Skip to content

Home

Thyra

PyPI Tests Python 3.12+ License: MIT Open in Colab

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 directory), PHI SmartSoft-TOF (.raw file)
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 in the CLI, opt-in from the Python API)
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 Path Instruments
ImzML .imzML file Any vendor exporting to the open standard
Bruker .d directory timsTOF fleX, Rapiflex MALDI-TOF
Waters .raw directory MassLynx imaging (DESI, MALDI)
PHI .raw file SmartSoft-TOF nanoTOF (ToF-SIMS)

.raw is claimed by two vendors and resolved by shape: Waters writes a directory, PHI writes a single file. See Supported Formats.

Output

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

Next Steps

  • Getting Started -- installation, first conversion, common workflows
  • Tutorial -- step-by-step walkthrough, from an example dataset to ion images
  • Supported Formats -- every input format, how it is detected, what metadata it supplies
  • CLI Reference -- every command-line option explained
  • Resampling -- how the common mass axis is chosen, and how to control it
  • Output Format -- what the .zarr contains and how to use it
  • API Reference -- Python API documentation

Acknowledgments

Visual identity

The Thyra logomark and logotype were designed by Nepsis Scriptorium.

Instagram @nepsis.scriptorium Email nepsisscriptorium@gmail.com

Built on