Pulseq-based 3D Wave-MPRAGE sequence generation with an integrated FLASH wave-calibration module and Python reconstruction utilities.
The repository has two intentionally separate parts:
- MATLAB generates the integrated MPRAGE + FLASH calibration sequence.
- Python reconstructs Wave-MPRAGE or no-wave MPRAGE data from the resulting Siemens TWIX measurement.
pyproject.toml is used only to define the Python reconstruction environment. This repository is not configured as an installable Python package and does not need to be published to PyPI.
.
├── README.md
├── pyproject.toml
├── uv.lock
├── .python-version
├── docs/
│ ├── sequence.md
│ ├── reconstruction.md
│ └── troubleshooting.md
├── seq/
│ ├── mprage_3d_wave_with_flash_calibration.m
│ └── utils/
├── recon/
│ ├── recon_wave_mprage_from_twix_integrated_nifti.py
│ ├── bart/
│ │ ├── run_wave_recon.sh
│ │ ├── run_cartesian_recon.sh
│ │ ├── wave_to_nifti.py
│ │ └── bart_utils/
│ ├── tests/
│ └── utils/
└── external/
The recommended entry points are:
seq/mprage_3d_wave_with_flash_calibration.m
recon/recon_wave_mprage_from_twix_integrated_nifti.py
- MATLAB
- Pulseq MATLAB toolbox
Optional scanner-safety checks can use Safe PNS Prediction, a scanner .asc file, and an existing forbiddenFreqCheck.m helper.
- Python 3.11
- CPU reconstruction environment defined in
pyproject.toml - GPU-enabled BART and an NVIDIA GPU for the default BART reconstruction path
- Optional CUDA 12-compatible CuPy only for GPU SigPy ESPIRiT in the explicit SENSE path
The current execution model is:
| Step | Device |
|---|---|
| Coil-compression matrix estimation and application | CPU |
| Default sensitivity-map calibration | BART ecalib; SigPy ESPIRiT is skipped |
| Default Wave reconstruction | BART GPU wavelet/FISTA (-w -f -g) |
| Default no-wave reconstruction | BART Cartesian GPU PICS (-l1 -r 1e-5 --fista -i 300 -g -S) |
| Explicit legacy Wave/no-wave CG-SENSE | CPU |
The default BART backend requires a BART build with GPU support. It invokes
bart wave -w -f -g for Wave acquisitions and bart pics ... -g for no-wave
Cartesian acquisitions. SigPy-specific ESPIRiT device, mode, and worker options
apply only when --reconstruction-backend sense is selected;
--espirit-crop configures either BART ecalib or SigPy, according to the
selected reconstruction backend. Use --coil-compression-channels N to retain
a non-default number of virtual coils; --vcc-channels and --ncc are aliases.
The default remains 12. Use --no-vcc (alias --no-coil-compression) to retain
all physical receiver channels without SVD compression; this can substantially
increase BART memory use.
git clone --recurse-submodules https://github.com/HarmonizedMRI/wave-mprage.git
cd wave-mprageInstall uv, then create the locked CPU-capable environment:
uv sync --lockedRun commands inside the environment with uv run:
uv run python recon/recon_wave_mprage_from_twix_integrated_nifti.py --helpTo include CUDA 12 CuPy for GPU-assisted ESPIRiT:
uv sync --locked --group gpuThe committed uv.lock records the exact resolved Python dependency versions. The host NVIDIA driver and GPU remain system requirements and are not contained in the lockfile.
pip 25.1 or newer can install the same standardized dependency groups directly from pyproject.toml:
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade "pip>=25.1"
python -m pip install --group reconFor CUDA 12 CuPy:
python -m pip install --group gpuThe pip route resolves compatible versions at installation time. Use uv sync --locked when exact lockfile reproduction is important.
Open MATLAB and run:
cd seq
mprage_3d_wave_with_flash_calibrationOn the first run, enter the requested paths. The helper stores machine-specific path settings in a local JSON file. Leaving the output path blank uses MATLAB's current folder.
Generated sequence files are written under:
generated_seq_v141/
generated_seq_v151/
See Sequence generation for acquisition order, TWIX routing, calibration SET layout, path handling, and validation.
Before scanning, turn off the neck-coil elements and prescribe an FOV that covers the complete signal-producing volume. Out-of-FOV neck or shoulder signal can contaminate the projection calibration, and wave-induced aliasing from anatomy outside the encoded FOV cannot be fully resolved.
The integrated measurement is expected to contain:
image -> MPRAGE k-space
refscan -> four FLASH PSF-calibration sets plus the ACS set
Review all arguments:
uv run python recon/recon_wave_mprage_from_twix_integrated_nifti.py --helpThe preferred input interface uses direct paths:
--twix integrated Siemens TWIX .dat file
--seq matching integrated Pulseq .seq file
--out reconstruction output directory
--wave-mode auto, wave, or nowave; default auto
--wave-mode auto inspects the MPRAGE imaging trajectory after excluding the appended FLASH calibration and ACS trajectory. It selects wave when both wave axes are active and nowave when both are inactive. One-axis wave acquisitions are rejected.
Example reconstruction with automatic wave-mode detection, automatic ESPIRiT device selection, and NIfTI export:
uv run python recon/recon_wave_mprage_from_twix_integrated_nifti.py \
--twix /path/to/data/meas_integrated_wave_mprage.dat \
--seq /path/to/data/mprage_3d_flashcalib_wave.seq \
--out /path/to/output \
--wave-mode auto \
--file-tag test01 \
--espirit-device auto \
--save-nifti-phasePSF coefficient processing remains smooth by default. To opt into the
automatic sine-plus-line fit, select sine-line without supplying manual kx
bounds:
uv run python recon/recon_wave_mprage_from_twix_integrated_nifti.py \
--twix /path/to/data/meas_integrated_wave_mprage.dat \
--seq /path/to/data/mprage_3d_flashcalib_wave.seq \
--out /path/to/output \
--wave-mode wave \
--psf-coefficient-processing sine-lineAutomatic mode uses calibration quality and coefficient stability to choose
one shared half-open fit interval for a(kx), b(kx), and c(kx). It uses a
near-global interval for stable data and a center-containing interval when it
detects sustained coefficient corruption. Supply both --psf-fit-kx-min and
--psf-fit-kx-max to override the automatic interval reproducibly. See
PSF coefficient processing
for the selection, validation, diagnostics, and failure contracts.
Wave acquisitions export the calibrated PSF, coil-compressed k-space, and
integrated ACS as BART CFL pairs by default. No-wave acquisitions first remove
fourfold readout oversampling by centered IFFT, central image-domain crop, and
centered FFT, then export Cartesian k-space without a PSF. Both paths skip
SigPy ESPIRiT, run BART ecalib, and then run GPU wavelet/FISTA reconstruction.
Select
--reconstruction-backend sense only when the traditional local CG-SENSE
solver is required. The companion recon/bart/run_wave_recon.sh script can
also be run independently; see
Reconstruction for the
exact dimensions and command. It converts results with python from the active
Conda environment or virtual environment, and writes NIfTIs to
BART_OUTPUT/nifti unless --skip-nifti or an override is supplied. Magnitude
NIfTI export is enabled by default in the integrated command; use
--no-save-nifti to disable it. A rerun with the same TWIX, sequence, output
directory, and tag automatically reuses complete, current BART maps and images.
If BART was killed after input export, validated modern BART inputs skip TWIX
preprocessing and resume missing maps or images in place. --resume may be
passed explicitly; use --no-resume to force reconstruction. Complete legacy BART
outputs without source-path provenance are validated and upgraded in place on
their first resumed run.
For lightweight sensitivity-support inspection without TWIX or sequence metadata, convert BART maps in their unchanged logical axis order:
python recon/bart/csm_to_nifti_local.py \
--csm /path/to/coil_sens_bart \
--out /path/to/coil_sens_bart_rss.nii.gz \
--voxel-size 0.64 0.64 0.64This diagnostic NIfTI uses a synthetic affine and must not be interpreted as having correct anatomical orientation.
Force CPU ESPIRiT while explicitly requiring wave reconstruction:
uv run python recon/recon_wave_mprage_from_twix_integrated_nifti.py \
--twix /path/to/data/meas_integrated_wave_mprage.dat \
--seq /path/to/data/mprage_3d_flashcalib_wave.seq \
--out /path/to/output \
--wave-mode wave \
--espirit-device cpuUse --espirit-device gpu --espirit-gpu-index 0 to require a specific GPU. The script raises a clear error instead of silently falling back when GPU mode is explicitly requested.
The calibration backend is selected independently of the Wave-MPRAGE forward model:
| Argument | Behavior |
|---|---|
--espirit-calib-mode 3d |
Native joint 3D SigPy ESPIRiT; default and reference mode; CPU or GPU |
--espirit-calib-mode slice2d |
CPU-parallel 2D ESPIRiT over logical-RO hybrid-space slices |
The slice2d backend receives the logical low-resolution ACS after the existing readout-oversampling removal. It inverse-transforms logical RO and calibrates each joint LIN-PAR plane independently, preserving both accelerated phase-encoding dimensions within every 2D calibration.
A practical CPU-parallel example is:
uv run python recon/recon_wave_mprage_from_twix_integrated_nifti.py \
--twix /path/to/data/meas_integrated_wave_mprage.dat \
--seq /path/to/data/mprage_3d_flashcalib_wave.seq \
--out /path/to/output \
--wave-mode auto \
--coil-compression-channels 16 \
--espirit-device cpu \
--espirit-calib-mode slice2d \
--espirit-crop 0.8--espirit-crop is valid for both reconstruction backends. The integrated
Python command passes it to BART as ecalib -c VALUE; the lower-level
--ecalib-options ... --end-ecalib-options syntax belongs only to
recon/bart/run_wave_recon.sh and is not a top-level Python option. Testing
with the current Wave-MPRAGE implementation found 0.8–0.9 to be a reasonable
practical range: 0.8 retains somewhat broader low-SNR support, while 0.9
applies a stricter support mask. Inspect the saved CSM magnitude and phase
plots for each acquisition.
When --espirit-cpu-workers is omitted, slice2d automatically uses the available physical-core count, capped by the number of logical-RO slices. Set it explicitly when sharing a machine, limiting memory use, or benchmarking, for example:
--espirit-cpu-workers 16
See Troubleshooting for Linux CPU inspection with lscpu, worker-count guidance, and crop-related checks.
The following compatibility aliases remain accepted:
| Preferred argument | Compatibility aliases |
|---|---|
--twix |
--mprage-data-file |
--seq |
--mprage-seq-file |
--out |
--out-folder |
--wave-mode |
--mode, --tag-wave |
The old shared --data-folder argument is no longer needed because --twix and --seq accept direct absolute or relative paths.
See Reconstruction for the pipeline, ESPIRiT calibration modes, crop and CPU-worker behavior, input assumptions, complete command-line interface, output files, and NIfTI conventions. The reconstruction guide also documents the optional smooth and sine-line PSF coefficient-processing modes; troubleshooting guidance explains CPU sizing with lscpu, crop/support checks, sine-line use, and safe reuse of an existing mode-specific coil calibration.
MIT License. See LICENSE.