Skip to main content

MIRACLE SDK 🫀

The Official Python SDK for the MIRACLE API

PyPI version License: MIT Python 3.8+

📦 PyPI: pypi.org/project/miracle-sdk


MIRACLE: MR Imaging Reference API for Cardiovascular Limits from Evidence

The MIRACLE SDK provides a simple, typed, and high-performance Python interface to access standardized cardiovascular MRI reference values. Built for data scientists and medical researchers who need to process cardiac imaging data at scale.

✨ Features

  • 34 Endpoints: Access all MIRACLE API domains with auto-generated, typed methods.
  • Batch Processing: Process hundreds of patients in parallel with MiracleBatch.
  • IDE Support: Full autocomplete and type hints for VS Code, PyCharm, and more.
  • Battle-Tested: Verified with stress tests (16+ concurrent requests, 100% success rate).

🚀 Installation

pip install miracle-sdk

📖 Quick Start

Single Request

from miracle import Miracle

# Initialize the client
client = Miracle()

# Get reference values for a pediatric left ventricle
result = client.pediatric_ventricle_reference_values(
    parameter="LVEDV",
    gender="Male",
    measured=62.5,
    ht_cm=110,
    wt_kg=22
)

print(result)
# {'inputs': {...}, 'results': {'calc_z': 0.5, 'calc_percentile': 69.1, ...}}

Batch Processing

Process an entire CSV of patients with multi-threaded parallelism.

Input CSV (patients.csv):

patient_id,gender,height_cm,weight_kg,lv_volume,param_type
001,Male,120,30,75,LVEDV
002,Female,110,25,60,LVEDV

Code:

from miracle import MiracleBatch

# Initialize the batch processor
processor = MiracleBatch(max_workers=10)

# Define how your CSV columns map to API parameters
mapping = {
    "gender": "gender",
    "ht_cm": "height_cm",
    "wt_kg": "weight_kg",
    "measured": "lv_volume",
    "parameter": "param_type"
}

# Process the CSV
df_results = processor.process_csv(
    file_path="patients.csv",
    domain="Pediatric_Ventricle",
    mapping=mapping
)

# Save the enriched data
df_results.to_csv("patients_with_zscores.csv", index=False)

🗺️ Parameter Mapping Guide

The mapping dictionary connects your CSV column names to the API parameter names.

mapping = {
    "API_PARAMETER": "YOUR_CSV_COLUMN",
    "ht_cm": "Patient_Height",  # Example
}

How to Find API Parameters

  1. Online Docs: Visit miracleapi.readme.io and check the "Query Parameters" for your endpoint.
  2. Python Help: Use the built-in docstrings:
    help(client.lv_reference_values)
    

Common Parameters

Parameter Type Description
gender str "Male" or "Female"
age float Patient age in years
ht_cm float Height in centimeters
wt_kg float Weight in kilograms
measured float The measured value (e.g., volume, diameter)
parameter str The measurement type (e.g., "LVEDV", "LVEF")

🏗️ Architecture

This SDK is auto-generated from the official OpenAPI specifications. This guarantees:

  • Consistency: Python methods always match the live API.
  • Type Safety: Full autocomplete and type hints.
  • Reliability: API changes are automatically reflected in the SDK.

🤝 Contributing

Contributions are welcome! Please see the main MIRACLE-API repository for the source of truth.

Development Setup:

git clone https://github.com/drankush/MIRACLE-sdk.git
cd MIRACLE-sdk
pip install -e .[dev]

Regenerate the client from OpenAPI specs:

python scripts/generate.py

📖 Citation

If you use this SDK in your research, please cite:

MIRACLE: MR Imaging Reference API for Cardiovascular Limits from Evidence Authors: Ankush et al. Journal of Cardiovascular Magnetic Resonance (2026)


📄 License

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


Made with ❤️ for the Cardiac Imaging Research Community

Metadata

Release files for miracle-sdk 0.1.1

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

Source distribution (sdist)

Source distribution for miracle-sdk 0.1.1
File Size Uploaded
miracle_sdk-0.1.1.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for miracle-sdk 0.1.1
File Interpreter ABI Platform
miracle_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.1 kB

Release files / miracle_sdk-0.1.1.tar.gz

Download URL miracle_sdk-0.1.1.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
30e755fa6c64f9435d16be24d7fa42fd41a369dbdcbcf02219b2924bdb01aa0b
BLAKE2b-256 checksum
How to use checksums
5c348d78e673ef571b02efaf94a9cd7ddfb42a14ed65442d0763fa79a5d6693e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / miracle_sdk-0.1.1-py3-none-any.whl

Download URL miracle_sdk-0.1.1-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4e37314c0c1ed84ff2e03fa8d1cd6627fd8c3c1d72a5a2cd311c630ef02c69b
BLAKE2b-256 checksum
How to use checksums
bf716ba032fbb8ca3c228e56e89f67e44118ddf03984e4f33669534a20c65960
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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