MRI utilities library for aind teams.
Project description
aind-mri-utils
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
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 aind_mri_utils-0.11.2.tar.gz.
File metadata
- Download URL: aind_mri_utils-0.11.2.tar.gz
- Upload date:
- Size: 63.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10b258ca164883652e658ada3c530320111422cebe27662856086662bd936c7e
|
|
| MD5 |
4617b49c69577cd87048ecc8806d7c59
|
|
| BLAKE2b-256 |
afda7d1ea97891620237feb9bad66ccbae822e14c4f58178c36edf651e7bc736
|
File details
Details for the file aind_mri_utils-0.11.2-py3-none-any.whl.
File metadata
- Download URL: aind_mri_utils-0.11.2-py3-none-any.whl
- Upload date:
- Size: 55.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4992e561ae856082f246e5bf26cc0d6b25719f86ffca2dc6e9f5d7faafcf378
|
|
| MD5 |
d223bbc757433ebfeb863a0e718c6d34
|
|
| BLAKE2b-256 |
52c1929eb73bb48a9adc32ececfe14a16c306b01d2c92517e65af649d04e61cc
|