Skip to main content

MRI utilities library for aind teams.

Project description

AIND MRI Utils

CI PyPI - Version semantic-release: angular License ruff uv Copier

MRI utilities library for aind teams.

Installation

pip install aind-mri-utils

For development, clone the repository and run:

git clone https://github.com/AllenNeuralDynamics/aind-mri-utils
cd aind-mri-utils
uv sync

Usage

# Arc angle conversions for probe positioning systems
from aind_mri_utils.arc_angles import vector_to_arc_angles, arc_angles_to_vector
probe_vector = [0.0, 0.5, -0.866]  # 30° from vertical
arc_angles = vector_to_arc_angles(probe_vector)  # → (30.0, 0.0)

# Reticle calibration from measurement data
from aind_mri_utils.reticle_calibrations import fit_rotation_params_from_parallax
calibration_file = "path/to/parallax_measurements.xlsx"
rotation_params = fit_rotation_params_from_parallax(calibration_file)

# Chemical shift correction for MRI images
from aind_mri_utils.chemical_shift import compute_chemical_shift
import SimpleITK as sitk
mri_image = sitk.ReadImage("brain_scan.nii")
shift_vector = compute_chemical_shift(mri_image, ppm=3.5, mag_freq=599.0)

# 3D geometric measurements
from aind_mri_utils.measurement import find_circle, dist_point_to_line
circle_center, radius = find_circle(measurement_points)
distance = dist_point_to_line(point, line_start, line_end)

# Medical image I/O
from aind_mri_utils.file_io import read_dicom, write_nii
dicom_volume = read_dicom("dicom_folder/")
write_nii(processed_volume, "output.nii")

Development

Please test your changes using the full linting and testing suite:

./scripts/run_linters_and_checks.sh -c

Or run individual commands:

uv run --frozen ruff format          # Code formatting
uv run --frozen ruff check           # Linting
uv run --frozen mypy                 # Type checking
uv run --frozen interrogate -v src   # Documentation coverage
uv run --frozen codespell --check-filenames  # Spell checking
uv run --frozen pytest --cov aind_mri_utils # Tests with coverage

Pull requests

For internal members, please create a branch. For external members, please fork the repository and open a pull request from the fork. We use Angular style commit messages, roughly:

<type>(<scope>): <short summary>

where scope (optional) describes the packages affected by the code changes and type (mandatory) is one of:

  • build: Changes that affect build tools or external dependencies (example scopes: pyproject.toml)
  • ci: Changes to our CI configuration files and scripts (examples: .github/workflows/ci-call.yml)
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bugfix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • test: Adding missing tests or correcting existing tests

License

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aind_mri_utils-0.12.3.tar.gz (258.9 kB view details)

Uploaded Source

Built Distribution

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

aind_mri_utils-0.12.3-py3-none-any.whl (59.1 kB view details)

Uploaded Python 3

File details

Details for the file aind_mri_utils-0.12.3.tar.gz.

File metadata

  • Download URL: aind_mri_utils-0.12.3.tar.gz
  • Upload date:
  • Size: 258.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 aind_mri_utils-0.12.3.tar.gz
Algorithm Hash digest
SHA256 b339a80608d105b8180eaedf13ce831df1a6f276f7eb921383fcae82876326e9
MD5 d0e9b3ed246c58f18e05ba84e9581875
BLAKE2b-256 f6ce5e71eb43a47bdb65fd6130413726a2df20caa3e1b118d6ba756917ff293b

See more details on using hashes here.

File details

Details for the file aind_mri_utils-0.12.3-py3-none-any.whl.

File metadata

  • Download URL: aind_mri_utils-0.12.3-py3-none-any.whl
  • Upload date:
  • Size: 59.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 aind_mri_utils-0.12.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0ef82f56993f6b03d0edd12abceb6e2cf33a87dc1dd1f3dfbc22047e42f49b06
MD5 9b0fcda13e9ca7d61472287b9abccc5b
BLAKE2b-256 4a33af957e5f3e2dfe589e354e0755fdc76457737d871959a1973f918e4217aa

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