Moving Line Chart: External Data
This facility enables you to display multiple lines, each defined by sets of XY coordinates. Individual lines can be highlighted in turn to produce an animated display showing changes in the line shapes. The lines do not have to be monotonic and they can be self-intersecting (i.e. they can curve back on themselves).
The aim is to facilitate analysis of moving and changing shapes in which the location of particular parts of the shape are defined by XY coordinates, with each row of coordinates (line) representing the shape at sequential moments in time.
- Open the Moving Line Chart dialog by selecting it from the Analyse: External data menu.
Data source
The canonical data source is plain-text tab- or comma-separated numbers defining X, Y coordinates, arranged in a square matrix. Each row defines a line, with X and Y values in alternating columns, thus:
ln 1 X 1 ln 1 Y 1 ln 1 X 2 ln 1 Y 2 … ln 2 X 1 ln 2 Y 1 ln 2 X 2 ln 2 Y 2 … … ... … …
However, there can be an arbitrary number of header rows and left-hand columns containing information that does not define line point coordinates, and also the X and Y columns can be interspersed by columns containing non-coordinate information, so long as the same format repeats for each X, Y pair. When data are loaded, the user specifies the format of the data, which can vary within the limits just described.
There are 3 ways to load data into the program:
- Copy the data onto the clipboard outside of DataView and then click the Paste button in the Moving Line Chart dialog.
- Click the Load button in the dialog and select a text (.txt) or CSV (.csv) file defining the data.
- Drag-and-drop a text or CSV file containing the data from File Explorer onto the dialog.
The table below shows 15 lines, each containing 8 X-Y coordinate pairs, arranged in the canonical format (so 16 columns in total).
635.9 800.0 649.5 813.0 662.5 824.4 671.7 838.5 675.4 854.2 675.5 866.8 678.9 878.1 687.1 894.4 634.4 796.9 645.4 808.7 658.9 820.1 671.2 832.9 676.7 847.4 678.6 863.0 679.6 877.7 678.5 891.4 628.9 794.5 640.2 804.8 653.6 815.7 667.7 828.0 678.2 842.0 679.7 859.4 681.0 873.0 676.1 891.6 624.3 790.3 635.0 803.6 646.9 815.7 658.7 825.2 671.7 833.3 680.7 849.1 681.1 864.1 677.7 881.9 621.9 785.3 630.5 800.0 640.7 813.9 651.8 823.2 666.4 832.3 675.2 842.9 682.3 856.2 681.1 875.4 620.7 781.9 627.4 797.2 636.6 813.7 648.8 825.0 660.0 830.8 673.3 839.2 683.1 850.0 685.3 865.3 620.1 778.8 626.0 795.2 634.4 812.9 642.8 826.2 652.2 833.1 670.3 839.4 681.3 846.5 687.9 858.3 617.6 773.9 624.1 791.1 631.4 808.3 637.3 822.8 648.2 833.8 665.8 840.5 679.1 847.1 688.3 854.3 617.6 769.0 624.1 787.0 630.8 802.4 633.8 818.8 644.8 831.1 659.1 841.1 675.2 845.9 687.5 848.6 617.7 764.4 625.7 779.9 632.2 796.9 635.1 812.9 640.6 829.9 650.7 840.1 663.5 847.2 684.9 848.9 616.0 761.3 625.0 775.7 633.6 792.2 634.5 808.1 639.4 825.8 646.6 837.1 656.9 846.1 675.5 852.1 613.8 756.4 625.3 770.7 633.2 784.9 638.3 802.8 640.4 821.1 643.4 831.0 651.6 844.0 665.6 853.8 611.2 751.1 622.8 765.1 632.1 778.2 641.2 793.4 641.1 812.1 643.9 825.8 645.8 838.2 654.2 851.3 609.2 747.7 620.0 762.0 632.4 774.0 639.3 785.1 645.0 801.7 645.4 815.7 642.9 832.4 650.8 849.0 607.2 744.8 616.1 757.6 627.9 770.1 638.5 781.6 644.7 794.4 649.6 806.8 645.5 820.8 642.6 832.7
- Select the data in the table above by draggging across them with the mouse, then copy them to the clipboard (usually control-C does the job).
- In the Moving Line Chart dialog, click the Paste button.
- This opens the Read Data Format dialog which enables you to specify deviations from the canonical format (you will see it in action later). However, these data are already in the canonical format, so just click OK.
The lines load into the Moving Line Chart dialog graphical display. Near the top left the dialog reports that there are 15 lines, each with 8 coordinate points. The data show the location of points along the body of a tadpole as it swims.
Data display
Above the top-left of the graph there is an edit box Selected line ID, which shows 1 in red. The graph itself shows 14 lines in grey with no symbol markers, and 1 coloured line with coloured symbols. The latter is the selected line, and with the default settings, the first coordinate point on the line has a red symbol marker, while the line itself and the remaning coordinate markers are blue. This differentiates the polarity of the line. These display features can all be adjusted by changing options in the Data display frame on the lower left of the graph.
Animation
- Click-and-hold the up spin button of the Selected line ID.
- This causes the Selected line ID value to progress through its range from 1 to 15.
Swimming in tadpoles is driven by alternating left-right flexions of the tail, and these movements are clearly visible as the animation progresses.
Interpolation
By default, coordinate points within a line are connected by straight-line segments (linear interpolation). Alternatively, data points can be connected by lines using Catmull-Rom spline interpolation.
- Select Spline from the Interpolation frame to the top-left of the graph display.
- Note that the coordinates are now joined by curving lines that give a more realistic impession of the body shape.
- The smoothness of the interpolation line can be adjusted by changing the n in line parameter from its default of 50.
- This parameter specifies how many coordinates there are defining the interpolated shape. The interpolation coordinates are themselves connected by straight lines, so if you have a very high definition display and expand the dialog, you may want to increase the value above its default.
One problem with this interpolation method is that the first and last segments can be distorted because there is no defined tangent to the curve at the end points. In DataView, the default solution is to use Linear end segment interpolation, but this can be turned off by de-selection if desired.
- Set the Selected line ID to 9.
- This line demonstrates the phenomenon most clearly in this data set.
- Deselect (uncheck) the Linear end segments option at the bottom of the Interpolation frame.
- Note that with full spline interpolation of every segment there is now a small spurious "wiggle" in the line joining the first (red) coordinate to the rest of the body shape. There is also a slight bend in the line connecting to the last coordinate, but this is less obvious.
Non-canonical formats (DeepLabCut)
The file swimming coordinates.csv contains data directly exported from the animal pose analysis program DeepLabCut.
- Save the CSV file linked above to a known location on your computer.
- Click the Load button in the Moving Line Chart dialog.
- Select the CSV file from the saved location.
The CSV file will be read and parsed into cells, and displayed in the Read Data Format dialog. The dialog can be expanded by dragging on a corner if desired.
The data format is the standard export format used by DeepLabCut. It has 3 non-data header rows, and 1 left-hand column specifying the line sequence number. The remaining data in each line is a repeating sequence consisting of a pair of columns specifying X and Y coordinates, followed by a column labelled "likelihood".
- Click the DLC button near the top-right of the dialog.
- Because the data is in an industry-standard format, this button automatically fills the format information appropriately.
Note that Top rows to skip is set to 3, the Left columns to skip is set to 1, and the skip value to the right of Y is set to 1 so that the likelihood column is skipped (other skip values remain at 0 since there are no other non-XY columns in the repeat sequence).
- Click OK to accept the format specification and close the Read Data Format dialog.
There are now 405 lines of data, each containing 11 coordinate points. The totality of grey (unselected) lines show a curving "C" shape showing the swim path of the tadpole, but the coloured first (selected) line is at the top left of the C.
More display options
- Click-and-hold the up spin button of the Selected line ID as before, to progress through the animation.
- Stop the animation when you reach line 60 (or thereabouts - the exact line doesn't matter).
- Unselect the Show unselected lines option in the Data display frame.
- This removes all the unselected lines from the display.
- Continue the animation, stopping when you get to about line 100.
- The tadpole swims through a clear display as if in a dish of water.
- Click the Zoom button near the top of the dialog, and drag a box around the line in the display.
- The scales change to zoom in to the selected line to show it in detail.
- Click the Show unselected lines check box to restore the context of the animation at this scale.
- Set the Show every n lines edit value to 10.
- Now only every 10th unselected line is shown. This may help reduce the confusion caused by so many lines in the display.
- Set the Selected line size to 2.
- This draws the selected line with a thicker width to make it stand out more.
- Click the Show unselected symbols check box to show the coordinate markers on unselected lines.
- NOTE that this option is only available for linear interpolation. With spline interpolation every coordinate defining the spline would be shown, which is almost certainly not what is wanted.
- Click the AutoScl button near the top-right of the dialog to return to scales that show all the data.
- Right-click one of the Selected line ID spin buttons (not the edit box itself) to open the Spin Control Properties dialog.
- Set the Delta value to 10.
- This means that the spin button will change the line ID in steps of 10.
- Click OK to dismiss the dialog.
- Click-and-hold the up spin button of the Selected line ID as before.
- Note that the animation progresses much more rapidly, but at the obvious expense of only showing every 10th line in the data set.
This has given you a tour of some of the display options that may be useful. However, in most cases the default values will probably be satisfactory.
Leg limitations
DataView currently assumes that all the data points lie on a single line, and that connecting them in sequence will yield a suitable representation of the shape. This is fine for something like a tadpole (or a snake), but could be confusing for a shape with branch points in the data, such as limbs projecing from the body of a legged animal. A partial solution might be to set the Selected line size to 0, in which case no connecting line is drawn. However, the viewer would then have to imagine the connections between the coordinate points to mentally construct the appropriate shape (or copy appropriate lines to an external drawing program, and manually add the connecting lines).