Skip to main content

Light microscopy simulation in python

Project description

microsim

License PyPI Python Version CI codecov

Light microscopy simulation in python.

The goal of this library is to generate highly realistic simulated data such as the following:

Montage2

(this data was generated using segmentations from cell jrc_hela-3 at OpenOrganelle as the ground truth)

https://github.com/user-attachments/assets/905fa1af-c8bd-406e-87a7-7c5921de74d1

Documentation

Start with the tutorial, and read about the simulation stages, then see the API Reference for details on the Simulation object and options for all of the fields.

Installation

from PyPI

pip install "microsim[all]"

[!NOTE] At the moment, this library is a bit more "application" than it is "library". If you are following the docs or tutorials, its probably best to install the full [all] extra, which brings in io, visualization, and other data-fetching dependencies. However, the bare minimal install is fully functional for generating data.

Local Development

gh repo clone tlambert03/microsim
cd microsim
uv sync

From github

To get the bleeding edge version, which will change rapidly, you can install from github.

pip install "microsim[all] @ git+https://github.com/tlambert03/microsim"

With GPU support

If available, microsim can use either Jax or Cupy to accelerate computations. These are not installed by default, see the jax or cupy installation instructions, paying attention to your GPU requirements. Support for torch is planned.

Usage

Construct and run a microsim.Simulation object.

from microsim import schema as ms
from microsim.util import ortho_plot

# define the parameters of the simulation
sim = ms.Simulation(
    truth_space=ms.ShapeScaleSpace(shape=(128, 512, 512), scale=(0.02, 0.01, 0.01)),
    output_space={'downscale': 8},
    sample=ms.Sample(
        labels=[ms.MatsLines(density=0.5, length=30, azimuth=5, max_r=1)]
    ),
    modality=ms.Confocal(pinhole_au=0.2),
    output_path="au02.tiff",
)

# run it
result = sim.run()

# optionally plot the result
ortho_plot(result)

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

microsim-0.0.12.tar.gz (4.5 MB view details)

Uploaded Source

Built Distribution

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

microsim-0.0.12-py3-none-any.whl (105.8 kB view details)

Uploaded Python 3

File details

Details for the file microsim-0.0.12.tar.gz.

File metadata

  • Download URL: microsim-0.0.12.tar.gz
  • Upload date:
  • Size: 4.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for microsim-0.0.12.tar.gz
Algorithm Hash digest
SHA256 f976ce19fb4aae22d7805d094007c76b4e7d3bf62e897bc1c8454ed93b9211fb
MD5 f6072ee60ec8801e52bdcdcf1a754d3c
BLAKE2b-256 4d4656bfb1bc44f464ede70daa5f98d786d71f57a9c559814d92b5185d0d280e

See more details on using hashes here.

Provenance

The following attestation bundles were made for microsim-0.0.12.tar.gz:

Publisher: ci.yml on tlambert03/microsim

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

File details

Details for the file microsim-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: microsim-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 105.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for microsim-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 85df04f2ae9b746b02ba22c3d5c39189a11f01cebfab197cb6a8f27859cd2088
MD5 14c20891accf61dca35ac609308fc696
BLAKE2b-256 71cb0ffe252c650c707ba4fab972ab5aa6c81745077b667dc708dc697b0a5acb

See more details on using hashes here.

Provenance

The following attestation bundles were made for microsim-0.0.12-py3-none-any.whl:

Publisher: ci.yml on tlambert03/microsim

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