pyfli.simulator.sim_workflow#
Functions
|
Concatenate multiple sim.sample() output dicts along the batch axis (axis=0). |
|
Run simulate_fn num_samples times and stack each output key along a new leading axis. |
Classes
Run repeated FLI/FLIM simulations across parameter sets. |
|
|
Wraps IRF shifting + a MacroSimulator/ContinuousSimulator/TCSPCSimulator/ PhotonCountSimulator engine + SimOutputWithIRFOffset for a single config. |
|
|
|
|
|
Wraps one |
- concat_sim_data(*datasets)[source]#
Concatenate multiple sim.sample() output dicts along the batch axis (axis=0). Assumes all datasets share identical keys and per-sample shapes.
- class SimGenerator(irf_data, config, a_range=(-20, 100), b_range=(0, 10), pixel=(0, 0), family='separate', sensor_type='discrete')[source]#
Bases:
objectWraps IRF shifting + a MacroSimulator/ContinuousSimulator/TCSPCSimulator/ PhotonCountSimulator engine + SimOutputWithIRFOffset for a single config. Only accepts one config dict — raises if given a list/tuple of configs.
Engine selection has two independent axes:
sensor_type(physics):config["sensor_type"]if present, otherwise thesensor_typeconstructor argument."continuous"samples from an intensity/ADC-scaled engine;"discrete"samples from a photon-by-photon TCSPC engine.family(implementation):"separate"(default) usesContinuousSimulator/PhotonCountSimulator;"combined"usesMacroSimulator/TCSPCSimulator.
- Parameters:
- class WeightedConfigSimGenerator(irf_data, configs, probs, a_range=(-20, 20), b_range=(0, 10), pixel=(0, 0), family='separate', sensor_type='discrete', seed=None)[source]#
Bases:
objectWraps one
SimGeneratorper config combination and, on everysimulate_once()call, draws a fresh combination according toprobsbefore delegating to it.This lets a single simulator built from this class (e.g. via
bayesflow.make_simulator([lambda: gen.simulate_once()])) produce draws sampled from a mixture of configs — such as the(configs, probs)pair returned bycombination_table()— with no change needed to code downstream that only ever callssimulate_once().- Parameters:
irf_data (
np.ndarray) – Full IRF cube, forwarded to each per-combinationSimGenerator.configs (
Sequence[dict]) – One config dict per combination.probs (
Sequence[float]) – Sampling probability for each entry inconfigs(same order, same length). Renormalized if it doesn’t already sum to 1.a_range – Forwarded to every per-combination
SimGenerator.b_range – Forwarded to every per-combination
SimGenerator.pixel – Forwarded to every per-combination
SimGenerator.family – Forwarded to every per-combination
SimGenerator.sensor_type – Forwarded to every per-combination
SimGenerator.seed (
int | None) – Seed for the combination-selection RNG (independent of eachSimGenerator’s own internal randomness).
- make_simulator(simulate_fn, num_samples)[source]#
Run simulate_fn num_samples times and stack each output key along a new leading axis.
- class BatchSimulator[source]#
Bases:
objectRun repeated FLI/FLIM simulations across parameter sets. The class is a convenience layer for generating batches of synthetic datasets for validation or model training.
Unlike
make_simulator()/concat_sim_data()(which batch the flattened per-sample dict produced bySimOutput), these methods batch the raw nested{"raw_data": {...}, "results": {"maps": {...}, "TR_maps": {...}}}dict returned directly by a simulator’s__call__(e.g.MacroSimulator,ContinuousSimulator).- sim_BI(sim_funcs, num_list)[source]#
Generates a simplified batch dictionary with specific parameters. Returns data as a dictionary of NumPy arrays.
- generate_batch(sim_func_list, num_list)[source]#
Generate batch.
- Parameters:
sim_func_list (
np.ndarray) – Simulator functions used to generate a batch.num_list (
int) – Number of samples generated for each simulator function.
- Returns:
Object produced by generate batch.
- Return type:
Any
- generate_batch2D(sim_funcs, num_list, shape=(10, 10))[source]#
Generate batch2 d.
- Parameters:
sim_funcs (
np.ndarray) – Simulator functions used to generate a two-dimensional batch.num_list (
int) – Number of samples generated for each simulator function.shape (
tuple[int,]) – Output shape requested for generated simulation batches.
- Returns:
Object produced by generate batch2d.
- Return type:
Any