Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- 1.4.0
- requires Python >= 3.10 again (was >= 3.12), now that `bifti` 0.3.1 supports Python 3.10; tested on Python 3.10 - 3.15
- `scikit-image` and `torchkbnufft` are no longer installed by default (they are not used by MRzeroCore itself); install them with `pip install mrzerocore[playground]`
- `ismrmrd` is now an optional dependency, only needed for `sig_to_mrd`: install it with `pip install mrzerocore[mrd]`. Without it, `sig_to_mrd` raises an `ImportError`; everything else works. This avoids building `h5py` from source where no wheels exist (e.g. Python 3.15)
- `numpy` is now a declared dependency; minimum versions: `bifti>=0.3.1`, `nibabel>=5.2`, `numpy>=1.22`, `ismrmrd>=1.14.1` (with `[mrd]`)
- 1.3.0
- use the official [`bifti`](https://pypi.org/project/bifti/) package for BIfTI phantoms instead of the internal implementation (#201). `NiftiPhantom`, `NiftiTissue` and `ResliceConfig` are now aliases of `bifti.BiftiPhantom`, `bifti.BiftiTissue` and `bifti.ResliceTo`; `TissueDict.load` uses the `bifti` loader (density-weighted resampling, `patient` position support, complex B1 maps, `func` mappings are parsed instead of `eval`ed)
- `TissueDict.save` uses `bifti.NumpyPhantom.save`: NIfTIs are named `<json name>_<property>.nii.gz` (e.g. `phantom_B1plus_0.nii.gz`) and stored as float64 / complex128; the `.json` no longer contains `reslice_to`
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mrzero_core"
version = "1.3.0"
version = "1.4.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 2 additions & 0 deletions documentation/src/api-unsorted.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The configuration files with the used tissue parameters can be found here: [brai

Write the simulation output to an [ISMRMD](https://github.com/ismrmrd/ismrmrd) file; supported by many reconstruction tools.

Requires the optional `ismrmrd` dependency: `pip install mrzerocore[mrd]`.

| Parameter | Description |
| --------- | ----------- |
| `mrd_path` | path where the file will be written to |
Expand Down
26 changes: 18 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "mrzerocore"
version = "1.3.0"
version = "1.4.0"
description = "Core functionality of MRzero"
authors = [
{name = "Jonathan Endres", email = "[email protected]"},
Expand All @@ -13,29 +13,39 @@ readme = "README.md"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: GNU Affero General Public License v3",
]
requires-python = ">=3.12"
requires-python = ">=3.10"
dependencies = [
"bifti>=0.3.0",
"ismrmrd",
"bifti>=0.3.1",
"matplotlib>=3.5",
"nibabel>=5.2",
"numpy>=1.22",
"pydisseqt>=0.1.13",
"pypulseq",
"pypulseq",
"requests>=2.20",
"scikit-image",
"scipy>=1.7",
"torchkbnufft",
"torch>=1.12",
"tqdm",
"nibabel",
]

# --- OPTIONAL INSTALLS ---
[project.optional-dependencies]
# to select pypulseq 1.4 or <1.5 use pip install mrzerocore[pp14]
pp15 = ["pypulseq"]
# ISMRMRD export (mr0.sig_to_mrd); optional because h5py lacks wheels for some environments
mrd = ["ismrmrd>=1.14.1"]
# Not used by MRzeroCore itself, only by some of the playground notebooks
playground = ["scikit-image", "torchkbnufft"]

[project.urls]
Repository = "https://github.com/MRsources/MRzero-Core"
Expand Down
4 changes: 2 additions & 2 deletions python/MRzeroCore/phantom/tissue_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import numpy as np
import matplotlib.pyplot as plt
from typing import Literal, Self
from typing import Literal


class TissueDict(dict[str, VoxelGridPhantom]):
Expand Down Expand Up @@ -158,7 +158,7 @@ def build(self, PD_threshold: float = 1e-6,

return SimData(**kwargs)

def recover(self, sim_data: SimData) -> Self:
def recover(self, sim_data: SimData) -> "TissueDict":
"""Provided to :class:`SimData` to reverse the ``build()``"""

assert sim_data.tissue_masks is not None
Expand Down
32 changes: 24 additions & 8 deletions python/MRzeroCore/simulation/sig_to_mrd.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
from __future__ import annotations

import os

import ismrmrd
import numpy as np
import pypulseq as pp
import torch
from tqdm import tqdm

# ismrmrd (and its h5py dependency) is an optional dependency, only needed for
# MRD export: install with `pip install mrzerocore[mrd]`.
try:
import ismrmrd
except ImportError as e:
ismrmrd = None
_ISMRMRD_IMPORT_ERROR = e

# Pulseq ADC label -> name of the ISMRMRD acquisition flag
PULSEQ_MRD_FLAGS = {
"NAV": ismrmrd.ACQ_IS_PHASECORR_DATA,
"REV": ismrmrd.ACQ_IS_REVERSE,
"REF": ismrmrd.ACQ_IS_PARALLEL_CALIBRATION,
"IMA": ismrmrd.ACQ_IS_PARALLEL_CALIBRATION_AND_IMAGING,
"NOISE": ismrmrd.ACQ_IS_NOISE_MEASUREMENT,
"PMC": ismrmrd.ACQ_IS_RTFEEDBACK_DATA,
"NAV": "ACQ_IS_PHASECORR_DATA",
"REV": "ACQ_IS_REVERSE",
"REF": "ACQ_IS_PARALLEL_CALIBRATION",
"IMA": "ACQ_IS_PARALLEL_CALIBRATION_AND_IMAGING",
"NOISE": "ACQ_IS_NOISE_MEASUREMENT",
"PMC": "ACQ_IS_RTFEEDBACK_DATA",
}


Expand All @@ -38,6 +48,12 @@ def sig_to_mrd(
verbose : int, optional
Logging verbosity level from 0 (silent) to 5 (most detailed). Default is 0.
"""
if ismrmrd is None:
raise ImportError(
"sig_to_mrd requires the optional 'ismrmrd' package: "
"pip install mrzerocore[mrd] (or: pip install ismrmrd)"
) from _ISMRMRD_IMPORT_ERROR

# Convert signal tensor to NumPy for ISMRMRD compatibility
mr0_signal_numpy = mr0_signal.detach().cpu().numpy()

Expand Down Expand Up @@ -233,7 +249,7 @@ def _labels_to_acq_head(
for key, item in PULSEQ_MRD_FLAGS.items():
label_value = seq_labels.get(key, 0)
if label_value > 0:
acq_head.set_flag(item)
acq_head.set_flag(getattr(ismrmrd, item))

return acq_head

Expand Down
Loading