16.01.2015 Views

Python algorithms in particle tracking microrheology - Chemistry ...

Python algorithms in particle tracking microrheology - Chemistry ...

Python algorithms in particle tracking microrheology - Chemistry ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

SOFTWARE<br />

Open Access<br />

<strong>Python</strong> <strong>algorithms</strong> <strong>in</strong> <strong>particle</strong> track<strong>in</strong>g<br />

<strong>microrheology</strong><br />

Timo Maier 1,2 and Tamás Haraszti 1,2*<br />

Abstract<br />

Background: Particle track<strong>in</strong>g passive <strong>microrheology</strong> relates recorded trajectories of microbeads, embedded <strong>in</strong> soft<br />

samples, to the local mechanical properties of the sample. The method requires <strong>in</strong>tensive numerical data process<strong>in</strong>g<br />

and tools allow<strong>in</strong>g control of the calculation errors.<br />

Results: We report the development of a software package collect<strong>in</strong>g functions and scripts written <strong>in</strong> <strong>Python</strong> for<br />

automated and manual data process<strong>in</strong>g, to extract viscoelastic <strong>in</strong>formation about the sample us<strong>in</strong>g recorded <strong>particle</strong><br />

trajectories. The result<strong>in</strong>g program package analyzes the fundamental diffusion characteristics of <strong>particle</strong> trajectories<br />

and calculates the frequency dependent complex shear modulus us<strong>in</strong>g methods published <strong>in</strong> the literature. In order<br />

to <strong>in</strong>crease conversion accuracy, segmentwise, double step, range-adaptive fitt<strong>in</strong>g and dynamic sampl<strong>in</strong>g <strong>algorithms</strong><br />

are <strong>in</strong>troduced to <strong>in</strong>terpolate the data <strong>in</strong> a spl<strong>in</strong>elike manner.<br />

Conclusions: The presented set of <strong>algorithms</strong> allows for flexible data process<strong>in</strong>g for <strong>particle</strong> track<strong>in</strong>g <strong>microrheology</strong>.<br />

The package presents improved <strong>algorithms</strong> for mean square displacement estimation, controll<strong>in</strong>g effects of frame loss<br />

dur<strong>in</strong>g record<strong>in</strong>g, and a novel numerical conversion method us<strong>in</strong>g segmentwise <strong>in</strong>terpolation, decreas<strong>in</strong>g the<br />

conversion error from about 100% to the order of 1%.<br />

Keywords: Particle track<strong>in</strong>g <strong>microrheology</strong>, Numerical conversion method, Software library, Dynamic <strong>in</strong>terpolation<br />

Background<br />

Particle track<strong>in</strong>g <strong>microrheology</strong> is a modern tool to <strong>in</strong>vestigate<br />

the viscoelastic properties of soft matter, for example,<br />

biopolymers and the <strong>in</strong>terior, or the membrane of<br />

liv<strong>in</strong>g cells [1,2] on the microscopic scale. Though embedd<strong>in</strong>g<br />

tracer <strong>particle</strong>s <strong>in</strong>to such a sample alters the local<br />

structure, this method is still considered non-<strong>in</strong>vasive and<br />

provides important <strong>in</strong>formation not available by other<br />

methods [1-4].<br />

The physical background of the method lies <strong>in</strong> the thermal<br />

motion of the tracer <strong>particle</strong>, which can be connected<br />

to the viscoelastic properties of the local environment<br />

through the generalized Langev<strong>in</strong> equation [5,6]. Neglect<strong>in</strong>g<br />

the <strong>in</strong>ertia term, which contributes to frequencies<br />

<strong>in</strong> the megahertz range, and assum<strong>in</strong>g that the memory<br />

function is l<strong>in</strong>early related to the frequency dependent<br />

*Correspondence: tamas.haraszti@uni-heidelberg.de<br />

1 Max-Planck Institute for Intelligent Systems, Advanced Materials and<br />

Biosystems, Heisenberg str. 3, 70569 Stuttgart, Germany<br />

2 Biophysical <strong>Chemistry</strong>, Institute of Physical <strong>Chemistry</strong>, University of<br />

Heidelberg, Im Neuenheimer Feld 253, 69120 Heidelberg, Germany<br />

viscosity of the medium (through a generalized Stokes-<br />

E<strong>in</strong>ste<strong>in</strong> relation)[3,5-8], the mean square displacement<br />

(MSD) of the <strong>particle</strong> can be directly related to the creep<br />

compliance as:<br />

J(τ) =<br />

3 πa<br />

N D k B T , (1)<br />

where τ denotes the time step <strong>in</strong> which the <strong>particle</strong> moves<br />

r distance, the mean square displacement,<br />

N D the dimensionality of the motion (usually N D = 2for<br />

<strong>particle</strong> track<strong>in</strong>g digital microscopy), k B the Boltzmann<br />

constant, T is the absolute temperature and a the <strong>particle</strong><br />

radius, respectively.<br />

Active <strong>microrheology</strong> (us<strong>in</strong>g optical or magnetic tweezers)<br />

and macroscopic rheometry commonly characterize<br />

the sample elasticity with the frequency-dependent complex<br />

shear modulus, G ∗ (ω), which is a complex quantity<br />

[4,9,10]. Its real part is known as the storage modulus<br />

G ′ (ω) and the imag<strong>in</strong>ary part is the loss modulus, G ′′ (ω).<br />

While J(t) is a description <strong>in</strong> the time doma<strong>in</strong>, G ∗ (ω) is<br />

an equivalent characterization <strong>in</strong> the frequency doma<strong>in</strong>.<br />

© 2012 Maier and Haraszti; licensee <strong>Chemistry</strong> Central Ltd. This is an Open Access article distributed under the terms of the<br />

Creative Commons Attribution License (http://creativecommons.org/licenses/by/2.0), which permits unrestricted use,<br />

distribution, and reproduction <strong>in</strong> any medium, provided the orig<strong>in</strong>al work is properly cited.


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 2 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

The two types of description are equivalent and <strong>in</strong>terconnected<br />

with the relation:<br />

G ∗ (ω) = 1<br />

iω˜J(ω) , (2)<br />

where ˜J(ω) is the Fourier transform of J(t). Assum<strong>in</strong>g that<br />

the <strong>particle</strong> tracks are previously obta<strong>in</strong>ed, the frequency<br />

dependent complex shear modulus G ∗ (ω) can be derived<br />

us<strong>in</strong>g equations (1) and (2) after calculat<strong>in</strong>g the mean<br />

square displacement.<br />

There are two major algorithm libraries available on the<br />

Interned address<strong>in</strong>g data handl<strong>in</strong>g for <strong>microrheology</strong>: the<br />

algorithm collection of J. Crocker et al. written <strong>in</strong> the<br />

<strong>in</strong>teractive data language (IDL) [11], which was translated<br />

to Matlab and expanded by the Kilfoil lab [12]. A separate<br />

stand alone algorithm is provided by M. Tassieri for<br />

calculat<strong>in</strong>g the complex shear modulus from the creep<br />

compliance, written <strong>in</strong> LabView [13]. However, an extensible<br />

<strong>in</strong>tegrated framework rely<strong>in</strong>g on freely accessible<br />

software and source code <strong>in</strong>tegrat<strong>in</strong>g multiple conversion<br />

methods is not yet available.<br />

In this paper we present a software package written <strong>in</strong><br />

the <strong>in</strong>terpreted program<strong>in</strong>g language <strong>Python</strong> (http://www.<br />

python.org) collect<strong>in</strong>g functions to support <strong>particle</strong> track<strong>in</strong>g<br />

<strong>microrheology</strong> related calculations, with emphasis on<br />

those parts provid<strong>in</strong>g enhanced functionality. This library<br />

is meant to be an open source, platform <strong>in</strong>dependent,<br />

freely extendable set of <strong>algorithms</strong> allow<strong>in</strong>g to extract<br />

rheology <strong>in</strong>formation from <strong>particle</strong> tracks obta<strong>in</strong>ed<br />

previously.<br />

The Rheology software library conta<strong>in</strong>s two example<br />

scripts. One called ProcessRheology.py, a configuration<br />

driven program perform<strong>in</strong>g all process<strong>in</strong>g steps from <strong>particle</strong><br />

trajectory <strong>in</strong>puts, thus present<strong>in</strong>g the various capabilities<br />

of the library (Figure 1). This program can be<br />

employed as a self-stand<strong>in</strong>g calculator or its code can<br />

be used as a template for the user test<strong>in</strong>g the Rheology<br />

library. The other is the Function-test.py, conta<strong>in</strong><strong>in</strong>g test<br />

calculations, and which was also employed to produce the<br />

figures <strong>in</strong> this article (see the content of the Additional<br />

file 1).<br />

Implementation<br />

Dependencies<br />

The software depends on the follow<strong>in</strong>g <strong>Python</strong> packages<br />

for calculations and display<strong>in</strong>g results:<br />

• Numpy: a library for array manipulation and<br />

calculations [14];<br />

• Scipy: the <strong>Python</strong> scientific library, from which we<br />

used the gamma function and the nonl<strong>in</strong>ear least<br />

squares fitt<strong>in</strong>g function [14];<br />

• Matplotlib: a Matlab-like plott<strong>in</strong>g library to generate<br />

<strong>in</strong>formation graphs of the results [15].<br />

Figure 1 Process flow chart of <strong>microrheology</strong> data. The<br />

fundamental process<strong>in</strong>g steps <strong>in</strong> <strong>particle</strong> track<strong>in</strong>g <strong>microrheology</strong> as<br />

followed by the ProcessRheology.py script. There are several<br />

parameters that may affect the details of the process, <strong>in</strong>clud<strong>in</strong>g the<br />

sampl<strong>in</strong>g <strong>in</strong> the MSD calculation and which way the complex shear<br />

modulus is calculated (see the ma<strong>in</strong> text for details). In this article we<br />

focus ma<strong>in</strong>ly on the later tree steps <strong>in</strong> the process: the MSD<br />

calculation and conversion methods.<br />

After <strong>in</strong>stallation, its functions are available us<strong>in</strong>g follow<strong>in</strong>g<br />

import command with<strong>in</strong> the <strong>in</strong>terpreter or a<br />

<strong>Python</strong> script:<br />

from Rheology import *<br />

Data presentation, data format<br />

Instead of def<strong>in</strong><strong>in</strong>g <strong>in</strong>dividual classes for each data type<br />

(MSD, creep compliance and complex shear modulus), an<br />

alternative technique <strong>in</strong> <strong>Python</strong> is to employ generalized<br />

lists, the so called dictionaries or ‘dicts’. A dict is a conta<strong>in</strong>er<br />

class hold<strong>in</strong>g data which are <strong>in</strong>dexed with arbitrary<br />

keys (marked by quotes <strong>in</strong> this paper). This is a very general<br />

and flexible data structure, which we used for all data<br />

<strong>in</strong> the Rheology package. For example, MSD dicts conta<strong>in</strong><br />

keys “tau” and “MSD” referr<strong>in</strong>g to arrays hold<strong>in</strong>g the time<br />

lag and the mean square displacement data, respectively.<br />

Particle trajectories<br />

Particle track<strong>in</strong>g <strong>microrheology</strong> starts with the imag<strong>in</strong>g<br />

experiments and the image treatment <strong>in</strong> a strict


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 3 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

sense, however, obta<strong>in</strong><strong>in</strong>g <strong>particle</strong> trajectories from video<br />

microscopy is well described <strong>in</strong> the literature [16-20]<br />

<strong>in</strong>clud<strong>in</strong>g the statistical difficulties of the process [21-23].<br />

There are various implementations of <strong>particle</strong> track<strong>in</strong>g<br />

<strong>algorithms</strong> available <strong>in</strong> IDL (see the same website as<br />

for the rheology code) [11,24], Matlab [12,25], LabView<br />

[20,26] or C++ languages [27]. An implementation of the<br />

Grier method [16] is also translated to <strong>Python</strong> [28].<br />

Thus, we start our discussion by extract<strong>in</strong>g rheological<br />

<strong>in</strong>formation from the <strong>particle</strong> trajectories, leav<strong>in</strong>g the<br />

implementation of data <strong>in</strong>put/output to the user. As a<br />

good start<strong>in</strong>g template, we recommend the ReadTable()<br />

and SaveTable() functions <strong>in</strong> the ProcessRheology.py example<br />

script.<br />

Drift correction<br />

Several experimental systems show a drift: a slow oriented<br />

motion of the sample versus the imag<strong>in</strong>g frame, which is<br />

caused by various factors of the experiment<strong>in</strong>g apparatus.<br />

To remove this drift, which is <strong>in</strong>dependent of the sample,<br />

there are multiple possibilities one may consider. If a<br />

reference bead bound to the sample is available, its trajectory<br />

provides the drift itself. If multiple <strong>particle</strong>s are<br />

tracked <strong>in</strong> the same time <strong>in</strong>terval, an average trajectory<br />

may be calculated and used as a reference. If these possibilities<br />

are not available, one has to consider whether<br />

the long time motion is due to drift or it is a characteristic<br />

of the <strong>in</strong>vestigated sample, because subtract<strong>in</strong>g it<br />

changes the resulted long time lag (low frequency) part of<br />

the viscoelastic characteristics.<br />

The simplest way of data treatment <strong>in</strong> such cases is<br />

to calculate a smoothened trajectory: e. g. us<strong>in</strong>g a runn<strong>in</strong>g<br />

average, and either subtract this smoothened data<br />

or, <strong>in</strong> one further step, fit a low order polynomial to the<br />

smoothened data and subtract the fitted values from the<br />

trajectory.<br />

A very simple implementation is available for two<br />

dimensional data sets as:<br />

GetData(timestamps, poslist, <strong>in</strong>dx=0,<br />

order=3,resolution=0.1434, Nd= 1000)<br />

This algorithm takes a position list (parameter poslist),<br />

which is a list of dicts, each describ<strong>in</strong>g the positions of a<br />

<strong>particle</strong>. The <strong>in</strong>dx parameter is used to select one of them.<br />

A position dict conta<strong>in</strong>s “X”, and “Y”, which are arrays of<br />

the x and y positions.Thedictalsoconta<strong>in</strong>san<strong>in</strong>dex<br />

array denoted with key “<strong>in</strong>dx”, identify<strong>in</strong>g the image <strong>in</strong>dex<br />

(serial number) of the given positions. Us<strong>in</strong>g this <strong>in</strong>dex<br />

allows the track<strong>in</strong>g algorithm to miss <strong>in</strong>dividual frames (e.<br />

g. when the <strong>particle</strong> drifted out of focus). This <strong>in</strong>dex is also<br />

used to def<strong>in</strong>e the time po<strong>in</strong>t of a position, either by identify<strong>in</strong>g<br />

the correspond<strong>in</strong>g time stamps, provided <strong>in</strong> seconds<br />

<strong>in</strong> the timestamps array, or if this variable is set to None,<br />

multiply<strong>in</strong>g the <strong>in</strong>dex by the optional tscale parameter.<br />

The Nd parameter gives the number of po<strong>in</strong>ts used <strong>in</strong> the<br />

runn<strong>in</strong>g average and the order parameter identifies the<br />

order of the polynomial to be fitted for drift correction. If<br />

Nd is set to −1, the runn<strong>in</strong>g averag<strong>in</strong>g is off, and if order is<br />

-1, the drift correction is turned off. The resolution is used<br />

to scale the coord<strong>in</strong>ates to micrometers (the same value<br />

for both coord<strong>in</strong>ates).<br />

Mean square displacement (MSD)<br />

Characteriz<strong>in</strong>g a soft sample us<strong>in</strong>g <strong>particle</strong> track<strong>in</strong>g<br />

<strong>microrheology</strong> strongly relies on the determ<strong>in</strong>ation of<br />

the mean square displacement. Calculat<strong>in</strong>g the MSD has<br />

two possible sets of assumptions: 1.) ensemble averages<br />

are based on record<strong>in</strong>g many tracer <strong>particle</strong>s and assum<strong>in</strong>g<br />

homogeneity across the sample. This is the averag<strong>in</strong>g<br />

method considered <strong>in</strong> theories, and has the advantage<br />

allow<strong>in</strong>g estimation of the time-dependent ag<strong>in</strong>g of the<br />

system. Technically this can be achieved by us<strong>in</strong>g video<br />

record<strong>in</strong>g-based <strong>particle</strong> track<strong>in</strong>g, where the number of<br />

tracers can be <strong>in</strong>creased to the order of tens. 2.) Assum<strong>in</strong>g<br />

ergodicity, one can switch from ensemble averag<strong>in</strong>g to<br />

time averag<strong>in</strong>g. This is very important for systems which<br />

are not homogeneous and for cases where only few <strong>particle</strong>s<br />

(1 − 5) can be observed at a time. For samples of<br />

biological orig<strong>in</strong>, time averag<strong>in</strong>g is more suitable because<br />

these samples are seldom homogeneous.<br />

Calculat<strong>in</strong>g the time average is done by splitt<strong>in</strong>g up the<br />

trajectory <strong>in</strong>to non-overlapp<strong>in</strong>g parts and averag<strong>in</strong>g their<br />

displacement.Becausethenumberof<strong>in</strong>tervalsdecreases<br />

with an <strong>in</strong>creas<strong>in</strong>g lag time, this method has very high<br />

error for large lag time values. Alternatively, it is also possible<br />

to split the trajectory <strong>in</strong>to overlapp<strong>in</strong>g regions and<br />

then do the averag<strong>in</strong>g. The result<strong>in</strong>g statistical errors follow<br />

a non-normal distribution, but it has been shown that<br />

us<strong>in</strong>g overlapp<strong>in</strong>g segments the resulted MSD may show<br />

improved accuracy [29,30] when us<strong>in</strong>g lag time values up<br />

to about the quarter of the measurement length (N/4 for<br />

N data po<strong>in</strong>ts). The results of a test calculation us<strong>in</strong>g positions<br />

randomly calculated from a normal distribution with<br />

standard deviation of σ X = σ Y = 0.15 μm <strong>in</strong> both X and<br />

Y directions are presented <strong>in</strong> Figure 2. The MSD oscillates<br />

around the theoretical value of = 2(σ 2 X +<br />

σ 2 Y ) = 0.09 μm2 as expected, but the data calculated us<strong>in</strong>g<br />

overlapp<strong>in</strong>g <strong>in</strong>tervals show visibly better accuracy.<br />

msd = MSD(positionlist, tau= 0)<br />

MSD() is the function to calculate the mean square displacement<br />

from a s<strong>in</strong>gle trajectory. The data po<strong>in</strong>ts are<br />

presented as a two dimensional array positionlist,conta<strong>in</strong><strong>in</strong>g<br />

coord<strong>in</strong>ates ((x, y) or (x, y, z)) <strong>in</strong> each row.<br />

The second parameter (tau) is used to generate the lag<br />

time values (steps) for which the MSD is calculated. This


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 4 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

MSD, μm 2<br />

1<br />

0.1<br />

0.01<br />

0.001<br />

0.01 0.1 1 10 100<br />

τ, seconds<br />

Figure 2 mean square displacement data calculated from<br />

simulated data. The distribution of X and Y positions were generated<br />

based on a normal distribution with σ = 0.15 μm. The theoretical<br />

MSD is constant at 0.09 μm 2 (black l<strong>in</strong>e). Data with non-overlapp<strong>in</strong>g<br />

<strong>in</strong>tervals (red + symbols) show higher scatter<strong>in</strong>g, the ones calculated<br />

with overlapp<strong>in</strong>g <strong>in</strong>tervals (green ×) show a much lower error.<br />

parameter can take various values: If an array or list of<br />

<strong>in</strong>teger values are given, then those are used as <strong>in</strong>dex step<br />

values. If a s<strong>in</strong>gle <strong>in</strong>teger is given between 0 and the number<br />

of positions, then so many <strong>in</strong>dex steps (lag time values)<br />

are generated <strong>in</strong> an equidistant manner. If noth<strong>in</strong>g, or 0 is<br />

given, then values 1 ...N/4areused.<br />

Each tau value results <strong>in</strong> M = M(tau) pairs, where<br />

the step r[ i + tau] −r[ i]iscalculated.M also depends on<br />

whether the set was generated us<strong>in</strong>g overlapp<strong>in</strong>g <strong>in</strong>tervals<br />

(if overlap = True is set).<br />

If an array of time values (<strong>in</strong> seconds) are provided for<br />

the position data us<strong>in</strong>g the optional tvector parameter, the<br />

algorithm will check the time step between each data pair<br />

used. Calculat<strong>in</strong>g the mean value of these time steps and<br />

us<strong>in</strong>g a relative error, every value outside the mean (1 ±<br />

tolerance) will be ignored (by default tolerance = 0.1).<br />

This process elim<strong>in</strong>ates jumps <strong>in</strong> the data caused by computer<br />

latency dur<strong>in</strong>g record<strong>in</strong>g.<br />

The function returns a dictionary conta<strong>in</strong><strong>in</strong>g “tau”,<br />

“dtau”,“MSD”,“DMSD”keys.Ifthetimevalueswerenot<br />

provided, then “tau” holds the <strong>in</strong>dex steps between the<br />

positions and “dtau” is not used.<br />

Creep compliance<br />

Assum<strong>in</strong>g that the generalized Stokes-E<strong>in</strong>ste<strong>in</strong> relation<br />

holds, the creep compliance is l<strong>in</strong>early proportional to the<br />

MSD [6]. The MSD to J() function calculates the creep<br />

compliance us<strong>in</strong>g equation (1).<br />

J = MSD to J(msd, t0= 0.1, tend= 150,<br />

T= 25.0, a= 1.0)<br />

The calculation requires a dict structure (msd) hav<strong>in</strong>g<br />

thetimevaluesunderthe“tau”key,andtheMSDvalues<br />

under the “MSD” key (error values are optional). Further<br />

parameters are the temperature T of the experiment <strong>in</strong><br />

Celsius degrees, the radius a oftheappliedtracer<strong>particle</strong><br />

<strong>in</strong> micrometers, and optionally the dimensionality of the<br />

motion D (denoted as N D <strong>in</strong> equation (1)), which is set to<br />

D = 2 by default.<br />

Calculat<strong>in</strong>g the frequency dependent shear modulus<br />

from J(t) with the numerical method proposed by Evans<br />

et al. requires extrapolated values to the zero time po<strong>in</strong>t<br />

and to <strong>in</strong>f<strong>in</strong>ite time values. These values are estimated<br />

here, allow<strong>in</strong>g the user to override them before be<strong>in</strong>g used<br />

to calculate the complex shear modulus G ∗ (ω). Thezero<br />

time value J 0 = J(t = 0) is extrapolated from a l<strong>in</strong>ear fit<br />

<strong>in</strong> the t < t0 region, and the end extrapolation is obta<strong>in</strong>ed<br />

from a l<strong>in</strong>ear fit to the tend < t part.Theslopeofthe<br />

extrapolated end part is 1/η, whereη is the steady state<br />

viscosity [31].<br />

The function returns a new dict conta<strong>in</strong><strong>in</strong>g: “J” (<strong>in</strong><br />

1/Pa), “tau”, “eta”, “J0”, “const”, “dJ”, and the fit parameters<br />

as “a0”, “b0” for the first part and “a1”, “b1” for the end part,<br />

where the l<strong>in</strong>ear equation J = a i t + b i (i = 0, 1) holds.<br />

Calculat<strong>in</strong>g the frequency dependent complex shear modulus<br />

While the connection presented by equation (2) is simple,<br />

there is a major problem with determ<strong>in</strong><strong>in</strong>g ˜J(ω) numerically.Itiswellknown<strong>in</strong>numericalanalysisthatapply<strong>in</strong>g<br />

a numerical Fourier transform <strong>in</strong>creases the experimental<br />

noise enormously [32]. In <strong>microrheology</strong>, there are<br />

four commonly applied methods to solve this problem.<br />

The first two address the noise of the Fourier transform<br />

directly by averag<strong>in</strong>g or by fitt<strong>in</strong>g, the second two were<br />

suggested <strong>in</strong> the last decade to improve the transform<br />

itself [6,9,31-33].<br />

In a homogeneous system, where multiple <strong>particle</strong>s can<br />

be tracked, convert<strong>in</strong>g their MSD to creep compliance and<br />

then G ∗ (ω) us<strong>in</strong>g a discrete Fourier transform, allows one<br />

to average the converted values and decrease the noise<br />

this way [32,33]. For cases when the creep compliance can<br />

be modeled us<strong>in</strong>g an analytical form, the Fourier transform<br />

of the fitted analytical function may be calculated<br />

and used to estimate of G ∗ (ω) [9].<br />

As we have discussed above, samples of biological orig<strong>in</strong><br />

are often not homogeneous and their MSD does not follow<br />

a well-described analytical function. However, model<br />

calculations suggest, <strong>in</strong> agreement with experiments, that<br />

biopolymers and many polymer gels show power law<br />

behavior at various time ranges [34-36]. The third and<br />

fourth conversion approaches have been suggested for<br />

such systems <strong>in</strong> the <strong>microrheology</strong> literature. One uses<br />

a power law approximation of the MSD or the creepcompliance<br />

[6] (we shall call the Mason method), and the<br />

other calculates a l<strong>in</strong>ear <strong>in</strong>terpolation between the data<br />

po<strong>in</strong>ts and apply<strong>in</strong>g a discrete Fourier transform on it [31]<br />

(we shall cite as the Evans method).


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 5 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

Because these methods have their strength and weakness,<br />

we summarize them and their implementation<br />

below. Recently we have shown that the accuracy of the<br />

Evans method can be greatly improved by us<strong>in</strong>g local<br />

<strong>in</strong>terpolation of the data <strong>in</strong> a spl<strong>in</strong>elike manner without<br />

forc<strong>in</strong>g a s<strong>in</strong>gle function to be fitted to the whole data<br />

set. This improvement is also <strong>in</strong>cluded <strong>in</strong> the Rheology<br />

framework and will be discussed below.<br />

The Mason method<br />

This is a fast conversion method based on the Fourier<br />

transformation of a power function, which has been used<br />

<strong>in</strong> various works <strong>in</strong> the last decade [6-8,37-39]. Briefly,<br />

let us consider a generalized diffusion process, where the<br />

MSD is follow<strong>in</strong>g a power law: < r(t) 2 >= 2N D Dt α<br />

[40], where D is the generalized diffusion coefficient, and<br />

0


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 6 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

J 0 and η are already estimated us<strong>in</strong>g the l<strong>in</strong>ear fits <strong>in</strong><br />

the MSD to J() function. Us<strong>in</strong>g equation (5) is straightforward,<br />

and allow for the calculation of G ∗ (ω) at any ω<br />

values. The natural selection of a suitable frequency range<br />

would be from 0 to N<br />

T π (the unit is 1/s) <strong>in</strong>N/2 stepsas<br />

it is common for the discrete Fourier transform of equally<br />

sampled data [32]. The correspond<strong>in</strong>g function is:<br />

G = J to G(J)<br />

The algorithm generates a l<strong>in</strong>ear array of frequencies,<br />

but the number of po<strong>in</strong>ts is limited to be maximum 1000,<br />

usually more than sufficient (MSD and creep compliance<br />

data arrays may hold several thousand po<strong>in</strong>ts). The result<br />

is a similar dictionary as it was for the Mason method,<br />

and can be tested us<strong>in</strong>g a Maxwell-fluid, which has a l<strong>in</strong>ear<br />

creep compliance <strong>in</strong> the form of J(t) = 1/E + t/η<br />

(Figure 4).<br />

There are various details worth mention<strong>in</strong>g about this<br />

method, which may affect the accuracy of the result <strong>in</strong><br />

general cases. It is clear <strong>in</strong> equation (5), that the method is<br />

sensitive to the A k+1 − A k terms, which, <strong>in</strong> extreme cases,<br />

may be either very small for a nearly l<strong>in</strong>ear part of J(t) or<br />

very high for sudden jumps <strong>in</strong> the experimental data. In<br />

order to reduce round-off errors, one may elim<strong>in</strong>ate the<br />

closetozerovalues,(when|A k+1 − A k |


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 7 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

1. def<strong>in</strong>e the data range us<strong>in</strong>g <strong>in</strong>dices i 0 = 0 and<br />

i 1 = i(t 0 ), conta<strong>in</strong><strong>in</strong>g at least 4 data po<strong>in</strong>ts;<br />

2. fit function from i 0 ...i 1 , calculate the squared error<br />

of each po<strong>in</strong>t and estimate the average error;<br />

3. f<strong>in</strong>d the last po<strong>in</strong>t around i 1 where χ 2 (i 2 )


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 8 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

100<br />

Additional file<br />

G’, G’’, Pa<br />

10<br />

1<br />

Additional file 1: rheology.zip - compressed ZIP archive conta<strong>in</strong><strong>in</strong>g<br />

the Rheology <strong>Python</strong> package. The archive conta<strong>in</strong>s several files. The<br />

source code <strong>in</strong> the Rheology subfolder, a setup.py for <strong>in</strong>stallation,<br />

README.txt and License.txt files and the Example subfolder. Installation (as<br />

usual <strong>in</strong> python):<br />

python setup.py build; python setup.py <strong>in</strong>stall<br />

0.1<br />

0.01<br />

0.1 1 10 100 1000<br />

ω, 1/s<br />

Figure 6 Dynamic resampl<strong>in</strong>g. Dynamic resampl<strong>in</strong>g can correct the<br />

errors of the Evans method result<strong>in</strong>g <strong>in</strong> an improved fit. The storage<br />

modulus (red +) and loss modulus (green ×) data calculated<br />

numerically shows a good fit to the theoretically predicted values<br />

(black l<strong>in</strong>es).<br />

The Example subfolder conta<strong>in</strong>s two <strong>Python</strong> scripts. The Function-test.py<br />

can be used to run test calculations and see the example plots present<strong>in</strong>g<br />

that all functions work properly. The figures presented <strong>in</strong> this paper were<br />

also generated by this script.<br />

The ProcessRheology.py is a batch process<strong>in</strong>g script, controlled by<br />

commands and parameters provided <strong>in</strong> a config.txt pla<strong>in</strong> text file. An<br />

example of this file is also <strong>in</strong>cluded here, conta<strong>in</strong><strong>in</strong>g detailed description of<br />

every parameter. This scripts is a fully function<strong>in</strong>g <strong>microrheology</strong> data<br />

evaluation toolkit, utiliz<strong>in</strong>g the functions of the Rheology package.<br />

Abbreviations<br />

MSD, Mean square displacement.<br />

Compet<strong>in</strong>g <strong>in</strong>terests<br />

The Authors declare that they have not compet<strong>in</strong>g <strong>in</strong>terests.<br />

def<strong>in</strong>ed by the NSmooth parameter. The range is identified<br />

<strong>in</strong> the orig<strong>in</strong>al data, but then applied to the ref<strong>in</strong>ed<br />

data set. The result is an MSD, where sudden jumps are<br />

reduced, m<strong>in</strong>imiz<strong>in</strong>g the presence of oscillatory artifacts<br />

<strong>in</strong> the resulted complex shear modulus G ∗ (ω).<br />

Conclusions<br />

Inthispaperwehavepresentedafreesoftwaresolution<br />

for analyz<strong>in</strong>g <strong>particle</strong> track<strong>in</strong>g data for <strong>microrheology</strong>.<br />

Our software library implements the time average calculation<br />

of mean square displacement with control over the<br />

time shift <strong>in</strong> the data, and conversion methods to calculate<br />

the creep compliance and the complex shear modulus.<br />

Beyond the two most common methods mentioned <strong>in</strong> the<br />

literature, we have developed a dynamic local fitt<strong>in</strong>g procedure,<br />

which allows spl<strong>in</strong>e-like fitt<strong>in</strong>g of the MSD and<br />

improved conversion accuracy to about 1% from about<br />

100% for a Kelv<strong>in</strong>-Voigt model test.<br />

Availability and requirements<br />

Lists the follow<strong>in</strong>g:<br />

• Project name: Rheology for <strong>Python</strong><br />

• Project home page: http://launchpad.net/<br />

<strong>microrheology</strong>py/<br />

• Operat<strong>in</strong>g systems: Platform <strong>in</strong>dependent (L<strong>in</strong>ux,<br />

W<strong>in</strong>dows and Max OSX tested)<br />

• Program<strong>in</strong>g language: <strong>Python</strong> 2.7<br />

• Other requirements: Numpy 1.5, Scipy 0.1,<br />

Matplotlib 1.0<br />

• License: LGPL v3<br />

• Any restrictions to use by non-academics: see<br />

license<br />

Authors’ contributions<br />

TM and TH have developed the <strong>Python</strong> software together discuss<strong>in</strong>g and<br />

test<strong>in</strong>g the various features, and both contributed to writ<strong>in</strong>g this manuscript.<br />

Both authors read and approved the f<strong>in</strong>al manuscript.<br />

Acknowledgements<br />

This work was supported by the M<strong>in</strong>istry of Science, Research, and the Arts of<br />

Baden-Württemberg (AZ:720.830-5-10a). The authors would like to thank to<br />

Professor Dr. Joachim P. Spatz, Dr. Heike Boehm and the Max-Planck Society<br />

for the generous f<strong>in</strong>ancial support and Dr. Claire Cobley for assistance.<br />

Received: 13 September 2012 Accepted: 14 November 2012<br />

Published: 27 November 2012<br />

References<br />

1. Dangaria JHH, Butler PJJ: Macrorheology and adaptive <strong>microrheology</strong><br />

of endothelial cells subjected to fluid shear stress. Am J Physiol Cell<br />

Physiol 2007, 293:C1568—C1575.<br />

2. Bausch AR, Moller W, Sackmann E: Measurement of local viscoelasticity<br />

and forces <strong>in</strong> liv<strong>in</strong>g cells by magnetic tweezers. Biophys J 1999,<br />

76:573–579.<br />

3. Waigh TA: Microrheology of complex fluids. Rep Prog Phys 2005,<br />

68(3):685.<br />

4. Wirtz D: Particle-track<strong>in</strong>g <strong>microrheology</strong> of liv<strong>in</strong>g cells: pr<strong>in</strong>ciples<br />

and applications. Annu Rev Biophys 2009, 38:301–326.<br />

5. Mason TG, Weitz DA: Optical measurements of frequency-dependent<br />

l<strong>in</strong>ear viscoelastic moduli of complex fluids. Phys Rev Lett 1995,<br />

74(7):1250–1253.<br />

6. Mason TG, Ganesan K, van Zanten JH, Wirtz D, Kuo SC: Particle track<strong>in</strong>g<br />

<strong>microrheology</strong> of complex fluids. Phys Rev Lett 1997, 79:3282 – 3285.<br />

7. Mason TG: Estimat<strong>in</strong>g the viscoelastic moduli of complex fluids us<strong>in</strong>g<br />

the generalized Stokes-E, <strong>in</strong>ste<strong>in</strong> equation. Rheologica Acta 2000,<br />

39(4):371–378.<br />

8. Squires TM, Mason TG: Fluid mechanics of <strong>microrheology</strong>. Annu Rev<br />

Fluid Mech 2010, 42:413–438.<br />

9. Goodw<strong>in</strong> JW, Hughes RW: Rheology for Chemists. An Introduction.Second<br />

edition. Cambridge: RSC Publish<strong>in</strong>g; 2008.<br />

10. Mezger TG: The Rheology Handbook. 3rd revised edition. V<strong>in</strong>centz Network<br />

GmbH & Co. KG , Plathnerstr. 4c, Vol. 30175. Hannover, Germany: European<br />

Coat<strong>in</strong>gs Tech Files, V<strong>in</strong>centz Network; 2011.<br />

11. Crocker J, Weeks E: Microrheology tools for IDL . [http://www.physics.<br />

emory.edu/weeks/idl/rheo.html]


Maier and Haraszti <strong>Chemistry</strong> Central Journal 2012, 6:144 Page 9 of 9<br />

http://journal.chemistrycentral.com/content/6/1/144<br />

12. Kilfoil M, et al.: Matlab <strong>algorithms</strong> from the Kilfoil lab. [http://people.<br />

umass.edu/kilfoil/downloads.html]<br />

13. Tassieri M: Compliance to complex moduli, version 2. 2011. [https://<br />

sites.google.com/site/manliotassieri/labview-codes]<br />

14. Jones E, Oliphant T, Peterson P, et al.: SciPy: Open source scientific<br />

tools for <strong>Python</strong>. 2001. [http://www.scipy.org/]<br />

15. Hunter JD: Matplotlib: A 2D graphics environment. Comput Sci Eng<br />

2007, 9(3):90–95. [http://matplotlib.sourceforge.net/]<br />

16. Crocker JC, Grier DG: Methods of digital video microscopy for<br />

colloidal studies. J Colloid Interface Sci 1996, 179:298–310. [http://www.<br />

physics.emory.edu/weeks/idl/]<br />

17. Brangwynne CP, Koender<strong>in</strong>k GH, Barry E, Dogic Z, MacK<strong>in</strong>tosh FC, Weitz<br />

DA: Bend<strong>in</strong>g dynamics of fluctuat<strong>in</strong>g biopolymers probed by<br />

automated high-resolution filament track<strong>in</strong>g. Biophys J 2007,<br />

93:346–359.<br />

18. Gosse C, Croquette V: Magnetic tweezers: micromanipulation and<br />

force measurement at the molecular level. Biophys J 2002,<br />

82(6):3314–3329.<br />

19. Rogers SS, Waigh TA, Lu JR: Intracellular <strong>microrheology</strong> of motile<br />

amoeba proteus. Biophys J 2008, 94(8):3313–3322.<br />

20. Carter BC, Shubeita GT, Gross SP: Track<strong>in</strong>g s<strong>in</strong>gle <strong>particle</strong>s: a<br />

user-friendly quantitative evaluation. Phys Biol 2005, 2:60.<br />

21. Sav<strong>in</strong> T, Doyle PS: Statistical and sampl<strong>in</strong>g issues when us<strong>in</strong>g multiple<br />

<strong>particle</strong> track<strong>in</strong>g. Phys Rev E 2007, 76(2):021501.<br />

22. Sav<strong>in</strong> T, Doyle PS: Static and dynamic errors <strong>in</strong> <strong>particle</strong> track<strong>in</strong>g<br />

<strong>microrheology</strong>. Biophys J 2005, 88:623–638.<br />

23. Sav<strong>in</strong> T, Spicer PT, Doyle PS: A rational approach to noise<br />

discrim<strong>in</strong>ation <strong>in</strong> video microscopy <strong>particle</strong> track<strong>in</strong>g. App Phys Lett<br />

2008, 93(2):024102.<br />

24. Smith R, Spauld<strong>in</strong>g G: User-friendly, freeware image segmentation<br />

and <strong>particle</strong> track<strong>in</strong>g. [http://titan.iwu.edu/gspald<strong>in</strong>/rytrack.html]<br />

25. Blair D, Dufresne E: The Matlab <strong>particle</strong> track<strong>in</strong>g code<br />

respository.:2005 - 2008. [http://physics.georgetown.edu/matlab/]<br />

26. Milne G: Particle track<strong>in</strong>g. 2006. [http://zone.ni.com/devzone/cda/epd/<br />

p/id/948]<br />

27. Caswell TA: Particle identification and track<strong>in</strong>g. [http://jfi.uchicago.<br />

edu/tcaswell/track doc/]<br />

28. Haraszti T: ImageP: image process<strong>in</strong>g add-ons to <strong>Python</strong> and numpy.<br />

2012 2009. [https://launchpad.net/imagep]<br />

29. Flyvbjerg H, Petersen HG: Error estimates on averages of correlated<br />

data. J Chem Phys 1989, 91:461–466.<br />

30. Saxton M: S<strong>in</strong>gle-<strong>particle</strong> track<strong>in</strong>g: the distribution of diffusion<br />

coefficients. Biophys J 1997, 72(4):1744–1753.<br />

31. Evans RML, Tassieri M, Auhl D, Waigh TA: Direct conversion of<br />

rheological compliance measurements <strong>in</strong>to storage and loss<br />

moduli. Phys Rev E 2009, 80:012501.<br />

32. Press WH, Teukolsky SA, Vetterl<strong>in</strong>g WT, FB P: Numerical recipes <strong>in</strong> C++.<br />

second edition. Cambridge: Cambridge University Press; 2002.<br />

33. Addas KM, Schmidt CF, Tang JX: Microrheology of solutions of<br />

semiflexible biopolymer filaments us<strong>in</strong>g laser tweezers<br />

<strong>in</strong>terferometry. Phys Rev E 2004, 70(2):021503.<br />

34. Morse DC: Viscoelasticity of concentrated isotropic solutions of<br />

semiflexible polymers. 2. L<strong>in</strong>ear Response. Macromolecules 1998,<br />

31(20):7044–7067.<br />

35. Morse DC: Viscoelasticity of concentrated isotropic solutions of<br />

semiflexible polymers. 1. model and stress tensor. Macromolecules<br />

1998, 31(20):7030–3043.<br />

36. Gittes F, Schnurr B, Olmsted PD, MacK<strong>in</strong>tosh FC, Schmidt CF: Microscopic<br />

viscoelasticity: shear moduli of soft materials determ<strong>in</strong>ed from<br />

thermal fluctuations. Phys Rev Lett 1997, 79(17):3286–3289.<br />

37. Crocker JC, Valent<strong>in</strong>e MT, Weeks ER, Gisler T, Kaplan PD, Yodh AG, Weitz<br />

DA: Two-po<strong>in</strong>t <strong>microrheology</strong> of <strong>in</strong>homogeneous soft materials.<br />

Phys Rev Lett 2000, 85(4):888–891.<br />

38. Dasgupta BR, Tee SY, Crocker JC, Frisken BJ, Weitz DA: Microrheology of<br />

polyethylene oxide us<strong>in</strong>g diffus<strong>in</strong>g wave spectroscopy and s<strong>in</strong>gle<br />

scatter<strong>in</strong>g. Phys Rev E 2002, 65(5):051505.<br />

39. Cheong F, Duarte S, Lee SH, Grier D: Holographic <strong>microrheology</strong> of<br />

polysaccharides from streptococcus mutans biofilms. Rheologica Acta<br />

2009, 48:109–115.<br />

40. Tejedor V, Benichou O, Voituriez R, Jungmann R, Simmel F,<br />

Selhuber-Unkel C, Oddershede LB, Metzler R: Quantitative analysis of<br />

s<strong>in</strong>gle <strong>particle</strong> trajectories: mean maximal excursion method.<br />

Biophys J 2010, 98(7):1364–1372.<br />

41. Maier T, Boehm H, Haraszti T: Spl<strong>in</strong>elike <strong>in</strong>terpolation <strong>in</strong> <strong>particle</strong><br />

track<strong>in</strong>g <strong>microrheology</strong>. Phys Rev E 2012, 86:011501.<br />

doi:10.1186/1752-153X-6-144<br />

Cite this article as: Maier and Haraszti: <strong>Python</strong> <strong>algorithms</strong> <strong>in</strong> <strong>particle</strong> track<strong>in</strong>g<br />

<strong>microrheology</strong>. <strong>Chemistry</strong> Central Journal 2012 6:144.<br />

Publish with <strong>Chemistry</strong>Central and every<br />

scientist can read your work free of charge<br />

Open access provides opportunities to our<br />

colleagues <strong>in</strong> other parts of the globe, by allow<strong>in</strong>g<br />

anyone to view the content free of charge.<br />

W. Jeffery Hurst, The Hershey Company.<br />

available free of charge to the entire scientific community<br />

peer reviewed and published immediately upon acceptance<br />

cited <strong>in</strong> PubMed and archived on PubMed Central<br />

yours you keep the copyright<br />

Submit your manuscript here:<br />

http://www.chemistrycentral.com/manuscript/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!