Skip to content

API reference

All the models used to define a simulation can be imported from microsim.schema, which is usually imported as ms:

from microsim import schema as ms

ms.Simulation, ms.Confocal, ms.CameraCMOS, ...

Every model is a pydantic model. Fields are validated when the object is created and when they are assigned, and every field that takes a model also accepts a dictionary with the same keys. Unknown fields raise an error.

The pages in this section are generated from the source code, one per public module, so they always match the installed version. Each object is documented once, in the module or subpackage that defines it; most are also importable from microsim.schema, as above. The main objects, by topic:

Simulation

Object Description
Simulation the top-level model
Simulation.run run every stage and return the digital image
Simulation.run_batch run once per sample, reusing PSFs and emission rates
Track channels acquired at the same time (guide)
ground_truth, filtered_emission_rates, optical_image, digital_image the stages, run one at a time (guide)

Spaces

Object Description
ShapeScaleSpace, ExtentScaleSpace, ShapeExtentSpace a space given by two of shape, extent, and scale
DownscaledSpace, UpscaledSpace a space derived from another one (guide)

Sample

Object Description
Sample, FluorophoreDistribution the labels in the sample, and where each one is
Fluorophore spectra, extinction coefficient, quantum yield, lifetime
MatsLines, CosemLabel built-in distributions (guide)
cosem, allen OpenOrganelle (COSEM) datasets, Allen Institute neuron reconstructions

Optics

Object Description
ObjectiveLens numerical aperture, immersion and specimen refractive index
Widefield, Confocal, Identity imaging modalities (guide)
psf functions to compute widefield and confocal PSFs directly

Channels

Object Description
OpticalConfig a channel: light sources, filters, and optionally its own exposure (and detector QE) (guide)
LightSource an excitation spectrum and its relative power
Bandpass, Longpass, Shortpass, SpectrumFilter filters
Spectrum a sampled spectrum
optical_config.lib built-in filter sets and laser lines

Detectors

Object Description
CameraCCD, CameraCMOS, CameraEMCCD cameras (guide)
PMT, HyD point detectors
detectors.lib built-in detectors

Settings and utilities

Object Description
Settings array backend, precision, random seed, caching (guide)
util plotting (ortho_plot, ndview, animate) and cache helpers