Skip to main content

MNUtils

PyPI Python Tests Docs License: BSD-3-Clause

MNUtils is a collection of utility functions for working with multi-nuclear MR data from our GE scanners.

Features

  • Data loading — read GE raw/reconstructed data via GEExam/GESeries.
  • NIfTI handling — read dcm2niix-converted scanner output (NIfTI + JSON sidecar); DICOMs are not read.
  • Plotting — spectral and slice plotting utilities.
  • Spectral fitting — AMARES fitting delegated to xmris (xmris[fitting], which wraps pyAMARES).

See the documentation for the full basics, data model, plotting, fitting, NIfTI, and MATLAB-bridge guides.

Installation

MNUtils is on PyPI:

uv add mnutils

Optional extras:

uv add "mnutils[bet]"     # brain extraction (hd-bet, torch)

To track the development version instead:

uv add git+https://github.com/bastigw/mnutils.git

The MATLAB Engine is not an extra: its version has to match your local MATLAB install, so you install it yourself (see MATLAB Engine Dependency below).

Usage

The main entry point is ExamBase: point it at a GE exam's data folder and it classifies every series for you — no need to know in advance which folder is an anatomical scan and which is a spectrum.

from mnutils.GEExam import ExamBase

exam = ExamBase("data/HeVo-11")  # prints an overview of every series it found

exam.exam_overview.head()  # same overview as a DataFrame
exam.series_dict[6]  # the GESeries subclass ExamBase picked for series 6 — nothing loaded yet

Load the series you actually need and analyse it — everything about it (spectrum, header fields, scan time) lives on the returned object:

exam.load_series(6)
mrs = exam[6]

print(mrs.protocol_name, mrs.spec.dims, mrs.spec.shape)
avg = mrs.avg_spec  # average over repetitions

load_series also takes a list, and load_all loads everything ExamBase classified. If you already know a series's type, construct it directly (e.g. MRSSeries(DATA_FOLDER, 6)) and skip the exam-level overview entirely.

From there, spectral fitting is handled by xmris — MNUtils deliberately doesn't reimplement fitting, a series hands its FIDs straight to xmris's AMARES implementation (itself built on pyAMARES) and returns the xmris result:

uv add "xmris[fitting]"

See the fitting docs for the full workflow, and the loading data and GEExam tutorials for more on exams and series. Need a raw .mat file's path directly instead of a loaded object? mnutils.utils.file_helpers.get_mat_data_from_series(base_folder, series_id) returns it.

Requirements

  • Python 3.12+

MATLAB Engine Dependency

To use MNUtils, you need to install the MATLAB Engine for Python. The version of the MATLAB Engine you require depends on your local MATLAB version. Ensure you install the correct version that matches your MATLAB installation.

You can find the appropriate MATLAB Engine version for your setup here: MATLAB Engine for Python.

To install the MATLAB Engine in your project, use the following command, replacing <version> with the correct version for your MATLAB:

uv add "matlabengine==<version>"

Development

See CONTRIBUTING.md and the contributor docs for setup, tests, docs, and lint workflow.

Contributions and Suggestions

I'm very open to suggestions and improvements! If you have ideas or want to share your own utilities, feel free to reach out or submit a pull request.

License

BSD-3-Clause — see LICENSE.

Metadata

Release files for MNutils 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MNutils 1.3.0
File Size Uploaded Provenance Actions
mnutils-1.3.0.tar.gz 124.8 kB Without provenance Details for mnutils-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for MNutils 1.3.0
File Interpreter ABI Platform Actions
mnutils-1.3.0-py3-none-any.whl Python 3 none any Details for mnutils-1.3.0-py3-none-any.whl

Total release size: 263.1 kB

Release files / mnutils-1.3.0.tar.gz

Download URL mnutils-1.3.0.tar.gz
Size 124.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2ddf463640c98cdebbccd4cabe2c06185f6e7ef82bbc83f2addf77a51215bd1c
BLAKE2b-256 checksum
How to use checksums
d8516d18b011fcaf62096ba3a563ffae20a7420f83d6ed41a5f62e0c4662eaa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.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}

Release files / mnutils-1.3.0-py3-none-any.whl

Download URL mnutils-1.3.0-py3-none-any.whl
Size 138.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bae24456a1cad221a9f29597022fedf817caa96e85c907485d96f71ee6075867
BLAKE2b-256 checksum
How to use checksums
f322a987ff55007c0b6a4447a95a46c31add43a32b0e08c30f95742c7f7a9224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.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}

Security for MNutils 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page