In this example we are going to track a set of randomly moving particles. We will analyze and classify the particles according to whether their motion is purely Brownian.
Import the video and extract the particles displaying motion:
The time lag (second argument of MSD) is chosen as 1/3 of the trajectory length. Moreover, only longer trajectories with a length > 35 are selected for computing the mean-squared-displacement:
Most trajectories for mean-squared displacement exhibit a linear trend, implying a Brownian motion, while a few trajectories deviate away from the straight line and possibly imply a super-diffusive regime. Moreover, for some trajectories the horizontal slope at larger timestep may also point to particles following a sub-diffusive motion.
Perform a linear fit to the MSDs of the particles to acquire gradients:
In[11]:=
gradients=a/.FindFit[#,ax+b,{a,b},x]&/@msd;
Cluster the gradients to define the different regimes of the particle motion, most likely linked to super diffusive, Brownian and sub-diffusive regimes:
Classify trajectories according to the Hurst exponent criterion.
Get the number of particles following the process in which the future increments are negatively correlated. The Hurst exponent between 0-0.5 suggest that particles having larger spatial shift at time 't' will likely have smaller step at 't+1' and subsequently larger spatial shift at 't+2':
In[16]:=
Count[hurstinds,x_/;0≤x<0.5]
Out[16]=
793
Get the number of particles exhibiting a Wiener Process or following Brownian motion. The autocorrelation decays exponentially towards 0. There is no memory effect in such cases:
In[17]:=
Count[hurstinds,x_/;x0.5]
Out[17]=
71
Get the number of particles following a process wherein the future increments are positively correlated. This implies that particles that have larger spatial steps now will tend to retain larger spatial steps in the future: