Skip to main content

Physically-driven synthetic 1-photon miniscope data: a forward-model generator and teaching tool, the inverse of the minian analysis pipeline.

Project description

Minisim

pytest codecov Documentation Status PyPI Python versions License Ruff

Physically-driven synthetic 1-photon miniscope data: a forward-model generator and teaching tool.

Minisim builds a miniscope recording forward from its physical components, the inverse of an analysis pipeline like minian. Instead of recovering signals from a movie, it starts from biology and optics and produces the movie, together with the ground truth that generated it:

place neurons -> cell activity -> bleaching -> optics -> composite -> neuropil
             -> brain motion -> illumination profile -> vignette -> leakage -> image sensor

Each stage is a small, inspectable physical model. Because the recording is built forward, every recording ships with exact ground truth (cell locations, footprints, calcium traces, spike times, motion trajectory, per-pixel optical fields), which makes Minisim useful for:

  • Benchmarking calcium-imaging pipelines (minian, CaImAn, suite2p, ...) against known ground truth.
  • Teaching the anatomy of miniscope data: what each physical effect does to the image, via interactive notebooks.
  • Testing analysis code with reproducible, parameterized fixtures.

📖 Full documentation: minisim.readthedocs.io - concepts, quickstart, how-to guides, and the API reference.

Install

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

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

The teaching notebooks ship inside the package; list them and copy the ones you want out to a writable directory with the bundled command:

minisim-notebooks list                  # see what's available
minisim-notebooks copy 01_anatomy       # -> ./minisim-notebooks/01_anatomy
# then: cd minisim-notebooks/01_anatomy && jupyter lab

Quick start

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(density_per_mm3=400000.0, soma_radius_um=4.0),
        CellActivity(),
        CellOptics(),
        Composite(),
        Sensor(),
    ],
)

rec = simulate(spec)
movie = rec.observed          # xarray DataArray (frame, height, width)
truth = rec.ground_truth      # cells, traces, spikes, optical fields

Relationship to minian

Minisim is the forward (generative) counterpart to minian's inverse (analysis) pipeline. The dependency is designed to be strictly one-directional: Minisim never imports minian. The intended integration is for minian to use Minisim as a test dependency, supplying ground-truth fixtures for its recovery tests; that wiring is planned, not yet in place.

License

GPL-3.0-or-later. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minisim-1.0.3.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minisim-1.0.3-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file minisim-1.0.3.tar.gz.

File metadata

  • Download URL: minisim-1.0.3.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minisim-1.0.3.tar.gz
Algorithm Hash digest
SHA256 8d492f160ba668f37127f4ba40b2979df23479f0fb870036ad5402bfdc9cf1d5
MD5 8b76b9bd9e9bc73785cbf6c1084c6caf
BLAKE2b-256 9c47a6f7efb702629464c14b5b1ec4e95c4f13af03e203c1266c50eeacefafc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for minisim-1.0.3.tar.gz:

Publisher: publish.yml on miniscope/minisim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minisim-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: minisim-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minisim-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 26a88dfc02ac2ef076c7eb1a3c146716ec32bed46563251639dcb97f1cc6ef0e
MD5 f9ad718e6f249d0b24f721505c38c204
BLAKE2b-256 7f1c284c7070937f3afe39f030a25a104b0a1d755378654374d5fada6e523d86

See more details on using hashes here.

Provenance

The following attestation bundles were made for minisim-1.0.3-py3-none-any.whl:

Publisher: publish.yml on miniscope/minisim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page