Histograms of state duration - vanTeeffelenLab/ExTrack GitHub Wiki

The following functions allow the user to compute histograms of probabilistic state duration for each state. This notably allows to highlight deviations from Markov transitions models. Indeed if the model is correct and transition are Markovian, we expect to see exponential decay of the state duration.

Function extrack.histograms.len_hist

hist = extrack.histograms.len_hist(all_tracks,
                                   params, 
                                   dt, 
                                   cell_dims=[0.5,None,None], 
                                   nb_states=2, 
                                   max_nb_states = 500,
                                   workers = 1,
                                   nb_substeps=1,
                                   input_LocErr = None
                                   )

Arguments:

  • all_tracks: dictionary describing the tracks with track length as keys (number of time positions, e.g. '23') of 3D arrays: dim 0 = track, dim 1 = time position, dim 2 = x, y position. This means 15 tracks of 7 time points in 2D will correspond to an array of shape [15,7,2].
  • params: lmfit parameters used for the model. can be extracted from the model using model_fit.params.
  • dt: time in between frames.
  • cell_dims: dimension limits (um).
  • nb_states: number of states of the model.
  • workers: number of workers for multi-threading (only use with linux, not working properly with Mac or Windows).
  • max_nb_states: maximum number of sequences kept (most likely sequences).
  • nb_steps_lim: upper limit of the plot in the x axis (number of steps).
  • long_tracks: if True only selects tracks longer than nb_steps_lim.
  • steps: x axis in seconds if False or in number of steps if False.

Outputs:

  • hists: 2D array of state probabilistic occurence. (dim 0: state duration from 1 to max_nb_states, dim 1: state).

A similar function allows to plot histograms in addition to output the state duration histograms hists:

Function extrack.visualization.visualize_states_durations

hists = extrack.visualization.visualize_states_durations(all_tracks,
                                                         params,
                                                         dt,
                                                         cell_dims = [1],
                                                         nb_states = 2,
                                                         max_nb_states = 200,
                                                         workers = 1,
                                                         long_tracks = True,
                                                         nb_steps_lim = 20,
                                                         steps = False)

Arguments:

  • all_tracks: dictionary describing the tracks with track length as keys (number of time positions, e.g. '23') of 3D arrays: dim 0 = track, dim 1 = time position, dim 2 = x, y position. This means 15 tracks of 7 time points in 2D will correspond to an array of shape [15,7,2].
  • params: lmfit parameters used for the model. can be extracted from the model using model_fit.params.
  • dt: time in between frames.
  • cell_dims: dimension limits (um).
  • nb_states: number of states of the model.
  • workers: number of workers for multi-threading (only use with linux, not working properly with Mac or Windows).
  • max_nb_states: maximum number of sequences kept (most likely sequences).
  • nb_steps_lim: upper limit of the plot in the x axis (number of steps).
  • long_tracks: if True only selects tracks longer than nb_steps_lim.
  • steps: x axis in seconds if False or in number of steps if False.

Outputs:

  • hists: 2D array of state probabilistic occurence. (dim 0: state duration from 1 to max_nb_states, dim 1: state).
  • plot of all tracks (preferencially input a single movie).