komamripy
Pulseq-compatible, high-performance MRI simulation in Python.
komamripy is a thin Python interface to
KomaMRI.jl, a high-performance
Julia framework for MRI simulation. It exposes KomaMRI to Python through
juliacall, so
Python users can run fast CPU/GPU MRI simulations without writing any Julia.
Installation
Install from PyPI with uv (recommended):
uv init project-folder && cd project-folder
uv add komamripy
or with pip:
pip install komamripy
Quick start
The first import downloads Julia and precompiles KomaMRI, which can take a few minutes. Subsequent runs are fast.
import komamripy as km
import numpy as np
km.load_cuda() # GPU backend selection, optional
sys = km.Scanner() # scanner hardware
obj = km.brain_phantom2D() # 2D brain phantom
seq = km.PulseDesigner.EPI_example() # example EPI sequence
sim_params = {"return_type": "mat"} # return the raw signal matrix
raw = km.simulate(obj, seq, sys, sim_params=sim_params)
print(np.shape(raw))
You do not need to install Julia yourself: juliacall provisions a suitable
Julia automatically, and KomaMRI is installed on first import.
How it works
komamripy mirrors the KomaMRI Julia namespace: any function or type that
KomaMRI exposes is available as an attribute of komamripy. Julia code
therefore translates to Python almost line for line.
Simulation results are returned as Julia objects; convert array-like results to
NumPy with numpy.asarray.
Status
komamripy is under active development as a Google Summer of Code project.
Project status and roadmap are tracked in JuliaHealth/komamripy#9.
Metadata
Release files for komamripy 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| komamripy-0.0.11.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| komamripy-0.0.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / komamripy-0.0.11.tar.gz
| Download URL | komamripy-0.0.11.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
333c2911959ec354c6d28598716ba8e33dd897d26d26d506eecccc6fd10709c7
|
|
BLAKE2b-256 checksum How to use checksums |
120af7a20a24ac0862360eaec96b801998b20a7448df299eb967f70371a5f3e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","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}
|
Release files / komamripy-0.0.11-py3-none-any.whl
| Download URL | komamripy-0.0.11-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ee5991f8b37f0a2ed2fbf9386c923d3873e2c932041aba726960cfa53ad3401
|
|
BLAKE2b-256 checksum How to use checksums |
f28d7c1c20ca004046476812874b786c31f2cc2570170223f9cfa7144f4990ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","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}
|