Skip to main content

msr

Pure Python and cross-platform reader for MSR/OBF image files as created by Imspector.

Implementation follows the description at: https://imspectordocs.readthedocs.io/en/latest/fileformat.html

WARNING: Only tested on data from our own Abberior Expert Line STED microscope with a narrow range of Imspector versions.

Installation

pip install msr-reader

Usage

from msr_reader import OBFFile
from xml.etree import ElementTree
import ome_types

with OBFFile('file_path.msr') as f:

    # reading image data
    idx = 0
    img = f.read_stack(idx) # read stack with index idx into numpy array

    # multi-channel (or confocal + STED) data is acquired into separate stacks by Imspector.
    # stack_groups groups stacks with same series number in the stack name and identical geometry.
    # every stack belongs to exactly one group, unmatched stacks
    # (e.g. line profiles, rescue_info maps) form single-member groups.
    groups = f.stack_groups # list of StackGroup
    img = f.read_stack_group(0) # read all "channels", stacked along a new first axis: e.g. (C, Z, Y, X)

    # xarray integration (optional dependency: pip install msr-reader[xarray]):
    # stacks as xarray.DataArray with labelled dims and physical coordinates
    # (SI units of the file: meters for spatial axes, seconds for time)
    da = f.read_stack_xr(idx) # dims e.g. ('z', 'y', 'x'), coords in meters
    dag = f.read_stack_group_xr(0) # one DataArray with a leading 'channel' dim, labelled with channel names

    # stacks without names (sometimes found in old files) can be grouped by geometry alone:
    # with OBFFile('file_path.msr', group_unnamed_stacks=True) as f:

    # Lightbox files use hierarchical stack names ('Overview 1/Image 1/14:03:01/STAR RED'):
    # for .obf files, grouping by the path up to the last component (the
    # acquisition) and the last component (the channel name) is enabled by
    # default. for .msr files (Imspector), enable it explicitly:
    # with OBFFile('file_path.msr', group_hierarchical_stacks=True) as f:
    # pass group_hierarchical_stacks=False to disable it for .obf files.

    # metadata
    stack_shapes = f.shapes # list of stack shapes, including stack and dimension names
    pixel_sizes = f.pixel_sizes # like shapes, but with pixel sizes (unit: meters)

    # imspector metadata as xml string
    xml_imspector_metadata = f.get_imspector_xml_metadata(idx)
    
    # can be parsed with ElementTree, for example    
    et = ElementTree.fromstring(xml_imspector_metadata)
    # find, e.g. x pixel size in XML
    et.find('doc/ExpControl/scan/range/x/psz').text

    # OME-XML metadata as xml string
    xml_ome_metadata = f.get_ome_xml_metadata()
    # can be parsed with ome-types, for example
    ome_meta = ome_types.from_xml(xml_ome_metadata)

Metadata

Release files for msr-reader 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msr-reader 0.3.1
File Size Uploaded Provenance Actions
msr_reader-0.3.1.tar.gz 4.3 MB Without provenance Details for msr_reader-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for msr-reader 0.3.1
File Interpreter ABI Platform Actions
msr_reader-0.3.1-py3-none-any.whl Python 3 none any Details for msr_reader-0.3.1-py3-none-any.whl

Total release size: 4.3 MB

Release files / msr_reader-0.3.1.tar.gz

Download URL msr_reader-0.3.1.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
503f3543525aab5fb23f3ccceb54095b56f4e3ca54bfee68b446eaf50be1312e
BLAKE2b-256 checksum
How to use checksums
b39bc2b0c7ff2867aa6ff6a2a0928341c92094cca983b7963e4902e447acdd4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / msr_reader-0.3.1-py3-none-any.whl

Download URL msr_reader-0.3.1-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b8439354ab5a9d353204b543eaa37db6c3f705bc3430996f1a0d1a79a8bfd10
BLAKE2b-256 checksum
How to use checksums
1f145b9bffded428c726665be1b17e9f4e612bc1a07a4380e3a747465d0a2b79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for msr-reader 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page