Skip to main content

A modern Python library for converting Mass Spectrometry Imaging (MSI) data into SpatialData/Zarr format - your portal to spatial omics

Project description

Thyra

Tests PyPI Python 3.10+ License: MIT Code style: black

Thyra (from Greek θύρα, meaning "door" or "portal") - A modern Python library for converting Mass Spectrometry Imaging (MSI) data into the standardized SpatialData/Zarr format, serving as your portal to spatial omics analysis workflows.

Features

  • Multiple Input Formats: ImzML, Bruker (.d directories)
  • SpatialData Output: Modern, cloud-ready format with Zarr backend
  • Memory Efficient: Handles large datasets (100+ GB) through streaming processing
  • Metadata Preservation: Extracts and maintains all acquisition parameters
  • 3D Support: Process volume data or treat as 2D slices
  • Cross-Platform: Windows, macOS, and Linux support

Installation

Via pip (Recommended)

pip install thyra

Via conda

conda install -c conda-forge thyra

From source

git clone https://github.com/Tomatokeftes/thyra.git
cd thyra
poetry install

Quick Start

Command Line Interface

# Basic conversion
thyra input.imzML output.zarr

# With custom parameters
thyra data.d output.zarr --pixel-size 50 --dataset-id "experiment_001"

# 3D volume processing
thyra volume.imzML output.zarr --handle-3d

Python API

from thyra import convert_msi

# Simple conversion
success = convert_msi(
    input_path="data/sample.imzML",
    output_path="output/sample.zarr",
    pixel_size_um=25.0
)

# Advanced usage with custom parameters
success = convert_msi(
    input_path="data/experiment.d",
    output_path="output/experiment.zarr",
    dataset_id="exp_001",
    pixel_size_um=10.0,
    handle_3d=True
)

Supported Formats

Input Formats

Format Extension Description Status
ImzML .imzML Open standard for MS imaging ✅ Full support
Bruker .d Bruker proprietary format ✅ Full support

Output Formats

Format Description Benefits
SpatialData/Zarr Modern spatial omics standard Cloud-ready, efficient, standardized

Advanced Usage

Configuration Options

# All available options
thyra input.imzML output.zarr \
    --pixel-size 25 \
    --dataset-id "my_experiment" \
    --handle-3d \
    --optimize-chunks \
    --log-level DEBUG \
    --log-file conversion.log

Batch Processing

import glob
from thyra import convert_msi

# Process multiple files
for input_file in glob.glob("data/*.imzML"):
    output_file = input_file.replace(".imzML", ".zarr")
    convert_msi(input_file, output_file)

Working with SpatialData

import spatialdata as sd

# Load converted data
sdata = sd.read_zarr("output/sample.zarr")

# Access the MSI data
msi_data = sdata.tables["msi_dataset"]
print(f"Shape: {msi_data.shape}")
print(f"Mass channels: {msi_data.var.index}")

Development

Setup Development Environment

# Clone repository
git clone https://github.com/Tomatokeftes/thyra.git
cd thyra

# Install with development dependencies
poetry install

# Install pre-commit hooks
poetry run pre-commit install

Running Tests

# Unit tests only
poetry run pytest -m "not integration"

# All tests
poetry run pytest

# With coverage
poetry run pytest --cov=thyra

Code Quality

# Format code
poetry run black .
poetry run isort .

# Run linting
poetry run flake8

# Run all checks
poetry run pre-commit run --all-files

Documentation

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Quick Contribution Steps

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes and add tests
  4. Run the test suite (poetry run pytest)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to your branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Citation

If you use Thyra in your research, please cite:

@software{thyra2024,
  title = {Thyra: Modern Mass Spectrometry Imaging Data Conversion - Portal to Spatial Omics},
  author = {Visvikis, Theodoros},
  year = {2024},
  url = {https://github.com/Tomatokeftes/thyra}
}

Acknowledgments


Thyra - Your portal from traditional MSI formats to modern spatial omics workflows

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

thyra-1.9.0.tar.gz (5.8 MB view details)

Uploaded Source

Built Distribution

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

thyra-1.9.0-py3-none-any.whl (5.9 MB view details)

Uploaded Python 3

File details

Details for the file thyra-1.9.0.tar.gz.

File metadata

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

File hashes

Hashes for thyra-1.9.0.tar.gz
Algorithm Hash digest
SHA256 0fdebc0bc04afdf3c4dbdf8c5a0f381047ccb54a137374fa78231150ee36f1ba
MD5 4b165a8ba1f4e508b35d482355c56437
BLAKE2b-256 7c9a83a3cf8f273d760e060a3a4e96a36f038ab54b0efb1dcb01597f8d46f27f

See more details on using hashes here.

Provenance

The following attestation bundles were made for thyra-1.9.0.tar.gz:

Publisher: release.yml on Tomatokeftes/thyra

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

File details

Details for the file thyra-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: thyra-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for thyra-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94d30bc492627c18f927ad8bbd4f651d4e429fd64e1d17417b58bb4d08514151
MD5 91b263b5160495b0bc5d6d4cfe1ba39e
BLAKE2b-256 3870389974e4a5004c3dea69ec8fe3a96a624e95a60972725d1d885dc5138e8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for thyra-1.9.0-py3-none-any.whl:

Publisher: release.yml on Tomatokeftes/thyra

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