KymoTrackGroup¶
lumicks.pylake.kymotracker.kymotrack.KymoTrackGroup
- class KymoTrackGroup(kymo_tracks)¶
Tracks on a kymograph.
- ensemble_msd(max_lag=None, min_count=2) lumicks.pylake.kymotracker.detail.msd_estimation.EnsembleMSD¶
This method returns the weighted average of the Mean Squared Displacement (MSD) for all tracks in this group.
This method determines the MSDs per track and determines the weighted average of them. The intrinsic assumption made when computing this quantity is that all tracks are independent and all trajectories sample the same environment and undergo the same type of diffusion.
The estimator for the MSD (\(\rho\)) is defined as:
\[\rho_n = \frac{1}{N-n} \sum_{i=1}^{N-n} \left(r_{i+n} - r_{i}\right)^2\]For a diffusion process \(\rho_n\) is gamma distributed. From the additivity of independent gamma distributions we know that for \(N_T\) tracks of equal length 1:
\[E[\rho^{ens}_n] = \rho_n\]and
\[E[(\sigma^{ens})^2] = \frac{\sigma}{N_T}\]In reality, the tracks will not have equal length, therefore the returned statistics are weighted by the number of samples that contributed to the estimate. If all the tracks were of equal length with no missing data points, the weighting will have no effect on the estimates.
Note: This estimator leads to highly correlated estimates, which should not be treated as independent measurements. See 1 for more information.
- Parameters
References
- estimate_diffusion(method, *args, min_length=None, **kwargs)¶
Estimate diffusion constant for each track in the group.
Calls
KymoTrack.estimate_diffusion()for each track. See the documentation for that method for more detailed information and references.- Parameters
method ({"cve", "ols", "gls"}) –
“cve” : Covariance based estimator. Optimal if SNR > 1. Can only be used when track is equidistantly sampled.
”ols” : Ordinary least squares. Determines optimal number of lags.
”gls” : Generalized least squares. Takes into account covariance matrix (slower).
max_lag (int (optional)) – Number of lags to include when using an MSD-based estimator. When omitted, the method will choose an appropriate number of lags to use. For the cve estimator this argument is ignored. When the method chosen is “ols” an optimal number of lags is estimated as determined by. When the method is set to “gls” all lags are included.
min_length (None or int (optional)) – Discards tracks shorter than a certain length from the analysis. If
None(the default) tracks shorter than 3 points ifmethod == "cve"or 5 points ifmethod == "ols" or "gls"will be discarded.
- fit_binding_times(n_components, *, exclude_ambiguous_dwells=True, tol=None, max_iter=None)¶
Fit the distribution of bound dwelltimes to an exponential (mixture) model.
- Parameters
n_components (int) – Number of components in the model. Currently only values of {1, 2} are supported.
exclude_ambiguous_dwells (bool) – Determines whether to exclude dwelltimes which are not exactly determined. If
True, tracks which start in the first frame or end in the last frame of the kymograph are not used in the analysis, since the exact start/stop times of the binding event are not definitively known.tol (float) – The tolerance for optimization convergence. This parameter is forwarded as the
ftolargument toscipy.minimize(method="L-BFGS-B").max_iter (int) – The maximum number of iterations to perform. This parameter is forwarded as the
maxiterargument toscipy.minimize(method="L-BFGS-B").
- plot_binding_histogram(kind, bins=10, **kwargs)¶
Plot histogram of bound events.
- Parameters
kind ({'binding', 'all'}) – Type of events to count. ‘binding’ counts only the first position of each track whereas ‘all’ counts positions of all time points in each track.
bins (int or sequence of scalars) – Definition of the histogram bins; passed to
np.histogram(). When an integer is supplied to thebinsargument, the full position range is used to calculate the bin edges (this is equivalent to usingnp.histogram(data, bins=n, range=(0, max_position))). If a sequence of scalars is provided, they directly define the edges of the bins.**kwargs – Keyword arguments forwarded to
plt.bar().
- remove_lines_in_rect(rect)¶
Deprecated since version 0.13.0: This method will be removed in a future release. Use
remove_tracks_in_rect()instead.
- remove_tracks_in_rect(rect)¶
Removes tracks that fall in a particular region. Note that if any point on a track falls inside the selected region it will be removed.
- Parameters
rect (array_like) – Array of 2D coordinates in time and space units (not pixels)
- save(filename, delimiter=';', sampling_width=None)¶
Export kymograph tracks to a csv file.
- Parameters
filename (str) – Filename to output kymograph tracks to.
delimiter (str) – Which delimiter to use in the csv file.
sampling_width (int or None) – When supplied, this will sample the source image around the kymograph track and export the summed intensity with the image. The value indicates the number of pixels in either direction to sum over.