Open
Description
I want to use PyBroMo to simulate timestamps generated from a single-molecule experiment.
tl;dr: it would be great to add an option to PyBroMo.simulate_diffusion
to save only the timestamps.
My plan is to run a series of simulations to understand which experimental parameters I need to tweak to be able to achieve a good SNR.
To save disk space, instead of following the example of PyBroMo - B.1 Disk-single-core - Generate photon timestamps.ipynb
I'm generating intensity traces and then calculating timestamps from sratch using the following code:
S = pbm.ParticlesSimulation(t_step=t_step, t_max=t_max,
particles=P, box=box, psf=psf)
S.simulate_diffusion(total_emission=True, save_pos=False, verbose=True,
rs=rs, chunksize=2**19, chunkslice='times')
trace = S.emission_tot[:] # Intensity trace
S.store.close()
photons = np.random.poisson(trace)
photons += np.random.poisson(np.ones_like(photons)*bkg*t_step) # Add uncorrelated background
timestamps = []
for (n, t) in zip(photons, np.cumsum(np.ones_like(photons)*t_step) - t_step):
if n > 0:
for i in range(n):
# If more than one photon fall into the same simulation step,
# distribute them evenly
timestamps.append(t + t_step/n * i)
ts = np.array(timestamps)
Working with the intensity trace is rather memory-consuming, so it would be great if the timestamps could be generated directly by the simulation function.
Metadata
Metadata
Assignees
Labels
No labels