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.
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:
- the event handlers that say how excitation, refocusing, inversion, saturation, readout and delay commands are interpreted; and
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.
Related projects
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.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| blochsim-0.0.9.tar.gz | 20.6 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| blochsim-0.0.9-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| blochsim-0.0.9-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| blochsim-0.0.9-cp310-abi3-musllinux_1_2_aarch64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ ARM64 | Details |
| blochsim-0.0.9-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| blochsim-0.0.9-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64, Linux glibc 2.27+ ARM64 | Details |
| blochsim-0.0.9-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| blochsim-0.0.9-cp310-abi3-macosx_10_9_x86_64.whl | CPython 3.10 | abi3 | macOS 10.9+ x86-64 | Details |
Total release size: 33.2 MB
Release files / blochsim-0.0.9.tar.gz
| Download URL | blochsim-0.0.9.tar.gz |
|---|---|
| Size | 20.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8765a4273d17fbc96c133d83b1103e0bda28ddb95ecf28fa08446bad2aef612e
|
|
BLAKE2b-256 checksum How to use checksums |
cc9d17f7cb26ff49b5b011149e195ba3b289085489f05bb27c351d9e9fa1910b
|
| 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 6, 2026.
Transparency logRelease files / blochsim-0.0.9-cp310-abi3-win_amd64.whl
| Download URL | blochsim-0.0.9-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
decb6a4b4754ff5515c1a3b9041716d212adf105b615aec672a2603e2f90e389
|
|
BLAKE2b-256 checksum How to use checksums |
d08148061aa2201a93cce71c889b302a90c5b59420c2d7eead016f5d28522f13
|
| 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 6, 2026.
Transparency logRelease files / blochsim-0.0.9-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | blochsim-0.0.9-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7e97618448100d37901ba090a0e270249862313f369dfe1183de04fc777449f3
|
|
BLAKE2b-256 checksum How to use checksums |
46ea3915b518a30d8b2b25e5ea7e69db1edad09d1f8f7b7a50fb5f8c7394667e
|
| 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 6, 2026.
Transparency logRelease files / blochsim-0.0.9-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | blochsim-0.0.9-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
49eb54d8122745daa708f0896eb9681ccd491f593ffb513ef5f037c9e8cd0eaf
|
|
BLAKE2b-256 checksum How to use checksums |
d3f6bb84fd2819b0fb79a42cae04e7559f9cf7bbb520428805d0fe0c233de5b9
|
| 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 6, 2026.
Transparency logRelease files / blochsim-0.0.9-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | blochsim-0.0.9-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.0 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 |
b6a9520d43a06199bef280a21d6781ca102d5e6732900f15628b1b405d0953a1
|
|
BLAKE2b-256 checksum How to use checksums |
b32f451d8abec30f66ce93535a02ce133e197bc83022b790808bd7d7c7ae47d3
|
| 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 6, 2026.
Transparency logRelease files / blochsim-0.0.9-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | blochsim-0.0.9-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
918f32bafffd3b86a0685ce54d445f5b320ff5fa41a6b10e8e7c34fa8ac986a3
|
|
BLAKE2b-256 checksum How to use checksums |
35d67d5ef97c91f175967bb0edeab32a74acc4d0ea62de50daffde6ef5a0b1bd
|
| 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 6, 2026.
Transparency logRelease files / blochsim-0.0.9-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | blochsim-0.0.9-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
204902e88d61a47b629d49bb945ad093082e5e456136a4dadfc3266ace60634b
|
|
BLAKE2b-256 checksum How to use checksums |
8882590650dfddfaf8c2f20cbb0536f009e3870814a36ab95d016fb3599087ff
|
| 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 6, 2026.
Transparency logRelease files / blochsim-0.0.9-cp310-abi3-macosx_10_9_x86_64.whl
| Download URL | blochsim-0.0.9-cp310-abi3-macosx_10_9_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.10 abi3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
02152f5c96b36824a18a517160ccd7cd5666b4334c1be4fe8840f12be881e778
|
|
BLAKE2b-256 checksum How to use checksums |
b5ff238f4168926bb09e876490c479d71dcaaa83df840be9ed5f83e6ee443e07
|
| 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 6, 2026.
Transparency log