1 Introduction

Particle tracking is utilized in several fields, such as single-molecule mechanics, live-cell mechanics, and drug delivery. Particle motion can reveal interactions with the microenvironment, transport mechanisms, and local fluid mechanics and rheology. The mean-square displacement (MSD) (Mason and Weitz 1995; Weihs et al. 2006) is a typical indicator for particle dynamics. However, the MSD may be misleading: in many experiments transient-trajectories occur, where particles change mode-of-motion during the observation time. Transients of local diffusion in cages punctuated by segments of active transport were observed in complex materials (Weeks et al. 2000), within yeast cells (Golding and Cox 2006; Weber et al. 2010; Jeon et al. 2011), within living mammalian cells (Suh et al. 2004; Bronstein et al. 2009), or on mammalian cells (Bursac et al. 2005). Analyzing an entire trajectory that exhibits transient elements, i.e., by time-averaging the steps, masks the motion’s intermittent nature and can lead to artifacts and misinterpretation (Weihs et al. 2007). Moreover, trajectories with similar MSD may in fact result from different transport mechanisms, and are not suitable for ensemble averaging or grouped analysis. Hence, approaches to reliably analyze transient single-particle trajectories are crucial, where transient elements can be segmented. Those will reveal mechanisms driving particles transport and structural features of the fluid. Here, we provide an automated approach to identify and segment transient-trapping trajectories. We successfully apply this approach to experiments using laser tweezers.

In complex fluids, the MSD is typically proportional to the observation time: 〈|r(t + τ) − r(t)|2〉 ~ τ α with an MSD scaling exponent, α, that indicates the mode-of-motion, which is in general referred to as anomalous diffusion (Saxton and Jacobson 1997; Metzler and Klafter 2000; Weihs et al. 2006). For free diffusion in a non-active system, the exponent is unity, while for hindered, sub-diffusive motion or super-diffusive active transport it is 0 ≤ α < 1 and 1 < α ≤ 2, respectively. However, the MSD cannot distinguish the underlying transport mechanisms leading to the observed exponents (He et al. 2008; Burov et al. 2011). Moreover, the MSD does not always accurately reflect the mode-of-motion or existence of concurrent transport mechanisms. For example, diffusive-like motion with α = 1 has been observed in active microtubule-fluctuations in myosin-driven actin networks (Brangwynne et al. 2008). In addition, transient-trapping trajectories erroneously exhibit an α = 1, while each segment accurately depicts caging (Weihs et al. 2007). We have recently shown that displacement-moments other than the second can reveal concurrent, same time-scale transport mechanisms (Gal and Weihs 2010), however, segmentation is still missing. In some cases, mechanistic origin of caging can be analytically described (Powles et al. 1992) and caging identified (Fujiwara et al. 2002; Reuveni et al. 2010). However, that approach is not generally applicable, for example in living cells, where a variety of (undetermined) forces may drive particle motion simultaneously. A noteworthy approach for detecting active- and passive-transients in intracellular particle motion has recently been provided (Arcizet et al. 2008), however, that does not apply universally (Gal and Weihs 2010) and typically requires user intervention.

Here, we present an automated analysis technique for transient-trapping trajectories, where the algorithm identifies and segments trajectory steps in traps from those of escape from the traps. We employ image-processing techniques to identify trapping. Our approach eliminates the need to predefine time-dependent step sizes and directionality within the trap, only requiring available experimental parameters alongside a lower limit for trap-to-particle ratio and time-in-trap. Our image-based approach allows identification of trapping segments, unbiased by specific step sizes within those traps or the mechanism driving those steps. Following trajectory segmentation by image-processing, we analyze escape and trapping trajectory step-segments separately to obtain controlling parameters; those include: sample viscosity, trap stiffness, and cage size, while other parameters can be added as required. Our method is generally applicable, requiring minimal user input and intervention. We apply the algorithm to experiments, accurately detecting a circular laser tweezers trap and calculating the trap stiffness and surrounding fluid viscosity from the segmented trajectory. Such segmentation could, for example, greatly enhance the recent important experiment on diffusion of stiff filaments (Fakhri et al. 2010) allowing more accurate measurement of reptation and disengagement times.

2 Methods

We develop an algorithm for automated single-particle analysis, separating transient regimes of local particle-trapping and regimes of escape from those traps. We use simulated trajectories where trap locations are known and can thus accurately determine trap step-density for different conditions. We portray each trajectory as an image of the travelled locations and determine the density of steps in a trap relative to a non-trap location; regional “hot-spots”, where there are many steps, are likely candidates for traps. We then employ image-processing techniques to identify the regions of trapping using a cutoff threshold, optimally determined for each trajectory in a wide-range of system and experiment conditions. Following that we determine the functional dependence of this threshold on system and experimental parameters. It is important to note that by analyzing the trajectories as images we disregard the time-dependence of the step locations; those are reintroduced at the end. The simulations, algorithm, and analysis were all developed and optimized in the MATLAB 2010a environment (Mathworks, Natick, MA).

To develop and optimize our algorithm, we generate trajectories with transients of diffusion in hard-edged cages and escape from those cages by diffusion combined with convection. The problem may also be mathematically formulated by combining the Langevin equations of motion that describe particle dynamics (Mason and Weitz 1995) with a trap potential and convective forcing term. However, in the general case, the trap potential is unknown and escape may not be by convection. Those equations would be difficult to solve for a general condition. Hence, as a first approximation we employ simplified simulations of trapping and escape and proceed to show how the approach is applicable in more general experimental conditions. We use a modified version of previously described simulations (Weihs et al. 2007). Free diffusion within traps is expected when no interaction with the microenvironment occurs and is typically the desirable experimental situation (Valentine et al. 2004). Convection was added to escape segments to ensure trap-partition for algorithm optimization and is discussed in more detail later; convective speed is not part of the algorithm parameters and trap separation is not required during experimental application.

2.1 The simulations

Trajectories are simulated by cycles of diffusion within a hard-edge trap and subsequent diffusive and convective escape (see Fig. 1a); simulations are described in detail in a previous study (Weihs et al. 2007). Trapping cycles simulate conditions where particles diffuse freely within a confined region and when an edge is encountered elastic return ensues. In many biological and physical systems the suspending fluid is water, hence we expect to measure diffusion within a Newtonian fluid when particles are small relative to the any network mesh. Diffusion is produced in both trapping and escape phases by generating steps with a normal distribution; those have a mean of 0 and variance of 1 for a narrow distribution (generated with the randn function in MATLAB). The size of a single step at time, τ (e.g., 1/frame rate) in a Newtonian liquid is defined by the Stokes–Einstein relation (Stokes 1856; Einstein 1956) and is detailed by (Weihs et al. 2007): 〈Δr 2(τ)〉 = 2k B /3πμR particle, with Bolzmann’s constant, k B, constant absolute temperature, T, particle radius, R particle, and viscosity, μ. Diffusing particles become trapped within polygonal cages. The cages are randomly generated polygons defined by 15 vertices with a user-defined average radius (see inset Fig. 1); this is in contrast to the original simulations, where simple circular cages were used. The polygonal cages provide a rounded but randomized trap shape. Such traps have are typically observed experimentally by particle tracking in biological, engineering, and food systems (Weeks et al. 2000; Suh et al. 2004; Bursac et al. 2005; Cohen and Weihs 2010). The hard trap-edge results in steps being cut short when an edge is encountered and the next step being directed toward the center, with some randomization.

Fig. 1
figure 1

Simulated transient trap-escape trajectories, where particle radius 50 nm, liquid viscosity at 50× water at 37°C, and 30 fps. a Representative simulated trajectory. Particle becomes transiently trapped in a region for approximately 10 s and escapes by diffusion combined with 3 μm/s convection for 1.3 s. Inset shows zoom in of a single trap, where interactions with the hard edges are apparent. b Mean-square displacement of the entire trajectory (top, blue) and each of the four traps (bottom, red overlapping plots). Analysis of the entire trajectory masks the caging, in contrast to analysis of each individual segment (color figure online)

The escape process is generated as Brownian motion concurrent with convection, where escape time is constant and convective speed is pre-defined with random direction in each cycle. To obtain the convective, direction escape, we sum in each frame a diffusive step and a convective step. The diffusive step is generated from the normal distribution and has random direction. To that we add in each frame a convective step composed of a constant speed, e.g., 3 μm/s will be 0.1 μm in a single frame at 30 fps. The convection is unidirectional, with a random albeit constant direction for each escape segment. Convective regimes are short relative to trapping regimes, 10–30% of the total trajectory steps. All simulated trajectories have four non-overlapping traps each, as a consistent basis for algorithm optimization. Hence, the overall trajectory time is proportional to the time spent in each trap, where the maximal trajectory time was 60 s.

The time-averaged MSD, 〈Δr 2(τ)〉 = 〈[x(t + τ) − x(t)]2 + [y(t + τ) − y(t)]2〉, does not correctly depict the time-dependent motion of the particles when transient elements are present; the angular brackets here represent time average. Figure 1b shows the MSD of the entire trajectory, which does not readily correlate to trajectory features, such as trapping. Conversely, when analyzing trapping segments separately, the caged nature of the motion is apparent. That bias in analysis would only be enhanced if many particles were also ensemble averaged together following the time average, losing the ability to reveal underlying mechanisms of motion and structural features from the MSD.

3 Algorithm development, testing, and application

3.1 The trap-identification algorithm

We use image-processing techniques to identify locations of transient-traps. Figure 2 shows a representative simulated trajectory and iterative determination of the optimal trap-identification threshold. Initially, we rescale each simulated trajectory-image to a 600 × 600 matrix, for uniformity. On the rescaled image-matrix of particle locations we apply an averaging filter with a 14 × 14 window size; that was determined as the optimum for the simulated trajectories (data not shown). Filtration provides a density image, where “hot-spots” indicate high step-density (see Fig. 2b). Hot-spots indicate where a particle step is within a (known) simulated trap. In many cases, a particle samples only part of the trap, e.g., due to short time-in-trap or residence time; in those cases we do not expect to identify the entire simulated trap. Hence, we obtain average thresholds inside and out of traps, which we then iterate between to determine the optimal threshold.

Fig. 2
figure 2

Iterative determination of trap location in simulated trajectories. a Trajectory steps are marked in blue (thin lines), simulated traps in red (thick lines), and identified traps in green (thick, wavy line); b filtered image with “hotspots” indicating higher step-density and likely traps; ce trap localization as a function of increasing threshold. The simulated trap, correctly and incorrectly identified regions are marked in red (line), blue (within region), and green (outside region), respectively. c Threshold value is too low and escape steps are identified; d optimal trap localization is achieved; e the threshold is too high, degrading the identified trap; and f quality of trap/non-trap determination for known simulated locations. Threshold increases with iteration number, while quality may also decrease. Maximum quality is >0.95 for over 98% of the simulated data (color figure online)

Quality of trap determination is defined by the number of pixels where trap or non-trap locations were correctly identified out of the total number of pixels (i.e., 600 × 600). When the threshold value is too low or too high, non-trap steps are erroneously identified as traps or trap steps are missed, respectively (Fig. 2). The optimal threshold (Fig. 2f) is an average on all four traps in each trajectory. That extends the sample space well beyond the number of simulated permutations and minimizes effects of irregularities.

3.2 Determining the threshold function

To facilitate application of the suggested approach to experiments, we determine a functional form for the threshold. Our approach can be used for experiments with parameters close to those tested here or the simulations can be further extended. The optimal threshold correlates with the chosen conditions for each simulation. We perform many permutations of the simulations parameter ranges typical to particle-tracking experiments (see Table 1). Following that we use linear least-squares parameter estimation (Beck and Arnold 1977) to determine the threshold function. For the final form of the function, we use parameters that are experimentally available or ones where a lower limit can easily be defined by the user. We maintained simulated viscosity at 34.6 mPa s, which is 50-fold water viscosity at 37°C. We also maintained a constant trap radius, simulating particle motion in a specific mesh network. To avoid overlapping traps during threshold optimization, we add a constant convective speed of 3 μm/s to the escape steps; the convective step per frame is always smaller than the diffusive step. We do not define the convective speed as a parameter in the threshold function, as it is not an experimentally available value and its purpose is only to ensure trap separation here.

Table 1 Simulation parameters for threshold function determination

Figure 3 shows the threshold dependence on each of the three base system and experiment parameters varied in the simulations: time spent in each trap, t trap, camera frame rate, rate, and particle radius, R particle. The threshold increases with the time-in-trap (Fig. 3a) and frame rates (Fig. 3b). That is expected, as longer time-in-trap and/or higher frame rates increase the number of steps and hence step-density; their product actually gives the number of steps in a trap. Higher step-density increases threshold values, making the difference between trap and background easier to distinguish, or improving quality of detection.

Fig. 3
figure 3

Trap threshold as a function of three simulated system-parameters: time-in-trap, frame rate, and particle radius. Points are iteratively determined threshold and lines are functional fits. In each plot, two parameters are varied and the third is held constant. a Particle radius is 25 nm; b particle radius is 25 nm; and c time-in-trap is 4 s

Threshold dependence on particle radius (Fig. 3c) is more complex. It is determined by the particle step-size and the area in the trap that remains free when the particle occupies it. The region where a particle may move, or the effective trap, is in fact smaller than the trap radius (Tseng et al. 2004); the average free annulus is defined by R trap − R particle. Particle step-size varies inversely with the square root of its radius and the frame rate (Weihs et al. 2007). At a constant frame rate, smaller particles have larger area for travel, but also exhibit larger steps. Hence, on average smaller particles encounter the edges more often, are more obviously caged, and their step-density and threshold increase (Fig. 3c); moreover, in the smallest particles each step is larger than R trap − R particle, leading to slightly different functional behavior. In contrast, large particles move in small steps within a small area, resulting in a dense trajectory in the trap. Thus, a balance between the area for travel and the diffusive step size determines the threshold dependence on particle radius. By fixing the trap radius in our simulations and changing the particle radius, we are also inherently modifying the particle-to-trap ratio of radii and the same functional behavior is expected for that ratio as for the radius.

We have used least-squares estimation to determine the functional dependence of the threshold. We define controlling parameters that are experimentally available, can be estimated from a trajectory, or can be bounded by the user, e.g., particle size, diffusive step-size, or minimal time-in-trap, respectively. Each parameters was fit independently and interaction parameters were also evaluated, e.g., number of steps in trap = t trap*rate. While, other functional forms may be suitable for the threshold, ours takes into account independent parameter effects as well as interaction between then and we believe is a good descriptor of the process. The exponents in the threshold equation were obtained by trial and error. Analysis provided the following threshold function:

$$ \begin{aligned} {\text{Threshold}} =& - 0.00223 \cdot t_{\text{trap}}^{0.5} - 0.00238 \cdot R_{\text{particle}}^{0.5} + 0.0000068 \cdot {\text{rate}}^{1.5} + 0.000458 \cdot \left( {t_{\text{trap}} \cdot {\text{rate}}} \right)^{0.75}\\ &+ 0.00088 \cdot \left( {{{R_{\text{particle}} } \mathord{\left/ {\vphantom {{R_{\text{particle}} } {\left\langle {\Updelta r^{2} \left( \tau \right)} \right\rangle_{\text{diffusion}} }}} \right. \kern-\nulldelimiterspace} {\left\langle {\Updelta r^{2} \left( \tau \right)} \right\rangle_{\text{diffusion}} }}} \right)^{1.7} + 0.042 \cdot \left( {{{R_{\text{particle}} } \mathord{\left/ {\vphantom {{R_{\text{particle}} } {\left( {R_{\text{trap}} - R_{\text{particle}} } \right)}}} \right. \kern-\nulldelimiterspace} {\left( {R_{\text{trap}} - R_{\text{particle}} } \right)}}} \right) + 0.0158. \\ \end{aligned} $$
(1)

We define a diffusive step, 〈Δr 2(τ)〉diffusion, as the distance travelled at the shortest lag time, 1/frame rate; those steps also depend on particle radius and viscosity (Weihs et al. 2007, 2006). When diffusive steps are small, a particle will sample traps slowly. Hence, if particle steps are small we expect to accurately observe and identify only small traps and can thus limit the R trap/R particle ratio according to step size and time-in-trap. We have defined R trap/R particle as an algorithm input and calculate the R particle/(R trap − R particle). We could detect traps with as few as 20-steps, when diffusion steps outside the trap were relatively small. Another bounding input is the time-in-trap, which we had maintained at a minimal cutoff of 1 s. We have observed that for step sizes <5 μm/frame the algorithm performs well with an R trap/R particle = 2, while higher values require a larger ratio. That can perhaps indicate which R trap/R particle to choose. However, as this is system dependent, e.g., frame rate can affect it, we leave it as a user input.

After a trap is identified, we reintroduce the time-element to improve detection. When analyzing a trajectory as an image, we basically disregard the time-dependence and order of the trajectory steps. Thus, we search for and append single step that were not identified in a trap and that are surrounded by steps that were. In doing so, we assume that there are no unphysical, large, single jumps out of a trap; that assumption can easily be verified by comparing the added steps to the median of the identified trap steps. In some cases, even more than a single step may actually belong to the identified trap. However, caution must be taken in adding those steps, as that may introduce errors and bias into the analysis. Convection was introduced into the algorithm to prevent trap-overlap. However, if overlap occurs, the time-dependence of the trajectory will reveal trapping at different times in the same location. Moreover, if escape is very slow and residence time in the trap is short, we expect to observe a Brownian-like trajectory, where no traps are apparent. In that case, we also do not expect the algorithm to detect any traps.

3.3 Algorithm verification and application to experimental data

We have analyzed 2D Brownian motion simulations, to test for false positives in trap detection. Brownian trajectories occasionally appear to linger at a location, yet that does not indicate local trapping (see Fig. 4a, inset). We have generated 10,000 random simulations of 200-nm diameter particles at 30 fps, in a Newtonian liquid with 50-fold water viscosity at 37°C. The average step-size in those simulations was 2.5–3 μm/frame, hence the trap was chosen as small relative to the particle size (R trap/R particle = 2). No traps were identified in over 70% of the Brownian trajectories. In about 20% of them a single trap was identified and in the remaining 10% of trajectories, more than 1 trap was identified. Informed filtration of the identified traps can considerably reduce the 30% false positive detection we have observed here. Here, for example analysis of the time-averaged MSD of the steps in the identified trap can sometimes provide an indication of the Brownian nature of the motion, as in Fig. 4a; the observed log-slope of close to unity indicates that no elastic trapping has occurred in the region and the identified trap can be automatically removed. In addition, the distribution of step sizes or other user-defined parameters could also be employed as an automated measure for identifying specific (expected) behaviors in a tested sample. The correlation between successive particle displacements or steps has recently been applied to provide insight on particle caging (Oppong and de Bruyn 2007; Rich et al. 2011). We apply it here as an approach to distinguish real and falsely identified traps.

Fig. 4
figure 4

Verification and application to experimental data. a Simulated Brownian motion of 200-nm diameter particle at 30 fps, in Newtonian liquid with viscosity 50× water at 37°C. Trajectory is in gray and identified trap is marked with thick black line; (inset, a) mean-square displacement (MSD) of the entire trajectory and the incorrectly identified trap, top and bottom lines, respectively. Dashed line is a guide to the eye of scaling exponent, α = 1. As the identified trap exhibits α > 0 it can be eliminated; b trajectory of a 500-nm diameter particle trapped by laser tweezers and then diffusing in glycerol. The identified trap is, as expected, circular; (inset, b) MSD of the entire trajectory and the elastic trap only (α = 0)

The correlation of successive steps can reveal true particle caging as compared to free diffusion in a region in the segmented trajectory. The correlation is defined as: \( \left\langle {x_{12} } \right\rangle = \left\langle {\frac{{\vec{r}_{1} \cdot \vec{r}_{2} }}{{\left\| {r_{1} } \right\|}}} \right\rangle \), where the vectors of successive steps 1 and 2 are dot multiplied and the angular brackets represent ensemble averages at a specific lag time. When particles are completely confined, typically above a certain lag time, successive steps will be in opposing directions, resulting in a negative correlation. In that case, the correlation varies inversely linear with the size of r 1 so that 〈x 12〉/‖r 1‖ tends toward −0.5 (Rich et al. 2011); this was verified with our simulations as well (data not shown). However, when particles are freely diffusing, successive steps will be uncorrelated. Thus, when a segment such as in Fig. 4a is input, the correlation exhibits a wide scatter as a function of r 1, meaning it is uncorrelated and is thus not a real trap. It is important to note that this metric is applicable to segments of the trajectories, as provided by our algorithm, or to trajectories where a persistent mode-of-motion exists throughout the examination, e.g., persistent trapping. Inputting a trajectory with transient elements on the same time-scales, such as in the simulations in Fig. 1, results in a non-interpretable correlation. Having optimized and verified our trap-identification algorithm, we now apply it to experimental data.

We successfully analyzed trajectories from a laser tweezers experiment. We have transiently trapped a 500-nm diameter particle in Newtonian glycerol, using a 1064-nm laser, and then released it to diffuse freely. The algorithm correctly identified a single, elastic circular cage (Fig. 4b), as expected from a laser trap. Moreover, the identified time in the trap was consistent with the actual trapping time. It is important to note that in this data, a single trap was identified regardless of the R trap/R particle input parameter, albeit the trap dimensions varied slightly. We have also verified the trap through the successive-step correlation (Rich et al. 2011) and obtained consistent values of −0.5 in the ratio of the correlation and the step r 1 for the identified trap and uncorrelated motion for the remaining steps. We have calculated trap stiffness from the identified steps using the equipartition theorem k trap = 2k B T/〈Δr 2〉, and obtained a value of 3.1 pN/μm; the 〈Δr 2〉 is the variance of particle displacement from the trap center (Yao et al. 2009). We have also analyzed the steps outside of the trap and calculated the liquid viscosity by the Stokes–Einstein relation (Weihs et al. 2006; Cohen and Weihs 2010). Before trapping, the viscosity was determined to be 800 mPa s at 25°C and after trapping, viscosity was reduced to about 30 mPa s, indicative of local heating due to the laser.

4 Discussion and conclusions

We have presented an approach to automatically identify transient-traps in single-particle trajectories. The approach was successful in accurately analyzing experimental laser tweezers data quantifying trap and liquid parameters. We expect that our approach will be directly and successfully applicable to experimental trajectories where particles do not interact with their environment and the media is a Newtonian liquid. Those encompass most experimental systems studied to date, including living cells, biomaterials, and physical systems, such as surfactants and gels. The rheology of the material should not, however, affect algorithm, performance, as long as particles diffuse freely in the cages and do not interact; that is, as long as diffusion is the same at each location within a trap. Underlying diffusion, the basis of the simulations, exists in most active transport systems, e.g., living cells. In cells, video frame rate (30 fps) is typically enough to observe the underlying diffusion at the shortest lag time. We expect the step-density will remain qualitatively similar, albeit the time-in-trap and optimal R trap/R particle inputs will likely change. In experiments, for example, well-chosen particle size and frame rate can compensate for short residence times. For a new experimental data set, the threshold function can be re-optimized with a different simulation parameter-range, e.g., by changing underlying viscosity; viscosity affects the step sizes in and out of traps albeit not the general appearance of the expected trajectory. Hence, we expect that the method outlined here will be widely applicable for trajectory analysis in many different types of experiments. The automatic trap segmentation presented here allows easy application to large amounts of experimental data. In conclusion, the presented approach of single-particle trajectories reduces errors incurred by analyzing entire transient-trajectories and provides accurate indication which trajectories can be ensembled.