Dimensions of Trackmate track in MATLAB @msdanalyzer and mean squared displacement analysis

I’ve played around with the @msdanalyzer MATLAB script for recorded 2D particle tracks analyzed with Trackmate.

As I don’t have any Z dimension, I’ve excluded them when importing the tracks to MATLAB, like so:

[tracks, clipZ] = importTrackMateTracks('/path/to/track.xml');

This doesn’t remove the Z coordinates entirely. It just sets them all to 0. However, @msdanalyzer refuses to take the .xml if I don’t run it with 3 dimensions. It also refuses to take a file where I’ve manually removed all the Z-coordinates (e.g. so the XML file only shows <detection t="0" x="48.31941812287789" y="23.572161216923433" />.

Will this affect the way the final diffusion coefficient is calculated?

Hi @komodovaran

I think there is a syntax error in your command. You need to call it like this:

[tracks, metadata] = importTrackMateTracks('/path/to/track.xml', clipz);

with clipz = true.

3 Likes

Thanks!

I’ve only used MATLAB for a day so far, so the syntax is a bit foreign, coming from R.

If you’re not familiar with Matlab yet, and you prefer doing your analyses with open source software in order to be reproducible for everyone, I can recommend trying KNIME.
We did MSD analysis in this paper and the attached KNIME workflow (doi: 10.13140/RG.2.2.16490.31688).

2 Likes

@imagejan I will be sure to check it out, thanks :slight_smile:

Also, @tinevez Do you mind telling me how exactly the MSD plot and time lags are calculated? An explanation, or some documentation; both will do.

E.g. in the simplest case how would I draw this graph by hand, for a single particle? Following your tutorial gives a nice introduction to @msdanalyzer, but the math behind it is straight up voodoo to me.

I’ll fix the topic title so it doesn’t look off topic.

Hi @komodovaran
The physics is best explained in the references 1, 2 and 4 of the tutorials. The first one is the Einstein paper.

1 Like

Hello I am new to using @msdanalyzer, and I am also pretty new to matlab. I have some basic questions related to the applications.

So far I used 2-dimensional bead movement tracks (with input as 3 columns ; 1=timestamp 2=x 3=y). Am I able to use 3D x,y,z bead movement tracks as well to determine the MSD? In this case should the input have 4 columns (1=timestamp, 2=x, 3=y, 4=z)?

To analyze in 2D i set as below;
ma = msdanalyzer(2, ‘µm’, ‘s’)

so to analyze 3D i hope to set as below;
ma = msdanalyzer(3, ‘µm’, ‘s’)

Is this good practice? I hope the MSD will be calculated accurately and that I am not making any simple mistakes!

Would be great if you could advise me!

Thanks in advance!
Zara

Hi @Zara12345

Yes, the syntax ma = msdanalyzer(3, 'µm', 's') is the correct one for 3D.

Hello tinevez,

Thank you for your response!

A post was split to a new topic: Writing a plugin for micromanager

Hello tinevez,

Could you help me on how the MSD in analysed in the @msdanalyzer? Could you help me by giving the equations used for 2D and 3D MSD calculations please? Any references or documents I can refer for the mathematics?

Thanks a lot!

Z

@Zara12345, did you have a look at the documentation of @msdanalyaser?

https://tinevez.github.io/msdanalyzer/#brownian-motion-and-mean-square-displacement

Also, if you want to know implementation details, you can have a look at the computeMSD.m script:

1 Like

Hi imagejan,

yes, I did take a look at this, but as I am not very fluent with matlab coding I was unable to decipher how the MSD calculation is done. Could you help me by giving me a guide on how the data stored in the input array (1=timestamp, 2=x position in um, 3=y position in um, 4=z position in um) is converted to the MSD by this program?

A simplified step by step process or flow is what I am looking for. So sorry about being so matlab illiterate :slight_smile: But would be grateful if someone could help me out!

Thanks a lot!
Z