Skip to main content

MRI utilities library for aind teams.

Project description

aind-mri-utils

License Code Style semantic-release: angular Interrogate Coverage Python MyPy

MRI utilities toolkit for neuroscience experiment planning developed by Allen Institute for Neural Dynamics.

Installation

pip install aind-mri-utils

For development:

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

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")

Contributing

Development workflow

# Setup development environment
uv sync --group dev

# Run linting and formatting
uv run ruff check
uv run ruff format

# Run type checking
uv run mypy src/

# Run tests with coverage
uv run pytest

# Run all checks
./scripts/run_linters_and_checks.sh --checks

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'll primarily use Angular style for commit messages. Roughly, they should follow the pattern:

<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, setup.py)
  • ci: Changes to our CI configuration files and scripts (examples: .github/workflows/ci.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

Documentation

To build documentation:

uv sync --group docs
uv run mkdocs serve

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.0.tar.gz (66.6 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.0-py3-none-any.whl (58.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aind_mri_utils-0.12.0.tar.gz
  • Upload date:
  • Size: 66.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.0.tar.gz
Algorithm Hash digest
SHA256 14d3611b08c87e49b2d8ec212cdc2f706b4f46353fc4fafcd63db3b728b495d1
MD5 f3ecd7d3bc30427e2c1e9e7f145cfb0e
BLAKE2b-256 eea0e8c14327518d1bb9e05569e719d76324ec5f705b19cdccce7805d7bfb20b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aind_mri_utils-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 58.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71e235bd5b1229026e84fa905c2e2f58ed0741d017bf2acad7fe765bb3cf9995
MD5 15cd1305fdbfc039eaca7d072ef1c8aa
BLAKE2b-256 37ab5a749aacf72f53c14bd5242b23c677700c7e17b349942802b4ce7a2e8f09

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