Particle tracking using IDL -- John C. Crocker and Eric R. Weeks
Home | Download software | Tutorial | Extra software

msd.pro

This program calculates the mean square displacement of data in a track array:

IDL> m = msd(t)
IDL> plot,m(0,*),m(3,*),/xlog,/ylog; this is <x^2>
IDL> oplot,m(0,*),m(4,*),linestyle=1; this is <y^2>

The output of msd has several columns, they are:

The angle brackets indicate averages over all particles and all starting times. The last column, N, is an estimate of the independent number of data points in the average. This is a little tricky to explain. Start with N' being the actual number of dx's that are computed. For dt = 1 frame, N' = N. For larger dt's, N = 2 N' / dt. The rationale is that for large dt's, there's a lot of redundant data, so less truly independent measurements (see below). Anyway, if you want to get back N', just do something like:

IDL> m = msd(t)
IDL> m2 = m
IDL> m2(6,*) = round(m2(6,*)*m2(0,*)/2.0)
IDL> m2(6,0) = m(6,0)

There are several keywords you can use:


Calculating the mean square displacement

A very brief tutorial. Define:

Then, define

where the mean is taken over all initial times t, and all particles. This is the mean displacement. Likewise,

is the mean square displacement. You can perhaps see why we define N the way we do, above. For example, imagine you have a trajectory that is 1000 time steps long, and you are calculating the mean square displacement for dt = 998. This is:

The average is taken over the initial times (t=0,1) and thus there are two dx's that we're averaging. However, these two dx's are nearly the same, as x[0] and x[1] are approximately the same, and likewise x[998] and x[999]. Thus, there's approximately one independent measurement being used, and we define N = (2 * 2) / 999 = 0.004 as a very small number indicating that this is a rather poor average. Currently the default is that MSD is calculated as long as N > 1000; this conservatively stops the MSD calculation a little early. To override this, use the MAXTIME keyword as described above, or use the secret keyword which you learn because you've read all the way to the bottom of this webpage:

One final note: For a dilute sample of colloidal particles, you should find:

That is, the MSD grows linearly with the lag time, with a proportionality constant being related to the diffusion constant D.


This program was written by John, and improved by Victor Breedveld, who fixed a DOS-related bug and made some other minor improvements. This web page was written by Eric.

Click here to return to microrheology summary page


Contact us