Skip to main content

An xarray-based MRI and MRS toolbox

Project description

xmris logo

A modern, N-dimensional, xarray-based toolbox for Magnetic Resonance Imaging and Spectroscopy.

MyST GitHub Pages Deploy Tests codecov
uv Ruff Python Versions License: AGPL v3

📖 Documentation

Documentation, tutorials, and API reference can be found here.

⚡ Overview

xmris bridges the gap between modern data structures and magnetic resonance research. By building on top of xarray, it provides a robust environment for handling multi-dimensional MRI and MRS data with labeled coordinates, powerful broadcasting, and seamless integration with the scientific Python ecosystem.

Key Features:

  • N-Dimensional Data: Native handling of complex MRI/MRS datasets using xarray.
  • MRS Integration: Direct compatibility with tools like pyAMARES and nmrglue.
  • Modern Tooling: Built for speed and reliability, developed using uv and strictly typed for modern Python environments.

🚀 Installation

Note: xmris requires Python 3.11 or 3.12.

You can install the package directly from PyPI using standard package managers:

# Using pip
pip install xmris

# Using uv (recommended)
uv add xmris

💻 Quick Start

import numpy as np
import xarray as xr
import xmris  # Registers the .xmr accessor!

# 1. Create a dummy N-dimensional FID (e.g., 5 Voxels x 1024 Time points)
time = np.linspace(0, 1, 1024)
data = np.random.randn(5, 1024) + 1j * np.random.randn(5, 1024)

mrsi_data = xr.DataArray(
    data,
    dims=["voxel", "time"],
    coords={"voxel": np.arange(5), "time": time},
    attrs={"MHz": 120.0, "sw": 10000.0}
)

# 2. Process all voxels simultaneously using the .xmr accessor!
results = (
    mrsi_data
    .xmr.zero_fill(target_points=2048)
    .xmr.apodize_exp(lb=5.0)
    .xmr.to_spectrum()
    .xmr.autophase()
)

🛠️ Development

We use uv for lightning-fast dependency management and Ruff for linting/formatting. To set up a local development environment:

  1. Fork this repository and then clone your version of this repository.

  2. Sync the environment and install dependencies:

uv sync
  1. Run tests via pytest (which includes notebook testing via nbmake):
uv run pytest
  1. Build the MyST based documentation :
uv run docs

More information can be found in the documentation here


⚖️ License & Commercial Use

xmris is licensed under the GNU Affero General Public License v3.0 (AGPLv3).

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

xmris-0.6.1.tar.gz (66.5 kB view details)

Uploaded Source

Built Distribution

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

xmris-0.6.1-py3-none-any.whl (78.9 kB view details)

Uploaded Python 3

File details

Details for the file xmris-0.6.1.tar.gz.

File metadata

  • Download URL: xmris-0.6.1.tar.gz
  • Upload date:
  • Size: 66.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for xmris-0.6.1.tar.gz
Algorithm Hash digest
SHA256 d350ebede4a4af5f482574810bd69f34af1f09b057f837531651b238752efa02
MD5 029271864397be055ca36bf222b30e28
BLAKE2b-256 a6b81119dd99f52f0766908e56f9f75ce4a538079f012e27741588da2d0cea77

See more details on using hashes here.

File details

Details for the file xmris-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: xmris-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 78.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for xmris-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 941d5af5d06dc48979ff5ab5b7359ebd380af8c6bce2249c5eaa86bbc056294e
MD5 3d88ee52d47873aab3d6330fa6e5ae85
BLAKE2b-256 5248ecff2261c64673757cce3a709ed2b1fe0f7ce47d4ff89a6a5bb833a3f8ba

See more details on using hashes here.

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