pyfli.simulator.image_generator_common#
Shared per-ROI mask loading, simulator selection, and pixel-loop logic for the full-image FLI dataset generators.
combined/sim_image_generator.py (FLIImageGenerator,
wrapping MacroSimulator/
TCSPCSimulator) and
separate/sim_model_image_generator.py (FLIModelImageGenerator,
wrapping ContinuousSimulator/
PhotonCountSimulator) implement
identical mask-loading, per-ROI simulator dispatch, and pixel-loop logic; they differ
only in which pair of simulator classes they dispatch between, and in whether
parameter maps are recorded for the background ROI (0). Subclasses declare those
differences as class attributes; this module owns the actual logic so it is defined
exactly once.
Classes
|
Shared |
- class BaseFLIImageGenerator(irf_data, intensity_image=None, roi_mask=None, roi_params=None, image_shape=(32, 32), method='continuous', verbose=True, bool_mask=None)[source]#
Bases:
objectShared
__init__/generate_imagelogic for FLIImageGenerator/ FLIModelImageGenerator.Subclasses set the following class attributes:
- continuous_clstype
Simulator class used for ROIs whose effective
sensor_typeis"continuous"(MacroSimulator/ContinuousSimulator).- discrete_clstype
Simulator class used for ROIs whose effective
sensor_typeis anything else (TCSPCSimulator/PhotonCountSimulator).- include_background_roi_in_mapsbool
Whether parameter maps are recorded for pixels in the background ROI (ROI value 0), in addition to any labeled ROI. Ignored (treated as
True) whenever noroi_maskwas supplied, since in that case ROI 0 is not “background” — it’s the only region there is.
- Parameters:
- generate_image()[source]#
Simulates every pixel and assembles the full FLI dataset.
Iterates over all
(i, j)pixels, selects the simulator assigned to that pixel’s ROI (swapping in a per-pixel normalized IRF slice whenirf_datais 3-D), runs it, and accumulates the results (scaled by the intensity mask) into pre-allocated decay/fit/IRF cubes and parameter maps. Ifbool_maskwas provided, it is applied as a final multiplicative mask.- Returns:
{"raw_data": {"decay": <H,W,T>, "irf": <H,W,T>}, "results": {"maps": {<param_name>: <H,W> ...}, "TR_maps": {"fit_map": <H,W,T>, "residual_map": decay_cube - fit_cube}}}.- Return type:
- Raises:
ValueError – If
bool_maskwas provided but its shape does not match the image shape(H, W).