3D brain MRI segmentation with a packaged UNet3D trained model and simple inference API.
Project description
Library quickstart
Minimal, copy-pasteable way to predict the packaged TorchScript model on your own NIfTI image
from pathlib import Path
from neuroimaging import VolumeSegmenter, Transforms
image_path = Path("path/to/your_scan.nii.gz")
device = "cpu"
input_tensor = VolumeSegmenter.prepare_input(image_path, device=device)
preprocessor = Transforms.normalize_input()
normalized_data = preprocessor({"image": input_tensor})
input_tensor = normalized_data["image"].to(device)
segmenter = VolumeSegmenter.from_pretrained(device=device)
mask = segmenter.predict(
input_tensor, output_path=image_path.with_name("predicted_mask.nii.gz")
)
Model
Development
Install uv
https://docs.astral.sh/uv/getting-started/installation/
uv venv # creates venv
uv sync --all-extras --dev # installs dependencies on venv
uv run -m segmentation.examples.models # this is how to run .py files
Format code with ruff
uv run ruff check --select I --fix # format imports, or run without --fix to check only
uv run ruff format # format code, or run with --check
Check typing
uv run mypy . --config-file pyproject.toml # runs type linter
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
neuroimaging-1.0.0.tar.gz
(8.1 kB
view details)
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 neuroimaging-1.0.0.tar.gz.
File metadata
- Download URL: neuroimaging-1.0.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac88d50e97cc24f588f97b1cdc939c55fe472001b9a652c243ca3e92d36251d9
|
|
| MD5 |
61a1b8fcf6ae8ee4e74158bc7fafb392
|
|
| BLAKE2b-256 |
c41838766cddb9b8d3fdc9b00932210ce94f3a5a9c907fa4593d5ec41124e1b4
|
File details
Details for the file neuroimaging-1.0.0-py3-none-any.whl.
File metadata
- Download URL: neuroimaging-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10e18eca14c9f6439a52fda860e35480e14bead4608d42172584f11c40558d47
|
|
| MD5 |
99ea85a44407637bb352b4bbbaca484c
|
|
| BLAKE2b-256 |
dbf1477be0e2648245fe19e8518770260b689249822dc6f09401e72505f8a9e5
|