User Tools

Site Tools


macro:plot_zeroed_tracking_data

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

macro:plot_zeroed_tracking_data [2019/04/12 11:13] (current)
Line 1: Line 1:
 +<​code>​
 +//Plot tracking data from a results table zeroed
 +//The required format is as generated by the Manual Tracking plugin ​
 +//​http://​rsbweb.nih.gov/​ij/​plugins/​track/​track.html
 +//assuming Results table column headings: Track > Slice > X > Y
  
 +//some variables
 +Track = 0;
 +result = 1;
 +
 +//Plot the graph
 +Plot.create("​Scatter Plot", "​X",​ "​Y"​);​
 +//You may want to determine your own limits in some way here
 +Plot.setLimits(-250,​ 250, -250, 250);
 +
 +//Get number of tracks
 +for (a=0; a<​nResults();​ a++) {
 +    if (getResult("​Track",​a)>​Track)
 +    {
 +     Track = getResult("​Track",​a);​
 +    }
 +    else{};
 +}
 +
 +//Work though the data a track at a time
 +for (b=1; b<​(Track+1);​ b++)
 +
 +{
 +        x = newArray();
 +        y = newArray();
 +
 +//get first x and y value
 +x_0 = getResult("​X",​ result);
 +y_0 = getResult("​Y",​ result);
 +        ​
 +   for (i=result; i<​nResults;​ i++){  ​
 +    if (getResult("​Track",​i)==b) {
 +            x1 = (getResult("​X",​ i)) - x_0;
 +            x = Array.concat(x,​ x1);   
 +            y1 = (getResult("​Y",​ i)) - y_0;          ​
 +            y = Array.concat(y,​ y1);
 +            result++; ​       ​
 +
 +//Plot each track       
 +        Plot.setColor("​red"​);​
 +        Plot.add("​crosses",​ x, y);
 +        Plot.setColor("​darkGray"​);​
 +        Plot.add("​lines",​ x, y);
 + }
 + }
 +
 +}
 +//Richard Mort 26/01/2013
 +</​code>​
macro/plot_zeroed_tracking_data.txt ยท Last modified: 2019/04/12 11:13 (external edit)