Simulation of time traces¶
-
class
fret_tester.
TwoStateExpTruth
(lifetimes, efficiencies)[source]¶ Simulate ground truth smFRET time traces (two states, exp. lifetimes)
Lifetimes are exponentially distributed.
Parameters: - life_times (array_like, shape=(2,)) – Mean (of the exponentially distributed) life times of the states
- efficiencies (array_like, shape=(2,)) – FRET efficiencies for the states
-
generate
(duration)[source]¶ Create a time trace that of at least duration length
Parameters: duration (float) – Minimum duration of the time trace. In practice, it will be longer. Returns: - time (numpy.ndarray) – Time points of state changes. These are bi-exponentially distributed.
- eff (numpy.ndarray) – Corresponding FRET efficiencies. The i-th entry lasts from
time[i-1]
(or 0 for i=0) totime[i]
.
-
__call__
(*args, **kwargs)[source]¶ Synonym for
generate()
-
fret_tester.
sample
(time, eff, exposure_time, data_points=inf, frame_time=0.0)[source]¶ Sample the true smFRET time trace with finite exposure time
This means that there will be integration over all transitions that happen during a single exposure.
Parameters: - time (array_like, shape=(n,)) – Sequence of transition times as returned by
two_state_truth()
- eff (array_like, shape=(n,)) – Sequence of FRET efficiencies as returned by
two_state_truth()
- exposure_time (float) – Exposure time for sampling. All transition during a exposure will be integrated.
- data_points (scalar, optional) – Number of data points to return. If the FRET time trace is too short, the maximum number of data points the trace allows is returned. Defaults to infinity.
- frame_time (float, optional) – Total time for one frame, i.e. minimum time between two data points. If this is less than exposure_time, use exposure_time. Defaults to 0, i.e. use exposure_time.
Returns: - sample_time (numpy.ndarray) – Time points of sampling. They are evenly spaced with exposure_time difference.
- sample_eff (numpy.ndarray) – Corresponding sampled FRET efficiencies
- time (array_like, shape=(n,)) – Sequence of transition times as returned by
-
fret_tester.
experiment
(eff, photons, donor_brightness, acceptor_brightness)[source]¶ From sampled smFRET time traces, simulate (noisy) experiment results
This adds noise coming from the rather broad brightness distributions of fluorophores to the time traces, resulting in a trace as one would get out of an experiment.
The acceptor signal is generated by
acceptor_brightness(eff * photons)
, the donor signal is generated bydonor_brightness((1 - eff) * photons)
.Parameters: - eff (array_like) – Sampled FRET efficiencies
- photons (float) – Mean summed number of photons emitted by donor and acceptor per exposure.
- donor_brightness, acceptor_brightness (callable) – Takes one argument, an array of mean brightness values. For each entry m it returns a random value drawn from the brightness distribution with mean m.
Returns: donor_noisy, acceptor_noisy – Donor and acceptor fluorescence including noise
Return type: numpy.ndarray
-
class
fret_tester.
DataSet
¶ Named tuple containing a full data set of a simulation run
-
true_time, true_eff
array_like – True state trajectory as produced by
two_state_truth()
-
samp_time, samp_eff
array_like – Sampled state trajectory as produced by
sample()
-
exp_don, exp_acc
array_like – (Noisy) donor and acceptor intensities as produced by
experiment()
-
exp_eff
¶ array_like – Experiment FRET efficiency, i.e.
exp_acc / (exp_acc + exp_don)
Create new instance of DataSet(true_time, true_eff, samp_time, samp_eff, exp_don, exp_acc, exp_eff)
-
-
fret_tester.
simulate_dataset
(truth, exposure_time, data_points, photons, donor_brightness, acceptor_brightness, frame_time=0.0)[source]¶ Simulate a whole data set
Consecutively run
two_state_truth()
,sample()
, andexperiment()
.Parameters: - truth (callable or tuple of numpy.ndarray, shape=(n,)) – Ground truth smFRET time trace. If this is an array,
truth[0]
should be the sequence of time points where state transitions occur andtruth[1]
the FRET efficiency between the (i-1)-th time point (or 0 for i = 0) and the i-th time point. If this is callable, it should return a ground truth smFRET time trace as described above. It should take one float parameter, which is the minimum duration of the generated trace. - exposure_time (float) – Exposure time for sampling. All transition during a exposure will be integrated.
- data_points (scalar, optional) – Number of data points to return. If the FRET time trace is too short, the maximum number of data points the trace allows is returned. Defaults to infinity.
- photons (float) – Mean summed number of photons emitted by donor and acceptor per exposure.
- donor_brightness, acceptor_brightness (callable) – Takes one argument, an array of mean brightness values. For each entry m it returns a random value drawn from the brightness distribution.
- frame_time (float, optional) – Total time for one frame, i.e. minimum time between two data points. If this is less than exposure_time, use exposure_time. Defaults to 0, i.e. use exposure_time.
Returns: Collected simulated data
Return type: - truth (callable or tuple of numpy.ndarray, shape=(n,)) – Ground truth smFRET time trace. If this is an array,