Skip to main content

osipy

OSIPI-compliant MRI perfusion analysis library.

A Python library implementing OSIPI standards for MRI perfusion data analysis across four modalities: DCE-MRI, DSC-MRI, ASL, and IVIM. Supports multi-vendor DICOM, NIfTI, and BIDS data formats with optional GPU acceleration.

Features

  • DCE-MRI — T1 mapping (VFA, Look-Locker), signal-to-concentration conversion, pharmacokinetic modeling (Tofts, Extended Tofts, Patlak, 2CXM, 2CUM), arterial delay fitting
  • DSC-MRI — Delta-R2* conversion, SVD deconvolution (sSVD/cSVD/oSVD/Tikhonov), leakage correction, CBV/CBF/MTT/Tmax maps
  • ASL — PCASL/PASL/CASL labeling schemes, M0 calibration, single and multi-PLD CBF quantification, ATT estimation
  • IVIM — Bi-exponential diffusion-perfusion fitting with segmented, simultaneous, and Bayesian approaches
  • Standards — Parameter naming, units, and symbols follow CAPLEX (DCE/DSC) and the ASL Lexicon
  • Extensible — Registry-driven architecture: add models, fitters, or methods with a single decorator
  • GPU-ready — Transparent CPU/GPU portability via array module abstraction (NumPy/CuPy)
  • Multi-vendor — DICOM metadata extraction for GE, Siemens, and Philips scanners

Installation

pip install osipy

For GPU acceleration (CUDA 12.x):

pip install osipy[gpu]

Requires Python 3.12+.

Quick Start

Programmatic API

from osipy.pipeline import run_analysis

# Unified entry point for any modality
result = run_analysis(data, modality="dce", model="extended_tofts", aif=aif, time=time)

# Access parameter maps
ktrans = result.parameter_maps["Ktrans"]
print(ktrans.statistics())

Modality-Specific Usage

DCE-MRI:

from osipy.dce import fit_model, compute_t1_map, list_models

# Available models
print(list_models())  # ['tofts', 'extended_tofts', 'patlak', '2cxm', '2cum']

# T1 mapping
t1_map = compute_t1_map(signal, flip_angles, tr, method="vfa")

# Pharmacokinetic fitting
result = fit_model("extended_tofts", concentration=conc, aif=aif, time=time, mask=mask)

DSC-MRI:

from osipy.dsc import compute_perfusion_maps, get_deconvolver

maps = compute_perfusion_maps(delta_r2, aif, time, mask=mask, deconvolution_method="oSVD")
# maps.cbv, maps.cbf, maps.mtt, maps.ttp, maps.tmax

ASL:

from osipy.asl import quantify_cbf

cbf = quantify_cbf(
    difference_image, labeling_scheme="pcasl",
    pld=1800, label_duration=1800, m0=m0_data,
)

IVIM:

from osipy.ivim import fit_ivim

result = fit_ivim(dwi_data, b_values, fitting_method="segmented", b_threshold=200)
# result.d_map, result.d_star_map, result.f_map

CLI

# Run a pipeline from a YAML config
osipy config.yaml /path/to/data --output results/

# Print a default config template
osipy --dump-defaults dce

# Validate a config file
osipy --validate config.yaml

# Interactive setup wizard
osipy --help-me-pls

Data Loading

from osipy.common.io import discover_dicom, load_dicom_series, load_nifti

# NIfTI (auto-reads an adjacent BIDS sidecar when present)
dataset = load_nifti("/path/to/dce.nii.gz", modality="dce")

# DICOM: observe first, then load.
series = discover_dicom("/path/to/dicom_dir")
dataset = load_dicom_series(
    next(s for s in series if s.role_hint == "dynamic"),
    modality="dce",
)

Extending osipy

All components use a registry pattern. Adding a custom model is one file, one decorator:

from osipy.dce.models.registry import register_model
from osipy.dce.models.base import BasePerfusionModel

@register_model("my_model")
class MyModel(BasePerfusionModel):
    ...

# Now usable everywhere:
result = fit_model("my_model", concentration=conc, aif=aif, time=time)

Registries exist for models, fitters, deconvolvers, AIF detectors, leakage correctors, T1 methods, convolution methods, and more. See the extension points documentation for the full list.

Population AIFs

from osipy.common.aif import get_population_aif, list_aifs

print(list_aifs())  # ['parker', 'fritz_hansen', 'georgiou', 'mcgrath']
aif = get_population_aif("parker")

GPU Acceleration

from osipy.common.backend import is_gpu_available, set_backend, GPUConfig

if is_gpu_available():
    set_backend(GPUConfig(force_cpu=False))
# All numerical code automatically uses GPU when available

Development

pytest                    # Run all tests
pytest tests/unit/        # Unit tests only
pytest tests/integration/ # Integration tests
ruff check .              # Lint
mypy osipy                # Type check
mkdocs serve              # Local docs at http://127.0.0.1:8000

License

This project is licensed under the Apache License 2.0. See NOTICE for third-party attributions.

References

Metadata

Release files for osipy 0.1.4

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

Source distribution (sdist)

Source distribution for osipy 0.1.4
File Size Uploaded Provenance Actions
osipy-0.1.4.tar.gz 6.3 MB With provenance Details for osipy-0.1.4.tar.gz

Built distribution (wheel)

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

Total release size: 6.6 MB

Release files / osipy-0.1.4.tar.gz

Download URL osipy-0.1.4.tar.gz
Size 6.3 MB
Tags Source
SHA-256 checksum
How to use checksums
750a497d3670d45b2e17a27820f8509fff0488af7b1f24abf66080fbd8a2d49d
BLAKE2b-256 checksum
How to use checksums
04592c24062d1f92db5cbdd399b9958feab19df60c234614b46bd26624df0727
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Release files / osipy-0.1.4-py3-none-any.whl

Download URL osipy-0.1.4-py3-none-any.whl
Size 318.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60731701427f59be28f3c00166c752d17345bd4edce74030ac8295b8d024bf06
BLAKE2b-256 checksum
How to use checksums
14f7580e8c8337f1164b0b48e8cdcfaf7405ec8db7bc14d76484a1dbc7c51e53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Security for osipy 0.1.4

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for osipy-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

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