gridlib.tl_simulation
- gridlib.tl_simulation(k: ndarray, s: ndarray, kb: float, t_int: float, t_tl_all: Sequence[Union[float, str]], N: Union[int, Sequence[int]] = 10000) Dict[str, Dict[str, ndarray]][source]
Function simulates the fluorescence survival time distributions of a molecule for different time-lapse conditions. Dissociation and photobleaching of molecules with user-defined parameters is simulated and the resulting fluorescence survival time distribution is calculated. This is done for all the different user-specified time-lapse conditions.
- Parameters
k (np.ndarray) – Decay rates with units per second.
s (np.ndarray) – Amplitudes for the respective decay rates.
kb (float) – Photobleaching rate per second (kb = a / t_int).
t_int (float) – The integration time in seconds.
t_tl_all (Sequence[float | str]) – The time-lapse times to simulate. If the time-lapse times are provided as floats then they are interpreted as seconds. However, the time-lapse times can also be provided as strings, eg. ‘100ms’ or ‘1.5s’.
N (int | Sequence[int], optional) – Number of molecules to simulate and use for the survival time distribution calculation (default 10000). If only an integer value is provided then this value will be used for all the simulations. In the case that the provided N object is an iterable, each element is used as value for each time-lapse condition.
- Returns
A dictionary mapping keys (time-lapse conditions) to the corresponding time and value arrays of the survival functions. For example:
{ "0.05s": { "time": array([0.05, 0.1, 0.15, ...]), "value": array([1.000e+04, 8.464e+03, 7.396e+03, ...]), }, "1s": { "time": array([1., 2., 3., ...]), "value": array([1.000e+04, 6.925e+03, 5.541e+03, ...]), }, }
- Return type
Dict[str, Dict[str, np.ndarray]]
- Raises
ValueError – If N is a list and does not have the same length as t_tl_all list.
Examples
>>> data_sim = tl_simulation(np.array([0.005, 0.48, 5.2]), ... np.array([0.05, 0.25, 0.7]), 0.03, 0.05, [0.05, 0.2, 1.0, 5.0], N=10000)
The above function call simulates fluorescence survival time distributions of a type of molecule with three different dissociation rates, and a photobleaching rate of 0.03 s^-1. The integration time is set to 50 ms and the time-lapse times are set to 50 ms, 200 ms, 1 s and 5 s. For each survival time distribution, 10000 observed molecules are simulated.
>>> data_sim = tl_simulation(np.array([0.005, 0.48, 5.2]), ... np.array([0.05, 0.25, 0.7]), 0.03, 0.05, [0.05, 0.2, 1.0, 5.0], ... N=[10000, 5000, 2500, 1500])
Same as the first example, but now there is a different number of molecules simulated for every time-lapse condition. )