An xarray-based MRI and MRS toolbox
Project description
📖 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
pyAMARESandnmrglue. - Modern Tooling: Built for speed and reliability, developed using
uvand 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:
-
Fork this repository and then clone your version of this repository.
-
Sync the environment and install dependencies:
uv sync
- Run tests via
pytest(which includes notebook testing vianbmake):
uv run pytest
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xmris-0.2.0.tar.gz.
File metadata
- Download URL: xmris-0.2.0.tar.gz
- Upload date:
- Size: 56.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ca6260a624fb430fe188ff7898afe8aecd62429673c35da0d45984392ca75be
|
|
| MD5 |
2de7839a612025cca5786d12e44a5cd4
|
|
| BLAKE2b-256 |
9731de8305660a6ef10e4e704576779991a046d626ed18b36333e54c5ac116ee
|
File details
Details for the file xmris-0.2.0-py3-none-any.whl.
File metadata
- Download URL: xmris-0.2.0-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3eec5ab81285a963808340e0228f6ab27ce4af19c428817ef18fbeca69c78440
|
|
| MD5 |
20f72795417cf6c70cd1cf1e69349aa7
|
|
| BLAKE2b-256 |
8d9107a477e056cf5956f7f51b98b6d5a3387bd3949f563ded84bf52bd7e1079
|