2.4. Simulating Line Scans and MINFLUX#
2.4.1. Goal#
We want to create some artificial data of a line scan or MINFLUX measurement.
2.4.2. Getting started#
As usual, we start with the imports, notably execute_simulation
from src.scripts.SimulateData
, which is a script providing bundled access to simulation routines.
[1]:
import numpy as np
import lib.utilities as ut
from src.scripts.SimulateData import execute_simulation
2.4.3. Preparing the simulation#
We define the parameters of the simulation and create the parameter dictionaries that will be passed to the simulation module.
We simulate two fluorophore arrangements with different separations, indicated by d
(first for-loop). p0
is the anchor point of the system, now set to the origin- Combined with the orientation vector vec
, we calculate the positions p1
and p2
of the molecules. Next, we assemble the parameter dictionaries and kwarg dictionaries for the simulation and execute the simulation routine. The results are saved in the output directory specified in lib.config
.
[2]:
rng = np.random.default_rng()
names, param_dicts, kwarg_dicts = [], [], []
#name = ut.Labeler().id_generator() + '-LineScanSimulation'
name = ut.Labeler().id_generator() + '-MINFLUXSimulation'
for d in range(3,4,1):
kwargs = dict(folder=f'/{d}nm')
#params = {'type':'line-scan','block_size':1, 'iteration_depth':1,'repetitions':30}
params = {'type':'minflux','L':50.,'repetitions':20}
for j in range(1,3):
p0 = np.array([[0.,0.]])# * 2 * (rng.random((1,2))-0.5)# np.array([[-40.,0.]])
vec = (rng.random((2,))-0.5)##np.ones((2,))#
n = vec/np.linalg.norm(vec)
p1 = p0 - float(d)*n/2
p2 = p0 + float(d)*n/2
mol_pos = np.concatenate([p1,p2],axis=0)
params = params | dict(
beta=5E-1
,blinking=False
#,bleach_idx=np.array([10,20])
,bleach_idx=np.array([700,1400])#for minflux: keep in mind that we have some pre-localization steps, i.e. more scan units...
,photon_budget=[np.inf, np.inf]
,molecule_brightness=35
,mol_pos=mol_pos
)
param_dicts.append(params)
kwarg_dicts.append(kwargs)
names.append(name)
j+=1
[3]:
execute_simulation(names,param_dicts,kwarg_dicts)
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
using a parallel pool with 16 processes
[3]:
['/mnt/d/artefacts/2024/02/06/8U8IUO-MINFLUXSimulation']