Simulation Library¶
-
class
trait2d.simulators.
BrownianDiffusion
(**kwargs)¶ BrownianDiffusion Initialization
Parameters: - Tmax (float) – Maximum simulation time (s)
- dt (float) – Simulation time resolution (s)
- L (float) – Simulation domain size (m)
- dL (float) – Simulation spatial resolution (m)
- d (float) – Diffusion coefficient (m^2/s)
- seed (int) – Seed to initialize the random generator (for reproducibility)
- quantize (bool) – Quantize the position to the simulation spatial resolution grid.
-
run
()¶ Run a random walk simulation (Brownian diffusion)
-
class
trait2d.simulators.
Diffusion
(Tmax=1.0, dt=0.001, L=1, dL=0.001, d=0.01, seed: int = None, quantize=True)¶ Abstract diffusion simulator
The methods to modify after inherition are: self.run, and te self.params_list, and assign the input variables
-
load_parameters
(filename)¶ Load the simulation parameters
-
plot_trajectory
(time_resolution=None, limit_fov=False, alpha=0.8, title='Diffusion')¶ Display the simulated trajectory.
Parameters: time_resolution (param) – [s]
-
print_parameters
()¶ Print the simulation parameters, accessible from self._gather_parameters()
-
save_parameters
(filename, mkdir=True)¶ Save the simulation parameters, accessible through _gather_parameter
-
save_trajectory
(filename, format=None)¶ Save the simulated trajectory as either a json, cvs or pcl file with fields t, x, and y
-
-
class
trait2d.simulators.
HoppingDiffusion
(Tmax=100, dt=5e-05, L=1e-05, dL=2e-08, Df=8e-13, HL=4e-08, HP=0.01, seed: int = None, quantize=True)¶ Simulates a hopping diffusion trajectory of a single molecule for a hopping diffusion model (i.e. free diffusion inside of compartments but changing from one compartment to the next only with a certain probability)
Syntax:
simulator = hopping_trajectories(Tmax, dt, L, Df, HL, HP, seed) simulator.run()
Authors:
Jan Keller-Findeisen (jkeller1@gwdg.de)Department of NanoBiophotonicsMax Planck Institute of Biophysical ChemistryAm Fassberg 11, 3077 Goettingen, GermanyConverted to Python by Joel Lefebvre
Parameters: - Tmax (float) – Maximal total length [s]
- dt (float) – Time step [s]
- L (float) – Sandbox length [m]
- dL (float) – Compartment map pixel size [m]
- Df (float) – Free diffusion coefficient [m^2/s]
- HL (float) – Average compartment diameter/length [m]
- HP (float) – Hopping probability [0-1]
- seed (float) – Random generator seed (nonnegative integer)
- quantize (bool) – Quantize the position to the simulation spatial resolution grid.
-
class
trait2d.simulators.
movie_simulator
(tracks=None, resolution=1.0, dt=1, contrast=5, background=0.3, noise_gaussian=0.15, noise_poisson=True, ratio='square')¶ Generate a syntetic iscat movie from a set of tracks.
Syntax:
movie_simulator = iscat_movie(tracks) movie_simulator.run()
Authors:
Joël Lefebvre (lefebvre.joel@uqam.ca)Department of Computer SciencesUniversité du Québec a Montréal (UQAM)201, Av. du Président-Kennedy, Montréal (Qc), Canada (H3C 3P8)Parameters: - tracks (dict or CSV filename) – A dictionary or a CSV filename containing the set of tracks to simulate. The dictionary must include the keys x, y, t and id
- resolution (float) – Spatial resolution [m/px]
- dt (float) – Temporal resolution [frame/sec]
- contrast (float) – Contrast between the simulated particle and the background (Contrast = particle intensity - background intensity)
- background (float) – Background intensity between 0 and 1
- noise_gaussian (float) – Gaussian noise variance
- noise_poisson (bool) – If True, Poisson noise will be added.
- ratio (str) – Aspect ratio of the simulated movie. Available (“square”). If none is given, the aspect ratio will be inferred from the tracks position.
-
get_estimated_size
()¶ Return the estimated movie size in MB
-
initialize
()¶ Initialize the simulator
-
load_psf
(filename)¶ Load a Point-Spread Function (PSF) from a file
Parameters: filename (str) – Input volume filename. Must be a volume format supported by imageio.volwrite Note
Only the middle slice along the first dimension will be used
-
load_tracks
(filename, field_x='x', field_y='y', field_t='t', field_id='id', file_format=None)¶ Load the tracks from a csv file.
Parameters: - filename (str) – Path to a csv filename
- field_x (str) – Column name in the CSV corresponding to the tracks X positions.
- field_y (str) – Column name in the CSV corresponding to the tracks Y positions.
- field_t (str) – Column name in the CSV corresponding to the tracks time.
- field_id (str) – Column name in the CSV corresponding to the tracks ID.
- file_format (str) – Specify the file format (available are cvs, json, pcl). If none is given, it will be inferred from the filename
-
run
(reinitialize=False)¶ Run the movie simulation
Parameters: reinitialize (bool) – If True, the simulator will be reinitialized.
-
save
(filename)¶ Save the simulated movie.
Parameters: filename (str) – Output volume filename. Must be a volume format supported by imageio.volwrite Note
The volume will be converted to single precision float (numpy.float32)