slitflow.trj.msd module

class Each(info_path=None)[source]

Bases: Table

Mean Square Displacement of each trajectory.

Parameters:
  • reqs[0] (Table) – Table containing X,Y-coordinate of trajectories. Required params; length_unit, interval. Required column; trj_no, x_(length_unit), y_(length_unit).

  • param["group_depth"] (int) – Column depth number of trajectory number.

  • param["split_depth"] (int) – File split depth number.

Returns:

Mean square displacement with time interval

Return type:

Table

Examples

Calculate MSDs of each trajectory.

# D2 is from the trj.random.Walk2DCenter example
D3 = sf.trj.msd.Each()
D3.run([D2], {"group_depth": 2, "split_depth": 0})
print(D3.data[0])
      img_no  trj_no  interval       msd
# 0        1       1       0.0  0.000000
# 1        1       1       0.1  0.057107
# 2        1       1       0.2  0.032046
# 3        1       1       0.3  0.063900
# ...
# 33       2       3       0.3  0.146120
# 34       2       3       0.4  0.222287
# 35       2       3       0.5  0.310305
set_info(param={})[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Mean Square Displacement of each trajectory.

Parameters:
  • reqs[0] (pandas.DataFrame) – Table containing X,Y-coordinate of trajectories. Required column; trj_no, x_(length_unit), y_(length_unit).

  • param["index_cols"] (list of str) – Column names of index.

  • param["interval"] (float) – Time interval of trajectory.

Returns:

Mean square displacement with time interval

Return type:

pandas.DataFrame

calc_msd(df, param)[source]

This function is used in pandas.core.groupby.GroupBy.apply() of Each.

class FitAnom(info_path=None)[source]

Bases: Table

Fitting parameters fitted from MSD with 4Dt^a.

If fitting is failed, this class returns initial values; D=value calculated from initial slope, alpha=0.5.

Parameters:
  • reqs[0] (Table) – MSD Table. Required param; interval, length_unit. Required column; msd.

  • param["step"] (int) – Step number for fitting from interval=0.

  • param["log_d"] (bool, optional) – Whether to add log10 scale for D. Defaults to False.

  • param["group_depth"] (int) – Data split depth for fitting.

  • param["split_depth"] (int) – File split depth number.

Returns:

Table containing the list of fitting parameters.

Return type:

Table

set_info(param)[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Fitting parameters fitted from MSD with 4Dt^a.

If fitting is failed, this class returns initial values; D=value calculated from initial slope, alpha=0.5.

Parameters:
  • reqs[0] (pandas.DataFrame) – MSD table containing interval and msd columns.

  • param["step"] (int) – Step number for fitting from interval=0.

  • param["interval"] (float) – Time interval in second.

  • param["log_d"] (bool, optional) – Whether to add log10 scale for D.

  • param["index_cols"] (list of str) – Column names for index.

Returns:

List of fitting parameters

Return type:

pandas.DataFrame

fit_msd_anom(df, param)[source]
class ModelAnom(info_path=None)[source]

Bases: Table

Model curve of MSD with 4Dt^a.

Parameters:
  • reqs[0] (FitAnom) – Table containing fitting parameters of MSD with anomalous diffusion. Required columns; diff_coeff, alpha. Required params; length_unit,

  • param["x_lims"] (list of float) – Minimum and maximum position of x-axis.

  • param["step"] (float) – Step size of x-axis for the model curve.

  • param["group_depth"] (int) – Data split depth.

  • param["split_depth"] (int) – File split depth number.

Returns:

Model curve Table

Return type:

Table

set_info(param)[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Model curve of MSD with 4Dt^a.

Parameters:
  • reqs[0] (pandas.DataFrame) – Fitting parameters of MSD with anomalous diffusion. Required columns; diff_coeff, alpha.

  • param["x_lims"] (list of float) – Minimum and maximum position of x-axis.

  • param["step"] (float) – Step size of x-axis for the model curve.

  • param["index_cols"] (list of str) – Column names of index.

Returns:

Model curve table

Return type:

pandas.DataFrame

class FitSimple(info_path=None)[source]

Bases: Table

Diffusion coefficients from MSD fitted with a simple 4Dt.

Parameters:
  • reqs[0] (Table) – MSD Table. Required columns; interval, msd. Required params; length_unit,

  • param["step"] (int) – Step number for fitting from interval=0.

  • param["group_depth"] (int) – Data split depth for fitting.

  • param["split_depth"] (int) – File split depth number.

Returns:

Table containing the list of diffusion coefficient

Return type:

Table

set_info(param)[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Diffusion coefficients from MSD fitted with a simple 4Dt.

Parameters:
  • reqs[0] (pandas.DataFrame) – MSD table. Required columns; interval, msd.

  • param["step"] (int) – Step number for fitting from interval=0.

  • param["index_cols"] (list of str) – Column names of index.

Returns:

List of diffusion coefficient

Return type:

pandas.DataFrame

fit_msd_simple(df, param)[source]
msd_simple_diff(t, d)[source]

Model function for simple MSD fitting.

Parameters:
  • t (float) – Time interval value.

  • d (float) – Diffusion coefficient.

Returns:

Mean square displacement

Return type:

float

msd_anom_diff(t, d, a)[source]

Model function for MSD fitting with anomalous diffusion.

Parameters:
  • t (float) – Time interval value.

  • d (float) – Diffusion coefficient.

  • a (float) – Anomalous exponent. a should be > 0.

Returns:

Mean square displacement

Return type:

float

class ModelSimple(info_path=None)[source]

Bases: Table

Model curve of MSD with 4Dt.

Parameters:
  • reqs[0] (FitSimple) – Table containing fitting parameters. Required column; diff_coeff. Required params; length_unit.

  • param["x_lims"] (list of float) – Minimum and maximum position of x-axis.

  • param["step"] (float) – The step size of x-axis of the model curve.

  • param["group_depth"] (int) – Data split depth to calculate model.

  • param["split_depth"] (int) – File split depth number.

Returns:

Model curve Table

Return type:

Table

set_info(param)[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Model curve of MSD with 4Dt.

Parameters:
  • reqs[0] (pandas.DataFrame) – Table containing fitting parameters. Required column; diff_coeff.

  • param["x_lims"] (list of float) – Minimum and maximum position of x-axis.

  • param["step"] (float) – The step size of x-axis of the model curve.

  • param["index_cols"] (list of str) – Column names of index.

Returns:

Model curve Table

Return type:

pandas.DataFrame

class DfromDeltaV(info_path=None)[source]

Bases: Table

Diffusion coefficients from differential velocity with simple 4Dt.

Parameters:
  • reqs[0] (Table) – Trajectory Table. Required columns; x_(length_unit), y_(length_unit). Required params; length_unit.

  • param["calc_cols"] (list of str) – Column names to calculate diffusion coefficients.

  • param["group_depth"] (int) – Data split depth.

  • param["split_depth"] (int) – File split depth number.

Returns:

Diffusion coefficient of each trajectory

Return type:

Table

set_info(param)[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Diffusion coefficients from differential velocity with simple 4Dt.

Parameters:
  • reqs[0] (pandas.DataFrame) – Trajectory Table. Required columns; x_(length_unit), y_(length_unit).

  • param["calc_cols"] (list of str) – Column names to calculate diffusion coefficients.

  • param["index_cols"] (list of str) – Column names of index.

Returns:

Diffusion coefficient of each trajectory

Return type:

pandas.DataFrame

calc_delta_v(df, param)[source]
class FitConfSaxton(info_path=None)[source]

Bases: Table

Fitting parameters fitted from MSD with Saxton confined model.

This model is approximation of Appendix B B14 equation in Saxton, M.J., 1993. Biophys. J. 64, 1766-1780. Only n=1 is used from the summation in the equation.

If fitting is failed, this class returns initial values; D=value calculated from initial slope, alpha=0.5.

Parameters:
  • reqs[0] (Table) – MSD Table. Required param; length_unit. Required columns; interval, msd.

  • param["step"] (int) – Step number for fitting from interval=0.

  • param["group_depth"] (int) – Data split depth.

  • param["split_depth"] (int) – File split depth number.

Returns:

Table containing the list of fitting parameters

Return type:

Table

set_info(param)[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Fitting parameters fitted from MSD with Saxton confined model.

If fitting is failed, this class returns initial values; D=value calculated from initial slope, r=final value of MSD.

Parameters:
  • reqs[0] (pandas.DataFrame) – MSD table. Required columns; interval, msd.

  • param["step"] (int) – Step number for fitting from interval=0.

  • param["interval"] (float) – Time interval in second.

  • param["index_cols"] (list of str) – Column names for index.

Returns:

List of fitting parameters

Return type:

pandas.DataFrame

fit_msd_confs(df, param)[source]
msd_confs_diff(t, d, r)[source]

Model function for MSD fitting with confined diffusion.

Parameters:
  • t (float) – Time interval value.

  • d (float) – Diffusion coefficient.

  • r (float) – Confinement radius.

Returns:

Mean square displacement

Return type:

float

class ModelConfSaxton(info_path=None)[source]

Bases: Table

Model curve of MSD with Saxton confined model.

Parameters:
  • reqs[0] (FitConfSaxton) – Table containing fitting parameters of MSD with confined diffusion. Required columns; diff_coeff, r. Required params; length_unit.

  • param["x_lims"] (list of float) – Minimum and maximum position of x-axis.

  • param["step"] (float) – Step size of x-axis for the model curve.

  • param["group_depth"] (int) – Data split depth.

  • param["split_depth"] (int) – File split depth number.

Returns:

Model curve Table

Return type:

Table

set_info(param)[source]

Copy info from req[0] and add columns and params.

static process(reqs, param)[source]

Model curve of MSD with Saxton confined model.

Parameters:
  • reqs[0] (pandas.DataFrame) – Fitting parameters of MSD with confined diffusion. Required columns; diff_coeff, r.

  • param["x_lims"] (list of float) – Minimum and maximum position of x-axis.

  • param["step"] (float) – Step size of x-axis for the model curve.

  • param["index_cols"] (list of str) – Column names of index.

Returns:

Model curve table

Return type:

pandas.DataFrame