slitflow.trj.random module

class Walk2DCenter(info_path=None)[source]

Bases: Table

Create X,Y-coordinate of two-dimensional random walk.

Trajectories are assumed starting from (0,0).

Parameters:
  • reqs[0] (Index) – Index Table class.

  • param["length_unit"] (str) – String of length unit such as “um”, “nm”, “pix”. This string is used as column name footers and units.

  • param["diff_coeff"] (float) – Diffusion coefficient in length_unit^2/s.

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

  • param["n_step"] (int) – Step number of trajectory. e.g. n_step=3 contains four points.

  • param["seed"] (int, optional) – Random seed.

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

Returns:

Expanded Table including frame number and coordinates

Return type:

Table

Examples

Add three-step trajectories to the Index table.

D1 = sf.tbl.create.Index()
D1.run([],{"type":"trajectory", "index_counts":[2,3], "split_depth":0})

D2 = sf.trj.random.Walk2DCenter()
D2.run([D1],{"length_unit": "um", "diff_coeff": 0.1, "interval": 0.1,
            "n_step":3, "seed": 1,  "split_depth":0})
print(D2.data[0])
#     img_no  trj_no  frm_no      x_um      y_um
# 0        1       1       1  0.000000  0.000000
# 1        1       1       2  0.229717 -0.151741
# 2        1       1       3  0.143202 -0.029354
# 3        1       1       4  0.068507 -0.354840
# 4        1       2       1  0.000000  0.000000
# 5        1       2       2  0.246754 -0.035266
# ...
# 22       2       3       3 -0.153925 -0.214459
# 23       2       3       4 -0.251106 -0.216250
set_info(param)[source]

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

static process(reqs, param)[source]

X,Y-coordinate of two-dimensional random walk.

Random seed should be set before running this function.

Parameters:
  • reqs[0] (pandas.DataFrame) – Index DataFrame.

  • param["diff_coeff"] (float) – Diffusion coefficient.

  • param["interval"] (int) – Time interval.

  • param["n_step"] (int) – Step number of trajectory.

  • param["calc_cols"] (list of str) – Column name of each coordinate.

Returns:

Expanded table including frame number and coordinates

Return type:

pandas.DataFrame

class WalkRect(info_path=None)[source]

Bases: Table

Random walk with a rectangle barrier.

Trajectories are assumed starting from the random position.

Parameters:
  • reqs[0] (Index) – Index Table class.

  • param["dimension"] (int) – Position dimension. 1=x, 2=xy, 3 = xyz.

  • param["length_unit"] (str) – String of length unit such as “um”, “nm”, “pix”. This string is used as column name footers and units.

  • param["diff_coeff"] (float) – Diffusion coefficient in length_unit^2/s.

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

  • param["n_step"] (int) – Step number of trajectory. n_step=3 contains four points.

  • param["lims"] (list of list of float) – List of [lower, upper] localization limits for each dimension.

  • param["seed"] (int, optional) – Random seed.

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

Returns:

Expanded Table including frame number and coordinates

Return type:

Table

Examples

Add three-step trajectories into the Index table.

D1 = sf.tbl.create.Index()
D1.run([],{"type":"trajectory", "index_counts":[2,3], "split_depth":0})

D2 = sf.trj.random.WalkRect()
D2.run([D1],{"dimension":2, "length_unit": "um", "diff_coeff": 0.1,
            "interval": 0.1, "n_step":3, "lims": [[0, 1], [0, 1]],
            "seed": 1,  "split_depth":0})
print(D2.data[0])
#     img_no  trj_no  frm_no      x_um      y_um
# 0        1       1       1  0.396767  0.685220
# 1        1       1       2  0.626485  0.533479
# 2        1       1       3  0.539969  0.199234
# 3        1       1       4  0.465274  0.359796
# 4        1       2       1  0.140387  0.968262
# 5        1       2       2  0.185506  0.676914
# ...
# 21       2       3       2  0.929132  0.410367
# 22       2       3       3  0.824191  0.328230
# 23       2       3       4  0.797061  0.312567
set_info(param)[source]

Convert input information to Info object.

This method creates columns and parameters information. The columns information is used to handle data structure. The parameter dictionaries are set as param of process(). This method is called before run(). Implemented in subclass.

Parameters:

param (dict, optional) – Parameters for columns or params.

static process(reqs, param)[source]

Add random walk coordinates to index DataFrame.

Random seed should be set before run this function.

Parameters:
  • reqs[0] (pandas.DataFrame) – Index DataFrame.

  • param["diff_coeff"] (float) – Diffusion coefficient.

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

  • param["n_step"] (int) – Step number of trajectory.

  • param["calc_cols"] (list of str) – Column name of each coordinate.

  • param["lims"] (list of list of float) – List of [lower, upper] localization limits for each dimension.

Returns:

Expanded table including frame number and coordinates

Return type:

pandas.DataFrame

reflect_in_rect(x0, dxs, lims)[source]

Reflect displacements if next position is outside the limits.

Parameters:
  • x0 (float) – One-dimensional coordinate of particle start position.

  • dxs (list of float) – List of one-dimensional displacements.

  • lims (list of float) – [lower, upper] of border positions to reflect.

Returns:

List of one-dimensional positions to which the reflection is applied

Return type:

numpy.ndarray

class WalkCircle(info_path=None)[source]

Bases: Table

Random walk with a circular barrier.

Trajectories are assumed starting from the random position.

Parameters:
  • reqs[0] (Index) – Index Table class.

  • param["dimension"] (int) – Position dimension. 1=x, 2=xy, 3 = xyz.

  • param["length_unit"] (str) – String of length unit such as “um”, “nm”, “pix”. This string is used as column name footers and units.

  • param["diff_coeff"] (float) – Diffusion coefficient in length_unit^2/s.

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

  • param["n_step"] (int) – Step number of trajectory. n_step=3 contains four points.

  • param["radius"] (float) – Radius of circular diffusion barrier.

  • param["offset"] (list of float, optional) – [x, y, (z)] position of the circle center. Defaults to [0, 0].

  • param["seed"] (int, optional) – Random seed.

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

Returns:

Expanded Table including frame number and coordinates

Return type:

Table

set_info(param)[source]

Convert input information to Info object.

This method creates columns and parameters information. The columns information is used to handle data structure. The parameter dictionaries are set as param of process(). This method is called before run(). Implemented in subclass.

Parameters:

param (dict, optional) – Parameters for columns or params.

static process(reqs, param)[source]

Add random walk coordinates to index DataFrame.

Random seed should be set before running this function.

Parameters:
  • reqs[0] (pandas.DataFrame) – Index DataFrame.

  • param["diff_coeff"] (float) – Diffusion coefficient.

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

  • param["n_step"] (int) – Step number of trajectory.

  • param["calc_cols"] (list of str) – Column name of each coordinate.

  • param["radius"] (float) – Radius of circular diffusion barrier.

  • param["offset"] (list of float, optional) – [x, y, (z)] position of the circle center.

Returns:

Expanded table including frame number and coordinates

Return type:

pandas.DataFrame