MRFlow: Report-Conditioned Autoregressive Flow Matching for Variable-Length 3D Brain MRI
Overview
MRFlow is a report-conditioned autoregressive flow-matching model for multi-sequence, multi-plane 3D brain MRI generation. A Spatial-Temporal DiT generates the series block by block in FLUX-VAE latent space, so the series length is not fixed. Each block is conditioned jointly on the previous block, the report (at the token and pooled level), the sequence type and the acquisition plane. The report is encoded by NeuroBERT fine-tuned on MR-RATE reports, and hierarchical classifier-free guidance is applied over sequence type and report.
This repository holds the MRFlow denoiser and the fine-tuned NeuroBERT text encoder.
Results
Image quality on 1,000 MR-RATE test series (100 per sequence-plane combination), ± bootstrap standard deviation. cfg: guidance scales for sequence/report.
| Method | FVD16 ↓ | FVD64 ↓ | FID-2D ↓ | FID-2.5D ↓ |
|---|---|---|---|---|
| NV-Generate-MR-Brain | 282.8 ± 13.5 | 547.0 ± 21.9 | 21.13 ± 0.52 | 0.454 ± 0.015 |
| WARP-MR, cfg 5 | 229.6 ± 10.4 | 320.4 ± 10.1 | 38.15 ± 0.53 | 0.120 ± 0.004 |
| Report2MRI, cfg 10/4 | 194.6 ± 5.5 | 454.5 ± 14.3 | 25.70 ± 0.40 | 0.827 ± 0.032 |
| Text2CT, cfg 10 | 222.6 ± 10.0 | 353.3 ± 13.2 | 16.15 ± 0.35 | 0.203 ± 0.006 |
| CCELLA, cfg 4 | 177.8 ± 8.7 | 306.3 ± 12.8 | 22.60 ± 0.71 | 0.395 ± 0.018 |
| CTFlow, cfg 1/1 | 171.4 ± 9.8 | 203.8 ± 10.4 | 21.16 ± 0.38 | 0.190 ± 0.006 |
| MRFlow, cfg 1/1 | 101.1 ± 6.4 | 140.9 ± 8.1 | 14.12 ± 0.30 | 0.159 ± 0.005 |
| MRFlow, cfg 3/3 | 78.3 ± 5.4 | 102.9 ± 6.1 | 10.55 ± 0.25 | 0.154 ± 0.006 |
Pathology classification (14 MR-RATE groups): a 3D classifier is trained on real and/or MRFlow-generated series (generated from the same 4,000 training reports) and always tested on 4,879 real test studies. Macro AUROC [95% CI], and the difference to training on 4,000 real series.
| Classifier training data | AUROC ↑ | ΔAUROC ↑ |
|---|---|---|
| 4,000 real | 0.701 [0.689, 0.712] | – |
| 4,000 generated | 0.707 [0.695, 0.718] | +0.006 [−0.003, +0.017] |
| 4,000 real + conventional augmentation | 0.717 [0.707, 0.728] | +0.016 [+0.009, +0.024] |
| 4,000 real + 4,000 generated | 0.731 [0.720, 0.742] | +0.030 [+0.023, +0.040] |
| 69,436 real (upper bound) | 0.800 [0.790, 0.809] | +0.099 [+0.087, +0.112] |
Files in this repository
| File | Contents |
|---|---|
denoiser_ema/ |
MRFlow denoiser (EMA weights) |
config.yaml |
Model configuration (configs/mrflow.yaml in the code) |
null_text.pt |
Encoded empty report, the null condition for report guidance |
neurobert-mlm-rsm/ |
NeuroBERT fine-tuned on MR-RATE reports, with its license and notice |
SHA256SUMS |
Checksums |
The FLUX VAE is not included (see Usage).
Usage
The FLUX VAE comes from FLUX.1-schnell,
a gated repository: accept its license on the model page and log in with hf auth login first.
git clone https://github.com/teodoraspasojevic/MRFlow && cd MRFlow
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
export PYTHONPATH=$PWD
# MRFlow denoiser, config and fine-tuned NeuroBERT; FLUX VAE
hf download teodora-spasojevic-fau/MRFlow --local-dir models/
hf download black-forest-labs/FLUX.1-schnell --include 'vae/*' --local-dir models/flux
sed -i "s#/path/to/flux-vae#$PWD/models/flux/vae#; s#null_text: .*#null_text: $PWD/models/null_text.pt#" models/config.yaml
Encode a report with the fine-tuned NeuroBERT, then generate:
import torch
from mrflow.text import load_neurobert, encode_neurobert_tokens
model, tokenizer = load_neurobert("cuda")
report = {"findings": "...", "impression": "..."}
torch.save(encode_neurobert_tokens(model, tokenizer, report), "report.pt")
python scripts/generate.py --config models/config.yaml --ckpt models/denoiser_ema \
--embedding report.pt --modality FLAIR --plane AXIAL \
--modality-cfg-scale 3 --report-cfg-scale 3 --output out/
A GPU is required.
Training
- Data. MR-RATE series are reoriented to RAS, resampled to 1 mm, normalized to [0, 1], cropped to 256 × 256 in-plane and VAE-encoded. Blank slices coming from MR-RATE defacing are trimmed.
- Denoiser. From scratch, 180k steps on 64 H200 GPUs, effective batch size 2,048.
- Text encoder. NeuroBERT was trained further on MR-RATE training reports with masked language modelling, then with findings/impression matching (40k steps, lr 1e-6). The checkpoint was chosen by held-out training-report loss, not by any generation or test score.
License and attribution
- These weights (denoiser and fine-tuned NeuroBERT): CC BY-NC-SA 4.0. They are trained on MR-RATE, which is released under CC BY-NC-SA 4.0, so non-commercial use and share-alike apply.
- NeuroBERT: the base model by Wood et al. is under Apache-2.0.
neurobert-mlm-rsm/is a modified version of it; the Apache license text and a notice of the changes are included there. - Code: Apache-2.0 (see the GitHub repository).
- FLUX VAE: Apache-2.0, not redistributed here.
- Dataset: MR-RATE, CC BY-NC-SA 4.0.
MRFlow builds on CTFlow. We thank the authors of MR-RATE, NeuroBERT and FLUX for releasing their data and models.
Citation
TBA
Please also cite CTFlow:
@InProceedings{Wang_2025_ICCVW,
author = {Wang, Jiayi and Reynaud, Hadrien and Erick, Franciskus Xaverius and Kainz, Bernhard},
title = {CTFlow: Video-Inspired Latent Flow Matching for 3D CT Synthesis},
booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) Workshops},
year = {2025},
}
and MR-RATE:
@misc{mrrate,
title = {{MR-RATE}},
author = {{Forithmus}},
year = {2026},
url = {https://huggingface.co/datasets/Forithmus/MR-RATE},
}
- Downloads last month
- -
Model tree for teodora-spasojevic-fau/MRFlow
Base model
davvwood/NeuroBERT