Skip to content

Thyra

PyPI Tests Python 3.11+ License: MIT

Thyra (from Greek thyra, meaning "door" or "portal") converts Mass Spectrometry Imaging (MSI) data into the standardized SpatialData/Zarr format -- your portal to spatial omics analysis workflows.


Why Thyra?

Mass spectrometry imaging produces rich spatial-molecular data, but every vendor stores it differently. Downstream tools -- napari, squidpy, scanpy -- expect a common format. Thyra bridges that gap:

 .imzML  ──┐                        ┌── napari visualisation
 .d      ──┼──  thyra  ──> .zarr  ──┼── squidpy / scanpy analysis
 .raw    ──┘   (SpatialData)        └── custom Python workflows

The output is a single SpatialData/Zarr directory containing intensity matrices, TIC images, optical images, pixel geometries, and full metadata -- ready for any tool in the scverse ecosystem.


Features

Feature Description
Formats Multiple inputs ImzML, Bruker (.d timsTOF + Rapiflex), Waters (.raw)
Output SpatialData/Zarr Cloud-ready, chunked, standardised
Scale Memory efficient Streaming mode for 100+ GB datasets
Optics Optical alignment Automatic MSI-to-microscopy registration (Bruker)
Regions Multi-region Handles slides with multiple tissue sections
Resampling Physics-aware Instrument-specific mass axis resampling (on by default)
3D Volume support Process as 3D volume or separate 2D slices
Platform Cross-platform Windows, macOS, Linux

Quick Start

Install

pip install thyra

Convert

thyra input.imzML output.zarr
from thyra import convert_msi

success = convert_msi("input.imzML", "output.zarr")

Explore the output

import spatialdata as sd

sdata = sd.read_zarr("output.zarr")

# Intensity matrix (pixels x m/z bins)
table = sdata.tables["msi_dataset_z0"]
print(f"Shape: {table.shape}")
print(f"m/z range: {table.var['mz'].min():.1f} -- {table.var['mz'].max():.1f}")

# TIC image
import numpy as np
tic = np.asarray(sdata.images["msi_dataset_z0_tic"])[0]

What is in the output?

See Output Format for the full structure: tables, TIC images, optical images, pixel shapes, regions, and metadata.


Supported Formats

Input

Format Extension Instruments
ImzML .imzML Any vendor exporting to open standard
Bruker .d timsTOF fleX, Rapiflex MALDI-TOF
Waters .raw MassLynx imaging (DESI, MALDI)

Output

Format Description
SpatialData/Zarr The scverse standard for spatial omics -- cloud-ready, chunked, with coordinate transforms

Next Steps