SMS_BP
Single Molecule Simulations -BP
Loading...
Searching...
No Matches
SMS_BP.simulate_foci Namespace Reference

Classes

class  Track_generator
 

Functions

 get_lengths (str track_distribution, int track_length_mean, int total_tracks)
 
dict create_condensate_dict (np.ndarray initial_centers, np.ndarray initial_scale, np.ndarray diffusion_coefficient, np.ndarray hurst_exponent, np.ndarray cell_space, float cell_axial_range, **kwargs)
 
 tophat_function_2d (var, center, radius, bias_subspace, space_prob, **kwargs)
 
 generate_points (pdf, total_points, min_x, max_x, center, radius, bias_subspace_x, space_prob, density_dif)
 
 generate_points_from_cls (pdf, total_points, min_x, max_x, min_y, max_y, min_z, max_z, density_dif)
 
 generate_radial_points (total_points, center, radius)
 
 generate_sphere_points (total_points, center, radius)
 
 radius_spherical_cap (R, center, z_slice)
 
 get_gaussian (mu, sigma, domain=[list(range(10)), list(range(10))])
 
float|np.ndarray axial_intensity_factor (float|np.ndarray abs_axial_pos, float detection_range, **kwargs)
 
np.ndarray generate_map_from_points (np.ndarray points, float|np.ndarray point_intensity, np.ndarray|None map, bool movie, float base_noise, float psf_sigma)
 

Detailed Description

Documentation for the simulate_foci.py file.
This file contains the class for simulating foci in space.

Author: Baljyot Singh Parmar

Function Documentation

◆ axial_intensity_factor()

float | np.ndarray SMS_BP.simulate_foci.axial_intensity_factor ( float | np.ndarray abs_axial_pos,
float detection_range,
** kwargs )
Docstring
Calculate the factor for the axial intensity of the PSF given the absolute axial position from the 0 position of
the focal plane. This is the factor that is multiplied by the intensity of the PSF

For now this is a negative exponential decay i.e:
    I = I_0*e^(-|z-z_0|)
This function returns the factor e^(-|z-z_0|**2 / (2*2.2**2)) only.

Parameters:
-----------
abs_axial_pos : float|np.ndarray
    absolute axial position from the 0 position of the focal plane
detection_range : float
    detection range of the function. This is the standard deviation of the gaussian function describing the axial intensity decay assuming a gaussian function.
kwargs : dict

Returns:
--------
float|np.ndarray
    factor for the axial intensity of the PSF

◆ create_condensate_dict()

dict SMS_BP.simulate_foci.create_condensate_dict ( np.ndarray initial_centers,
np.ndarray initial_scale,
np.ndarray diffusion_coefficient,
np.ndarray hurst_exponent,
np.ndarray cell_space,
float cell_axial_range,
** kwargs )
Docstring for create_condensate_dict:

Parameters:
-----------
inital_centers: numpy array of shape (num_condensates,2) with the initial centers of the condensates
initial_scale: numpy array of shape (num_condensates,2) with the initial scales of the condensates
diffusion_coefficient: numpy array of shape (num_condensates,2) with the diffusion coefficients of the condensates
hurst_exponent: numpy array of shape (num_condensates,2) with the hurst exponents of the condensates
cell_space: numpy array of shape (2,2) with the cell space
cell_axial_range: float
**kwargs: additional arguments to be passed to the condensate_movement.Condensate class

◆ generate_map_from_points()

np.ndarray SMS_BP.simulate_foci.generate_map_from_points ( np.ndarray points,
float | np.ndarray point_intensity,
np.ndarray | None map,
bool movie,
float base_noise,
float psf_sigma )
Docstring for generate_map_from_points:
---------------------------
Generates the space map from the points. 2D

Parameters:
-----------
points: array-like
    points numpy array of shape (total_points,2)
point_intensity: array-like
    intensity of the points, if None, then self.point_intensity is used.
map: array-like
    space map, if None, then a new space map is generated.
movie: bool
    if True, then don't add the gaussian+noise for each point. Rather add the gaussians and then to the whole add the noise.
base_noise: float
    base noise to add to the space map
psf_sigma: float
    sigma of the psf (pix units)


Returns:
--------
1. space map as a numpy array of shape (max_x,max_x)
2. points as a numpy array of shape (total_points,2)


Notes:
------
1. The space map is generated using get_gaussian function.
2. For movie: In the segmented experimental images you are adding the noise of each frame to the whole subframe,
    so for this (movie=False) add each gaussian point to the image with the noise per point.
    (movie=True) add the gaussians together and then add the noise to the final image.

◆ generate_points()

SMS_BP.simulate_foci.generate_points ( pdf,
total_points,
min_x,
max_x,
center,
radius,
bias_subspace_x,
space_prob,
density_dif )
genereates random array of (x,y) points given a distribution using accept/reject method

Parameters
----------
pdf : function
    function which defines the distribution to sample from
total_points : int
    total points to sample
min_x : float
    lower bound to the support of the distribution
max_x : float
    upper bound to the support of the distribution
center : array-like of float
    coordinates of the center of the top hat
redius : float
    raidus of the top hat
bias_subspace : float
    probability at the top hat
space_prob : float
    probaility everywhere not at the top hat

Returns
-------
array-like
    [x,y] coordinates of the points sampled from the distribution defined in pdf

◆ generate_points_from_cls()

SMS_BP.simulate_foci.generate_points_from_cls ( pdf,
total_points,
min_x,
max_x,
min_y,
max_y,
min_z,
max_z,
density_dif )

◆ generate_radial_points()

SMS_BP.simulate_foci.generate_radial_points ( total_points,
center,
radius )
Genereate uniformly distributed points in a circle of radius.

Parameters
----------
total_points : int
    total points from this distribution
center : array-like or tuple
    coordinate of the center of the radius. [x,y,...]
radius : float-like
    radius of the region on which to

Returns
-------
(n,2) size array
    array of coordinates of points genereated (N,3) N = # of points, 2 = dimentions

◆ generate_sphere_points()

SMS_BP.simulate_foci.generate_sphere_points ( total_points,
center,
radius )
Genereate uniformly distributed points in a sphere of radius.

Parameters
----------
total_points : int
    total points from this distribution
center : array-like or tuple
    coordinate of the center of the radius. [x,y,...]
radius : float-like
    radius of the region on which to

Returns
-------
(n,2) size array
    array of coordinates of points genereated (N,3) N = # of points, 2 = dimentions

◆ get_gaussian()

SMS_BP.simulate_foci.get_gaussian ( mu,
sigma,
domain = [list(range(10)), list(range(10))] )
Parameters
----------
mu : array-like or float of floats
    center position of gaussian (x,y) or collection of (x,y)
sigma : float or array-like of floats of shape mu
    sigma of the gaussian
domain : array-like, Defaults to 0->9 for x,y
    x,y domain over which this gassuain is over


Returns
-------
array-like 2D
    values of the gaussian centered at mu with sigma across the (x,y) points defined in domain

Notes:
------
THIS IS IMPORTANT: MAKE SURE THE TYPES IN EACH PARAMETER ARE THE SAME!!!!

◆ get_lengths()

SMS_BP.simulate_foci.get_lengths ( str track_distribution,
int track_length_mean,
int total_tracks )
Returns the track lengths from the distribution track_distribution. The lengths are returned as the closest integer

Parameters:
-----------
track_distribution: distribution of track lengths. Options are "exponential" and "uniform"
track_length_mean: mean track length
total_tracks: total number of tracks to be generated

Returns:
--------
track lengths as a numpy array of shape (total_tracks,1)

Notes:
------
1. If the distribution is exponential, then the track lengths are generated using exponential distribution.
2. If the distribution is uniform, then the track lengths are generated using uniform distribution between 0 and 2*track_length_mean.
3. If the distribution is constant, then all the track lengths are set to the mean track length. (track_length_mean)

Exceptions:
-----------
ValueError: if the distribution is not recognized.

◆ radius_spherical_cap()

SMS_BP.simulate_foci.radius_spherical_cap ( R,
center,
z_slice )
 Find the radius of a spherical cap given the radius of the sphere and the z coordinate of the slice
Theory: https://en.wikipedia.org/wiki/Spherical_cap, https://mathworld.wolfram.com/SphericalCap.html

Parameters:
-----------
R : float,int
    radius of the sphere
center : array-like
    [x,y,z] coordinates of the center of the sphere
z_slice : float,int
    z coordinate of the slice relative to the center of the sphere, z_slice = 0 is the center of the sphere

Returns:
--------
float
    radius of the spherical cap at the z_slice

Notes:
------
1. This is a special case of the spherical cap equation where the center of the sphere is at the origin

◆ tophat_function_2d()

SMS_BP.simulate_foci.tophat_function_2d ( var,
center,
radius,
bias_subspace,
space_prob,
** kwargs )
Defines a circular top hat probability distribution with a single biased region defining the hat.
The rest of the space is uniformly distrubuted in 2D

Parameters
----------
var : array-like, float
    [x,y] defining sampling on the x,y span of this distribution
center : array-like, float
    [c1,c2] defining the center coordinates of the top hat region
radius : float
    defines the radius of the circular tophat from the center
bias_subspace : float
    probability at the top position of the top hat
space_prob : float 
    probability everywhere not in the bias_subspace

Returns
-------
float, can be array-like if var[0],var[1] is array-like
    returns the value of bias_subspace or space_prob depending on where the [x,y] data lies