Skip to content

JuliaHealth/komamripy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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.

Installation

komamripy is in early development and is not yet on PyPI. Install it from source.

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

Install by using uv (recommended) or pip (remove uv):

uv pip install git+https://github.com/JuliaHealth/komamripy

The first import downloads Julia and precompiles KomaMRI, which can take a few minutes. Subsequent runs are fast.

Quick start

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/.

Pulseq compatibility

KomaMRI reads Pulseq .seq files, so komamripy can simulate sequences produced by any Pulseq tool, including pypulseq:

seq = km.read_seq("sequence.seq")
raw = km.simulate(obj, seq, sys)

Status

komamripy is under active development as a Google Summer of Code project.

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

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

About

Pulseq-compatible, high-performance MRI simulations in Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages