minisim#

Physically-driven synthetic 1-photon miniscope data

A forward-model generator and teaching tool, the inverse of an analysis pipeline like minian.


minisim builds a miniscope recording forward from its physical components, the inverse of an analysis pipeline. Instead of recovering signals from a movie, it starts from biology and optics and produces the movie, together with the exact ground truth that generated it: cell locations, footprints, calcium traces, spike times, motion trajectory, and per-pixel optical fields.

from minisim import (
    Acquisition, Optics, ImageSensor,
    PlaceNeurons, CellActivity, CellOptics, Composite, Sensor,
    Spec, simulate,
)

spec = Spec(
    acquisition=Acquisition(
        fps=20.0, duration_s=10.0,
        optics=Optics(magnification=8.0, na=0.45),
        image_sensor=ImageSensor(n_px_height=256, n_px_width=256, pixel_pitch_um=8.0),
    ),
    seed=0,
    steps=[PlaceNeurons(), CellActivity(), CellOptics(), Composite(), Sensor()],
)

rec = simulate(spec)         # -> Recording, with rec.ground_truth attached
movie = rec.observed         # the simulated movie: (frame, height, width) array

Because every recording ships with its ground truth, minisim is built for:

Benchmarking

Score calcium-imaging pipelines (minian, CaImAn, suite2p) against known truth with the recovery metrics.

Teaching

Walk the anatomy of miniscope data: what each physical effect does to the image. See the tutorials.

Testing

Reproducible, parameterized fixtures for analysis code, with a typed Spec and disk caching.

Install#

pip install minisim                # engine only
pip install "minisim[notebook]"    # + the interactive teaching notebooks

Requires Python >= 3.10. Core dependencies are numpy, scipy, xarray, zarr, pydantic, and numpydantic.

The teaching notebooks ship inside the package; copy them out with minisim-notebooks ./minisim-notebooks (see the tutorials).

Where to go next#

  • New here? Start with the Concepts page for the mental model, then the Quickstart.

  • Want to run something specific? The how-to guides cover benchmarking, parameter sweeps, and video export.

  • Looking for a class or function? The API reference is generated from the package.