{"action":"created","issue":{"url":"https://api.github.com/repos/tritemio/PyBroMo/issues/4","repository_url":"https://api.github.com/repos/tritemio/PyBroMo","labels_url":"https://api.github.com/repos/tritemio/PyBroMo/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/tritemio/PyBroMo/issues/4/comments","events_url":"https://api.github.com/repos/tritemio/PyBroMo/issues/4/events","html_url":"https://github.com/tritemio/PyBroMo/issues/4","id":176572226,"number":4,"title":"Improvement: simulation generates photon timestamps directly","user":{"login":"lampo808","id":5128757,"avatar_url":"https://avatars.githubusercontent.com/u/5128757?v=3","gravatar_id":"","url":"https://api.github.com/users/lampo808","html_url":"https://github.com/lampo808","followers_url":"https://api.github.com/users/lampo808/followers","following_url":"https://api.github.com/users/lampo808/following{/other_user}","gists_url":"https://api.github.com/users/lampo808/gists{/gist_id}","starred_url":"https://api.github.com/users/lampo808/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lampo808/subscriptions","organizations_url":"https://api.github.com/users/lampo808/orgs","repos_url":"https://api.github.com/users/lampo808/repos","events_url":"https://api.github.com/users/lampo808/events{/privacy}","received_events_url":"https://api.github.com/users/lampo808/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-13T07:42:28Z","updated_at":"2016-09-15T23:55:21Z","closed_at":null,"body":"I want to use PyBroMo to simulate timestamps generated from a single-molecule experiment.\r\n\r\n**tl;dr**: it would be great to add an option to `PyBroMo.simulate_diffusion` to save only the timestamps.\r\n\r\nMy 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.\r\nTo 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:\r\n\r\n```python\r\nS = pbm.ParticlesSimulation(t_step=t_step, t_max=t_max,\r\n                            particles=P, box=box, psf=psf)\r\n\r\nS.simulate_diffusion(total_emission=True, save_pos=False, verbose=True,\r\n                        rs=rs, chunksize=2**19, chunkslice='times')\r\n\r\ntrace = S.emission_tot[:]  # Intensity trace\r\nS.store.close()\r\n\r\nphotons = np.random.poisson(trace)\r\nphotons += np.random.poisson(np.ones_like(photons)*bkg*t_step)  # Add uncorrelated background\r\n\r\ntimestamps = []\r\nfor (n, t) in zip(photons, np.cumsum(np.ones_like(photons)*t_step) - t_step):\r\n    if n > 0:\r\n        for i in range(n):\r\n            # If more than one photon fall into the same simulation step,\r\n            #  distribute them evenly\r\n            timestamps.append(t + t_step/n * i)\r\n\r\nts = np.array(timestamps)\r\n```\r\n\r\nWorking with the intensity trace is rather memory-consuming, so it would be great if the timestamps could be generated directly by the simulation function."},"comment":{"url":"https://api.github.com/repos/tritemio/PyBroMo/issues/comments/247486606","html_url":"https://github.com/tritemio/PyBroMo/issues/4#issuecomment-247486606","issue_url":"https://api.github.com/repos/tritemio/PyBroMo/issues/4","id":247486606,"user":{"login":"tritemio","id":4156237,"avatar_url":"https://avatars.githubusercontent.com/u/4156237?v=3","gravatar_id":"","url":"https://api.github.com/users/tritemio","html_url":"https://github.com/tritemio","followers_url":"https://api.github.com/users/tritemio/followers","following_url":"https://api.github.com/users/tritemio/following{/other_user}","gists_url":"https://api.github.com/users/tritemio/gists{/gist_id}","starred_url":"https://api.github.com/users/tritemio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tritemio/subscriptions","organizations_url":"https://api.github.com/users/tritemio/orgs","repos_url":"https://api.github.com/users/tritemio/repos","events_url":"https://api.github.com/users/tritemio/events{/privacy}","received_events_url":"https://api.github.com/users/tritemio/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T23:55:21Z","updated_at":"2016-09-15T23:55:21Z","body":"@lampo808, if you look at the method ParticlesSimulation.simulate_timestamps_mix_da_online it does what you need for a mixture of multiple FRET populations. If you want to do only a single-color version you could simplify that method removing the duplication that is there to simulate both donor and acceptor channel, maybe call it ParticlesSimulation.simulate_timestamps_mix_online. If you send a PR to add this method I would be happy to merge it.\r\n\r\nLet me know if you need further help."}}
{"actor":{"display_login":"tritemio"}}