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

BaseFLIImageGenerator(irf_data[, ...])

Shared __init__/generate_image logic for FLIImageGenerator/ FLIModelImageGenerator.

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: object

Shared __init__/generate_image logic for FLIImageGenerator/ FLIModelImageGenerator.

Subclasses set the following class attributes:

continuous_clstype

Simulator class used for ROIs whose effective sensor_type is "continuous" (MacroSimulator / ContinuousSimulator).

discrete_clstype

Simulator class used for ROIs whose effective sensor_type is 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 no roi_mask was supplied, since in that case ROI 0 is not “background” — it’s the only region there is.

Parameters:
continuous_cls: type#
discrete_cls: type#
include_background_roi_in_maps: bool = True#
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 when irf_data is 3-D), runs it, and accumulates the results (scaled by the intensity mask) into pre-allocated decay/fit/IRF cubes and parameter maps. If bool_mask was 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:

dict

Raises:

ValueError – If bool_mask was provided but its shape does not match the image shape (H, W).