Diffusion by Brownian Motion
Getting Data from your Video
One could analyze this data in a variety of ways. There are solutions that use exclusively Python or ImageJ or other image-analysis programs and software. Here are steps to turn your video into a stack of images, digitize those images, and fit your supposedly-Gaussian data in Python.
- Open your .avi file in ImageJ. Choose ‘non-virtual stack’ and ‘greyscale’. You should have a stack of images in greyscale, and for each frame of your video (they’re all timestamped)
- Go to Image →Adjust→Threshold. Choose ‘default’ and ‘B&W’. Your images should now be black specs on a white background. Choose ‘don’t reset range’, then apply. A new window will pop up. You should now have a black and white image for each frame in your video. Take a quick look through everything to make sure you don’t have a couple good frames followed by a bunch of black screens.
- Now run a macro to turn the black pixels into 1’s and the white pixels into 0’s. Go to Plugins→New→Macro and paste the following, then choose Macros → Run Macro:
macro "Stack profile Data" {
if (!(selectionType()==0 || selectionType==5 || selectionType==6))
exit("Line or Rectangle Selection Required");
setBatchMode(true);
run("Plot Profile");
Plot.getValues(x, y);
run("Clear Results");
for (i=0; i<x.length; i++)
setResult("x", i, x[i]);
close();
n = nSlices;
for (slice=1; slice<=n; slice++) {
showProgress(slice, n);
setSlice(slice);
profile = getProfile();
sliceLabel = toString(slice);
sliceData = split(getMetadata("Label"),"\n");
if (sliceData.length>0) {
line0 = sliceData[0];
if (lengthOf(sliceLabel) > 0)
sliceLabel = substring( line0,0,5) ;
}
for (i=0; i<profile.length; i++)
setResult(sliceLabel, i, profile[i]);
}
setBatchMode(false);
updateResults;
}
You now have a huge array with the x values in the first column and the summed y values for each image in the subsequent columns. Note that timestamps are conveniently located in the header, in units of seconds. - Use Python to fit your data with a Gaussian profile. Remember that you are only interested in the width of the Gaussian function, so you can set the amplitude to the variable A and let Python decide what it should be without you worrying about it at all. Consider using a very simple Gaussin-like function like
(7)
where Python will determine the best values for the amplitude (which you don’t care about) and the width (which you really, REALLY care about). - Focus on just the part of your image that has the chain you are interested in. You don’t have to fit every frame! You could fit every other image, or skip 2 or 3 if you still have enough data to fit the Gaussian widths as a function of time and see a trend.