Skip to main content

Pulseq-compatible, high-performance MRI simulation in Python, powered by KomaMRI.jl.

Project description

komamripy

CI PyPI version Python versions License

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

You do not need to install Julia yourself: juliacall provisions a suitable Julia automatically, and KomaMRI is installed on first import.

The examples additionally use NumPy (pip install numpy), which is not a runtime dependency of komamripy itself.

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

sys = km.Scanner()                       # scanner hardware
obj = km.brain_phantom2D()               # 2D brain phantom
seq = km.PulseDesigner.EPI_example()     # example EPI sequence

sim_params = km.KomaMRICore.default_sim_params()
sim_params["return_type"] = "mat"        # return the raw signal matrix

raw = km.simulate(obj, seq, sys, sim_params=sim_params)
signal = np.asarray(raw)

print(signal.shape)

A runnable version lives in examples/.

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.

Currently supported: the core simulation pipeline and reading Pulseq files.

Planned: GPU backend selection, tighter pypulseq integration, and differentiable workflows.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

komamripy-0.0.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

komamripy-0.0.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file komamripy-0.0.3.tar.gz.

File metadata

  • Download URL: komamripy-0.0.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for komamripy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d60a61430569bbb837233f5241085fd3c63aef998b2b07f41f49f53c542fded7
MD5 eaa211f2fea9f3648a1132bc8da37018
BLAKE2b-256 f164decde60826649a238aa1b38e63c8f44f682cf92421068c320b51846732b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for komamripy-0.0.3.tar.gz:

Publisher: publish.yml on JuliaHealth/komamripy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file komamripy-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: komamripy-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for komamripy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5af7f0bc3d8731ab763245f779cf9c242f35d5e9a6b3d9160cd9af3f767f4ab3
MD5 fa0a5b0aa140c4bc2fe218861fb73ac8
BLAKE2b-256 a997aba3d7dc65360de143853d6fa8d11affc75622dea2bd1d4aad2574dfbca9

See more details on using hashes here.

Provenance

The following attestation bundles were made for komamripy-0.0.3-py3-none-any.whl:

Publisher: publish.yml on JuliaHealth/komamripy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page