//Example macro that does a diffusion analysis on a results table of tracking //data. 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 //It requires many tracks and many time points! //The analysis uses the time ensemble average method described in Charsooghi, MA et al 2011 //http://www.sciencedirect.com/science/article/pii/S0010465510003620 //Get number of tracks (nTracks) nTracks = 0; for (a=0; anTracks) { nTracks = getResult("Track",a); } else{}; } //Find the track length for each track - write track length to results table //some variables Track=1; L_Track=0; //work though tracks and determine length for (i=0; imaxslice) { maxslice = getResult("Slice",b); } else{}; } //get first slice minslice = maxslice; for (c=0; cgetResult("Track", i-u)) {} else { if (getResult("T_Length", i)>=u && getResult("Track", i-u)==getResult("Track", i)) { B9 = getResult("X", i); B8 = getResult("X", i-u); C9 = getResult("Y", i); C8 = getResult("Y", i-u); disx2 = (B9-B8)*(B9-B8); disy2 = (C9-C8)*(C9-C8); dis2 = (disx2 + disy2); r_total = r_total+dis2; divide++; } } } } time = Array.concat(time, u); MSD = Array.concat(MSD, (r_total)/divide); r_total=0; divide=0; } Fit.doFit("Straight Line", time, MSD); intercept = d2s(Fit.p(0),6); slope = d2s(Fit.p(1),6); r2 = d2s(Fit.rSquared,3); print("slope = "+slope); print("intercept = "+intercept); print("R^2 = "+r2); Fit.plot(); //Richard Mort 26/01/2013