Recording and ground truth#

Recording#

pydantic model minisim.Recording[source]#

Bases: BaseModel

A complete simulated recording: the spec, the observed movie, and the truth.

observed holds the integer-valued sensor counts in a float container (per Output.store_dtype). snapshots is populated only when Output.save_intermediates is set, keyed by each step’s stage name; stage() reads them.

Fields:
  • ground_truth (minisim.recording.GroundTruth)

  • observed (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* frame, * height, * width], (

  • snapshots (dict[str, xarray.core.dataarray.DataArray])

  • spec (minisim.spec.Spec)

field spec: Spec [Required]#
field observed: NDArray[Shape['* frame, * height, * width'], float] [Required]#
field ground_truth: GroundTruth [Required]#
field snapshots: dict[str, xr.DataArray] [Optional]#

GroundTruth#

pydantic model minisim.GroundTruth[source]#

Bases: BaseModel

The per-recording truth: structural targets + per-cell and per-effect fields.

The planted vs observed footprint split is load-bearing: A_observed is what CNMF can actually recover (tests match against it), while A_planted is the ideal, optics-free target that quantifies the irreducible limit. Both are exposed as dense (unit, height, width) arrays via properties, but neither is stored dense:

  • Footprints are stored sparse, as canvas-coordinate patches in planted (a FootprintStack); fov_offset / fov_shape crop them to the sensor FOV.

  • The observed footprint is not stored at all: it is the deterministic blur gain · (planted Gaussian(sigma_px)) of the planted one, so it is regenerated on demand from the per-unit observed_sigma_px / observed_gain scalars. Deep cells’ observed footprints are near-full-canvas, so storing them dominated memory and disk; regenerating is bit-identical and far cheaper to keep.

Per-effect fields are None when their step is absent from the recording.

Fields:
  • C (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit, * frame], (

  • S (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit, * frame], (

  • amplitude_per_cell (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit], (

  • bleaching (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit, * frame], (

  • centers_um (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit, 3], (

  • detectable (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit], numpy.bool])

  • focal_depth_um (float | None)

  • fov_offset (tuple[int, int])

  • fov_shape (tuple[int, int])

  • illumination (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* height, * width], (

  • in_focus (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit], numpy.bool])

  • leakage (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* height, * width], (

  • neuropil_population (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* frame], (

  • neuropil_spatial (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* component, * height, * width], (

  • neuropil_temporal (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* component, * frame], (

  • observed_gain (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit], (

  • observed_sigma_px (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit], (

  • planted (minisim.footprint.FootprintStack)

  • shifts (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* frame, 2], (

  • vasculature_mask (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* height, * width], (

  • vessel_overlap_fraction (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* unit], (

  • vignette (numpydantic.vendor.nptyping.base_meta_classes.NDArray[numpydantic.vendor.nptyping.base_meta_classes.Shape[* height, * width], (

field planted: FootprintStack [Required]#
field fov_offset: tuple[int, int] [Required]#
field fov_shape: tuple[int, int] [Required]#
field observed_sigma_px: NDArray[Shape['* unit'], float] | None = None#
field observed_gain: NDArray[Shape['* unit'], float] | None = None#
field C: NDArray[Shape['* unit, * frame'], float] [Required]#
field S: NDArray[Shape['* unit, * frame'], float] [Required]#
field centers_um: NDArray[Shape['* unit, 3'], float] [Required]#
field amplitude_per_cell: NDArray[Shape['* unit'], float] [Required]#
field in_focus: NDArray[Shape['* unit'], bool] [Required]#
field detectable: NDArray[Shape['* unit'], bool] [Required]#
field shifts: NDArray[Shape['* frame, 2'], float] | None = None#
field illumination: NDArray[Shape['* height, * width'], float] | None = None#
field vignette: NDArray[Shape['* height, * width'], float] | None = None#
field leakage: NDArray[Shape['* height, * width'], float] | None = None#
field bleaching: NDArray[Shape['* unit, * frame'], float] | None = None#
field neuropil_temporal: NDArray[Shape['* component, * frame'], float] | None = None#
field neuropil_spatial: NDArray[Shape['* component, * height, * width'], float] | None = None#
field neuropil_population: NDArray[Shape['* frame'], float] | None = None#
field vasculature_mask: NDArray[Shape['* height, * width'], float] | None = None#
field vessel_overlap_fraction: NDArray[Shape['* unit'], float] | None = None#
field focal_depth_um: float | None = None#

finalize#

minisim.finalize(scene, spec)[source]#

Distill an exhausted Scene into a frozen, typed Recording.

Keeps each cell’s canvas-coordinate planted footprint (sparse) plus its canvas-frame position rebased to the sensor FOV, drops cells left entirely in the motion margin, records the per-unit optics scalars (so A_observed can be regenerated rather than stored), assembles the per-cell structural truth, sets detectable from the realized optical × illumination peak versus the sensor noise floor (folding in vessel transmission, and recording each cell’s vessel-occlusion burden), reads the per-effect fields off scene.truth, and downcasts the working movie to Output.store_dtype for observed.

Parameters:
Return type:

Recording