Skip to main content
blochsim

BlochSim

BlochSim is a differentiable MR signal simulator built on PyTorch, with closed-form signal models and a fused extended-phase-graph (EPG) state machine for pulse trains.

codecov Tests Lint License Documentation PyPi Ruff PythonVersion

What it provides

  • Vectorized signal simulation over voxels/atoms on CPU and NVIDIA GPU.
  • Forward-mode Jacobians with respect to tissue properties and reverse-mode differentiation with respect to sequence parameters.
  • Closed-form models and an EPG state machine with relaxation, off-resonance, diffusion, flow, transmit variation, magnetization transfer and chemical exchange.
  • Parameter inference, model-based reconstruction and sequence-design tools written against the same simulator interface.
  • Pulseq and MRD sequence-description input, so the same sequence model can be used offline or driven from a scanner stream.

Installation

Install the PyTorch build appropriate for your machine first, then BlochSim:

pip install blochsim

See the User Guide for CPU, CUDA, macOS and source-build details.

Basic usage

The central public object is a Simulator. A shipped simulator fixes the sequence; simulate and jacobian evaluate it over the tissue you pass:

import numpy as np
from blochsim.simulators import MRFSimulator

flip = np.concatenate(
    (np.linspace(5.0, 60.0, 300), np.linspace(60.0, 2.0, 300), np.full(280, 2.0))
)
sequence = MRFSimulator(flip=flip, TR=10.0)

signal, jacobian = sequence.jacobian(
    ("T1", "T2"),
    T1=1000.0,
    T2=100.0,
)

Functional helpers such as blochsim.mrf_sim(...) remain convenient for one-off calls. The class interface is the canonical one for reusable models, parameter estimation, reconstruction, optimization, Pulseq input and scanner descriptions.

Implementing a sequence

Subclass blochsim.model.Simulator. For a state-machine sequence you define:

  1. the event handlers that say how excitation, refocusing, inversion, saturation, readout and delay commands are interpreted; and
  2. layout(), which returns those operators in order for offline use.

An incoming Pulseq/MRD description already supplies the layout, so Simulator.from_description() replays its commands through the same handlers. That gives offline design and scanner-driven simulation one public sequence abstraction.

The executable Framework course walks through the complete pattern.

Development

git clone git@github.com:pulserver/blochsim
cd blochsim
pip install -e ".[dev]"
pre-commit install

The install compiles the two C++ kernels, so it needs a C++17 compiler. CMake and Ninja arrive as build-time dependencies. pre-commit runs the same Ruff format/lint checks as CI.

The documentation's Related projects page places BlochSim among other MR simulators and links to the relevant packages and literature.

Metadata

Release files for blochsim 0.0.10

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

Source distribution (sdist)

Source distribution for blochsim 0.0.10
File Size Uploaded
blochsim-0.0.10.tar.gz 20.7 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for blochsim 0.0.10
File
blochsim-0.0.10-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
blochsim-0.0.10-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
blochsim-0.0.10-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
blochsim-0.0.10-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
blochsim-0.0.10-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details
blochsim-0.0.10-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
blochsim-0.0.10-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details

Total release size: 32.6 MB

Release files / blochsim-0.0.10.tar.gz

Download URL blochsim-0.0.10.tar.gz
Size 20.7 MB
Tags Source
SHA-256 checksum
How to use checksums
b3f732cdc7655ebb8e058c4ec70a48c39e5c97e4d2c51d9f2b3efbcc134bb81e
BLAKE2b-256 checksum
How to use checksums
157b7caac4ed0b01d54fd3f313b736818381cc1d950e264b49e14016a426f997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release files / blochsim-0.0.10-cp310-abi3-win_amd64.whl

Download URL blochsim-0.0.10-cp310-abi3-win_amd64.whl
Size 928.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5dc5c7b88fc37de012ba14882002aa688a688c799d3938eabbbbb5abf31cc314
BLAKE2b-256 checksum
How to use checksums
15fb1f0520421500ce3a47210f0049ad7c5fd281cf2917d8ec6edf5354cbd3e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release files / blochsim-0.0.10-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL blochsim-0.0.10-cp310-abi3-musllinux_1_2_x86_64.whl
Size 2.7 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
34a6f60a1b6400226a8ba8abc518be3c14ec17ef7a39791e0c5857b4bfeaba6b
BLAKE2b-256 checksum
How to use checksums
71f6bc01bac87514c724df3e210b808f9a9d6323ec918bff31e7b712c620ced5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release files / blochsim-0.0.10-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL blochsim-0.0.10-cp310-abi3-musllinux_1_2_aarch64.whl
Size 2.5 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d624ac229cbf319c628307a1e53fdcdf8387a9b9f6c6cdd19d7e0cb1827cfa31
BLAKE2b-256 checksum
How to use checksums
c67774120361a71214449105b2deb720add165d2dfecc8dda18eaada98afd599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release files / blochsim-0.0.10-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL blochsim-0.0.10-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
1f567835f522aaa8b6e11499211b7632419504db5ed26192901e084fa09b1779
BLAKE2b-256 checksum
How to use checksums
fe3bf3ad74e1f1bd7c71182f2d2c12f1bc41072b102171a1a900693fd816ec3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release files / blochsim-0.0.10-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL blochsim-0.0.10-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
9f668d434ef9a84f56edd9942ab1915aa43c45ffac433b03ae2458d3402e414c
BLAKE2b-256 checksum
How to use checksums
5d2f6a3be9646e89021dc30040d1e07634fe32c23f3f4ad7a54e5d8736781e74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release files / blochsim-0.0.10-cp310-abi3-macosx_11_0_arm64.whl

Download URL blochsim-0.0.10-cp310-abi3-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
db4f6985d67cf160d576475fec8120783196ff2e8dcae5616cf829f3e47b63c8
BLAKE2b-256 checksum
How to use checksums
b8f4c9bf3af494627f79e1c0bd5b166e42a8a995bf1d5d1932eb5a2022562c06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release files / blochsim-0.0.10-cp310-abi3-macosx_10_9_x86_64.whl

Download URL blochsim-0.0.10-cp310-abi3-macosx_10_9_x86_64.whl
Size 1.2 MB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
e89ba11012f529569b239e2c8e8529b3ab61c53e0894e03ce327a0e9561e6468
BLAKE2b-256 checksum
How to use checksums
977ca8c63cd51eb5a159ff074929d4687f584f511ed93a9a41ba7c919ad0fe96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.0.14

8 release files

0.0.13

8 release files

0.0.12

8 release files

0.0.11

8 release files

This release

0.0.10 This release

8 release files

0.0.9

8 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