Skip to main content

Schema for multi-dimensional microscopy experiments

Project description

useq-schema

License PyPI - Python Version PyPI Conda tests docs codecov

An open, implementation-agnostic schema for describing multi-dimensional microscopy experiments.

Documentation: https://pymmcore-plus.github.io/useq-schema/

Rationale

The useq-schema library defines a structured schema to represent a sequence of microscope acquisition events. By adopting this schema, various microscopy software tools can facilitate interoperability, allowing end users to potentially switch between different control backends with ease. The goal is to encourage a shared standard, making it straightforward for developers to adopt useq-schema and enhance compatibility across tools.

We are particularly interested in feedback from developers of microscopy-control software. If you are interested in supporting the useq-schema in your software, please open an issue or pull request to discuss how we can make that easier for you, or to request additional features that would be necessary for your use case.

useq.MDAEvent

The primary "event" object is useq.MDAEvent. This represents a single event that a microscope should perform, including preparation of the hardware, and execution of the event (such as an image acquisition).

from useq import MDAEvent

event = MDAEvent(
    channel="DAPI",
    exposure=100,
    x_pos=100.0,
    y_pos=100.0,
    z_pos=30.0,
    min_start_time=10.0,
    ... # multiple other fields
)

Downstream libraries that aim to support useq-schema should support driving hardware based on an Iterable[MDAEvent]. See useq.MDAEvent documentation for more details.

Similar objects in existing software packages

useq.MDASequence

useq.MDASequence is a declarative representation of an multi-dimensional experiment. It represents a sequence of events: as might be generated by the multidimensional acquisition GUI in most microscope software. It is composed of "plans" for each axis in the experiment (such as a Time Plan, a Z Plan, a list of channels and positions, etc.). A useq.MDASequence object is itself iterable, and yields MDAEvent objects.

See useq.MDASequence documentation for more details.

Similar objects in existing software packages

Example usage

from useq import MDASequence

mda_seq = MDASequence(
    stage_positions=[(100, 100, 30), (200, 150, 35)],
    channels=["DAPI", "FITC"],
    time_plan={'interval': 1, 'loops': 20},
    z_plan={"range": 4, "step": 0.5},
    axis_order='tpcz',
)

The MDASequence object is iterable, yielding MDAEvent objects in the order specified by the axis_order attribute.

>>> events = list(mda_seq)

>>> print(len(events))
720 

>>> print(events[:3])
[MDAEvent(
    channel=Channel(config='DAPI'),
    index=mappingproxy({'t': 0, 'p': 0, 'c': 0, 'z': 0}),
    min_start_time=0.0,
    x_pos=100.0,
    y_pos=100.0,
    z_pos=28.0,
 ),
 MDAEvent(
    channel=Channel(config='DAPI'),
    index=mappingproxy({'t': 0, 'p': 0, 'c': 0, 'z': 1}),
    min_start_time=0.0,
    x_pos=100.0,
    y_pos=100.0,
    z_pos=28.5,
 ),
 MDAEvent(
    channel=Channel(config='DAPI'),
    index=mappingproxy({'t': 0, 'p': 0, 'c': 0, 'z': 2}),
    min_start_time=0.0,
    x_pos=100.0,
    y_pos=100.0,
    z_pos=29.0,
 )]

Both MDAEvent and MDASequence objects are pydantic models, so they can be easily serialized to and from json or yaml.

print(mda_seq.yaml())
axis_order: tpcz
channels:
- config: DAPI
- config: FITC
stage_positions:
- x: 100.0
  y: 100.0
  z: 30.0
- x: 200.0
  y: 150.0
  z: 35.0
time_plan:
  interval: 0:00:01
  loops: 20
z_plan:
  range: 4.0
  step: 0.5

Installation

pip install useq-schema

or, with conda:

conda install -c conda-forge useq-schema

Executing useq-schema experiments with pymmcore-plus

pymmcore-plus implements an acquisition engine that can execute an iterable of MDAEvents using micro-manager in a pure python environment (no Java required).

from pymmcore_plus import CMMCorePlus

core = CMMCorePlus()
core.loadSystemConfiguration()  # loads demo by default

core.mda.run(mda_seq)  # run the experiment

# or, construct a sequence of MDAEvents anyway you like
events = [MDAEvent(...), MDAEvent(...), ...]
core.mda.run(events)

This can be considered a "reference implementation" of an engine that supports useq-schema.

See pymmcore-plus documentation for details.

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

useq_schema-0.5.2.tar.gz (59.7 kB view details)

Uploaded Source

Built Distribution

useq_schema-0.5.2-py3-none-any.whl (46.5 kB view details)

Uploaded Python 3

File details

Details for the file useq_schema-0.5.2.tar.gz.

File metadata

  • Download URL: useq_schema-0.5.2.tar.gz
  • Upload date:
  • Size: 59.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for useq_schema-0.5.2.tar.gz
Algorithm Hash digest
SHA256 83d2fba738fd2664672dce0b5960a74cbec9b3c5c897bdf733557d9372d32e83
MD5 401d689b9dfc4cf5c9e0bf5f533b8f02
BLAKE2b-256 14cbf2827051c60f3736d6f7c19826ef1b1ee65bee07e53d5ec69407a4b85a87

See more details on using hashes here.

Provenance

The following attestation bundles were made for useq_schema-0.5.2.tar.gz:

Publisher: ci.yml on pymmcore-plus/useq-schema

Attestations:

File details

Details for the file useq_schema-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: useq_schema-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 46.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for useq_schema-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f5768101b0e626d22a6cdd004f2d2d6e86ab8c16028bb18e2bf66ba4364afe32
MD5 639d12da37adda476b202666f8c73cbe
BLAKE2b-256 a098123be0fa9b09c42d5391b3b74a5247aa582de6e4bb5aeeddb5f09f6c7457

See more details on using hashes here.

Provenance

The following attestation bundles were made for useq_schema-0.5.2-py3-none-any.whl:

Publisher: ci.yml on pymmcore-plus/useq-schema

Attestations:

Supported by

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