Time Axes Tool - nickcounts/MDRT GitHub Wiki

The Time Axes Tool allows for the definition of the x-axis limits to be applied to all axes inside the plotting window. The tool encompasses two separate codes that mimic each other in functionality but are called in separate locations.

Set Time Axes Limits

Location: MDRT\ApplicationModules\PlottingEngine\plotTools\setTimeAxesLimits.m

Set Time Axes is the primary code, allowing the user to define the time range of the data set prior to the execution of the plot. This tool is accessed from within the Plot Setup tool and is added as a separate tab within the window.

Within this tool, the user can specify the starting and stopping points of the desired plot, thus setting the x-axis limits. The start and stop times can be characterized by four options [5]:

  • None : This pulls either the first or last point of the FCS data set, thus representing what would normally be plotted without any restrictions to the x-axis.
  • Manual : This is a date and time of day represented in UTC time. The format of the inputted time must follow MM/DD/YY HH:MM:SS exactly to be accepted as valid.
  • Milestone : This is a timeline event marker as defined by the timeline.mat data set. Here, milestone is synonymous to ‘timeline event.’ Functionality with any added milestones through “Edit Timeline Events” has not yet been tested [1,4].
  • Offset: This is an offset from the respective start or stop time, limited to a maximum of 24 hours from the other data point. Inputs must take the form of HH:MM:SS exactly to be accepted.

The default option is a None-None case for the data set, and is the default within any empty graph structure. Changing the data for the starting and stopping points and hitting “Apply” then updates the graph structure with the latest information [2]. From here, the user can then switch back to the original Plot Setup tab, where the FD’s are selected, and plot the graph [3].

The save, load, and clear functions in the window toolbar still operate nominally. “Clear” will set the GUI fields back to the default of “None.” “Save” will save the graph config as a graph structure .gcf file to your folder. And “Load” will load any saved configurations and repopulate all GUI fields, including the inputted starting and stopping points [8]. However, these toolbar items must be executed from within the Variable Selection Tab [6].

The tool takes advantage of MATLAB’s ability to define the x-axis at any point of the plotting process. The x-axis limits can be passed to the graphing command itself or defined after the graph is created. As a result, it does not hinder any other tool functionality. If the user would prefer, he or she can still use the horizontal zoom tool to fine tune the data set in view.

Notes 1: Due to the nature of the timeline events and launch operations, there are some repeat commands. Milestones such as “FGSE FLS Low Flow Fill Command” occur twice at different points leading up to T-0. To make matters more confusing, the timeline.mat file does not extract the timeline events chronologically and thus the order in the drop-down menu is not entirely chronological. When selecting the proper repeat command, the first instance in the drop-down menu is the one that occurs earlier.

2: The user MUST hit “Apply” to save the start and stop information. Merely selecting new starting and stopping points and switching tabs does not update the graph structure and does not carry over into the plot. Pressing “Apply” does not currently result in any visible changes to the screen. Thus, if you’re not sure the “Apply” went through, nothing should break if you press it once more just in case.

3: Plotting typically takes some time (usually a maximum of 12 seconds) to fully plot the data set and then apply the x-axis limits. This is exacerbated by the reviewRescaleAllTimelineEvents which then updates and hides any milestone events that are now pushed off screen.

4: Every time you want to select a milestone you must actually click on the drop-down menu entry. For example, if you switch from none to milestone, the drop-down menu becomes active and the first entry is displayed. If you would like to select the first entry, you must still reselect it within the menu. In the case below, a manual stop time was originally in place and then switched to a milestone type. You’d have to physically select “Initiate GN2 Conditioning” even though it’s the first item that shows up.

5: The four options follow a map for compatible start and stop times. This means that the code is programmed to not allow an Offset-Offset option, among others. Such combinations are deemed impractical or theoretically impossible. The map follows the following structure.

6: You cannot load or clear a configuration file within the Axes Setup tab. All loading and clearing must be conducted from within the “Variable Selection” tab or what was originally the Plot Setup screen for simplicity. This is due to the nature of the setTimeAxesLimits code and how it is executed within makeGraphGUI. If you happened to load a .gcf file from within the Axes Setup tab, it would populate the Variable Selection Tab but fail to populate the Axes Setup tab. If you happened to clear a configuration from within the Axes, it would clear the Variable Selection tab not the Axes Setup tab.

7: One common error that results in the code breaking is if the user chooses a stop time that precedes the start time or a start time that succeeds a stop time. In this case, the MATLAB command window provides the following error: Error using matlab.graphics.axis.Axes/set Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be Inf

8: For reference, the terms graph configuration and graph structure are used interchangeably within this document. The graph structure is a MATLAB type structure titled ‘graph’ that stores the configuration of the graph to be plotted.

Integration:

The Set Axes Tool is represented by the code file setTimeAxesLimits(). This function is called within makeGraphGUI and executed upon tab switch. This is why it gets funky with the order of operations. The function begins running when you switch to the Axes Setup tab, and populates all the GUI elements when you open that tab. Essentially, the tab’s contents don’t exist until you click on the tab. The function is passed the graph structure from the makeGraphGUI code which is then passed back as an updated output after you click “Apply.” Once that function finishes up, it returns to makeGraphGUI and picks up with the next line of code, with the updated graph output now stored within the main code makeGraphGUI again.

Update Time Axes Limits

Location: MDRT\ApplicationModules\PlottingEngine\plotTools\updateTimeAxesLimits.m

Update Time Axes is a post-plotting tool that allows you to update the x-axis limits once you’re within the plot. It has a similar GUI layout to the Set Time Axes tool but now exists within its own window, called from the Toolbar Functions in the plotting window.

The tool has the same four options for the starting and stopping points and follows the same enable/disable logic as in Set Time Axes. Each time option also follows the same patterns as described above. However, this tool has two parent cases: execution within a Quick Plot and execution from a Plot Setup Plot.

Plot Setup

If the tool is called from within a plot created through Plot Setup, then the tool will populate with the existing x-axis limits [9]. For instance, let’s say you had the FLS Low Flow as your starting event and FLS Fill/Drain Line as your stopping event and plot under that configuration. When you open Update Time Axes from within the window, those milestones are already displayed and active as the current selection within the window.

Furthermore, since the graph structure is still present within Plot Setup plots, the Update Time Axes tool has both the option to apply the new limits to the axes or to save the updated graph structure. “Apply to Axes” will only update the x-axis on screen without changing the graph structure. “Save Graph Structure” will open a directory window to save the graph structure as either a new file or to overwrite the existing graph structure file.

Quick Plot

Within Quick Plot, the tool is initiated in the same manner, and still holds the ability to set the time axes to a new configuration. However, since Quick Plot does not process or save graph structures, as it merely plots one FD across its entirety, there is no current way of saving the axis configuration.

As a result, the “Save Graph Structure” is grayed out and disabled when the tall is called from the Quick Plot window. The user can then only temporally update the x-axis of the current figure from which the tool was called.

Another thing to note is due to the lack of graph structures, there currently is no implementation to save the current configuration. This means that if you were to set the x-axis to a certain Milestone-Offset, etc. combination and closed out of the Update Time Axes tool, the information would not repopulate upon reopening.

Notes 9. The x-axis limits do not need to be specified ahead of time for Update Time Axes to work. If it would be easier for the user to specify and save the graph structure after the data is plotted, then the Set Time Axes can be left blank and set to None-None as a default, and the x-axis can later be specified via this tool, Update Time Axes.

Integration

The code for the Update Time Axes is in updateTimeAxesLimits() which is called within addToolButtonsToPlot. Thus, whenever the toolbar button for tool is pressed within the plot window, the attached code executes. The trick was passing the graph structure and graphNumber (to be discussed under “Graph Bundle Tool”) to the code. Within Set Time Axes, the graph structure was a local variable inside the parent code and could thus be passed into setTimeAxesLimits. Here, the process was a bit more complicated. To start, the last instance of the graph structure existing within the parent code was found. The hierarchy of the code is as follows:

 _plotGraphFromGUI_ > _makeMDRTPlotFigure_ > _addToolButtonsToPlot_ > _updateTimeAxesLimits_

In plotGraphFromGUI the graph structure is passed from makeGraphGUI. Thus, the structure could theoretically be passed down the code to reach Update Time Axes. Instead, the structure was saved to the figure’s appdata, and thus attached to the plot it represents, in makeMDRTPlotFigure. It is this appdata that is read when updateTimeAxesLimits executes. Also saved to the appdata is the aforementioned graphNumber variable.

Theoretically, any code that executes from inside the plot window could then access and call the graph structure from the getappdata() command alone. This may prove useful for any future updates to the code or even the structure.