alphaFeedback

WorksEngineering

Measure Before You Repair: An Explainable Agent for Blind Restoration of Multi-Artifact 3-D MRI

AI contributions
Not recorded for this paper
View details

Abstract

A brain MRI scan can carry an unknown mix of artifacts, so restoration has to be blind, yet most deep-learning methods are built to correct one known artifact. We present Dx-Rx, an agent in which a multimodal large language model (MLLM) measures suspected artifacts before it repairs them. To our knowledge, it is the first agent to restore whole 3-D MRI volumes, whereas earlier MRI agents restore 2-D slices. In a loop, it looks at slices of the 3-D volume, calls five diagnostic tools (noise, spike, ghosting, bias field, motion) and four restoration tools in any order it chooses, checks each repair, can return to any earlier version to change the order, and ends with a radiology-style report of its diagnostic reasons, the repairs it applied and their results. We simulated up to five artifacts on 148 whole 3-D T1-weighted volumes, at levels calibrated to radiologists' grades of real scans. An MLLM that only looked at the image, as earlier MRI agents do, removed at most 19.7 % of the artifact error. With the best of five MLLMs, Dx-Rx removed a mean 64.5 %, nearly matching the 64.6 % of the same tools given the ground-truth artifacts, which are never known for a clinical scan. With all five models, it made no volume worse and was on par with or better than an expert rule-based pipeline built from the same tools (62.3 %). Code and demo are public at https://itu-biai.github.io/measure-before-you-repair.

Introduction

Artifacts from thermal noise, radio-frequency spikes, ghosting, coil shading (bias field) and head motion degrade brain MRI and can force a rescan [1, 2]. A scan may carry several of them at once, and which ones are present is not known in advance. The restoration has to be blind. Deep learning has been very successful at correcting one artifact, but such methods do not generalize beyond it, which limits them in the clinic where several occur together [3]. Running every repair on every scan is not safe: on our test set it made 11 volumes worse. An expert pipeline instead runs each repair only when an artifact is detected, in a fixed order. These rules are set by hand and stay fixed, so the pipeline cannot reorder its repairs when one interferes with another.

Agents built on large language models, which reason and call tools in a loop [4], offer another way. AgenticIR restores natural images with a language model that plans and reschedules and a vision-language model that judges quality [5]. For MRI, AgentMRI lets a vision-language model name the corruption and dispatch a restoration model [6]; MRI-AgentNet coordinates several such agents for motion, undersampling and noise [7]; ResMAP restores MRI with mixed artifacts by cascading prompt retrieval [3]. Yet AgentMRI and MRI-AgentNet only look, through a vision-language model, and such models are least reliable on mild degradations [8]. In MRI quality assessment, MMRQA grades a scan better when its vision-language model is informed by the scan’s global quality metrics [9].

We test the idea, measure before you repair, on whole 3-D volumes with up to five artifacts. Our main contributions are:

  • Dx-Rx, an MLLM agent that measures with diagnostic tools, repairs, checks each repair, and can return to any earlier version and change the order (see Figure 1).

  • To our knowledge, the first agent to restore whole 3-D MRI volumes. Earlier MRI agents restore 2-D slices [6, 7].

  • A radiology-style report that gives the measured evidence for each finding and explains each repair and its order, and is checked deterministically against the run log for hallucinations.

  • An ablation showing how much the diagnostic tools, the loop and a larger MLLM each add to the agent.

Figure 1. Dx-Rx. The MLLM receives one 3-D volume with unknown artifacts and a system prompt (excerpt, verbatim) and works in a diagnose–restore loop inspired by ReAct [4]: it calls tools on any version and reads their results (text and pictures) before deciding again.

Method

Dx-Rx receives one 3-D T1-weighted volume (192×240×240192 \times240 \times240 mm) that may contain any mix of five artifacts, or none, and nothing else: no clean scan, no artifact labels and no file name. Its system prompt (Figure 1) states the task, the scanner protocol (phase encoding along anterior–posterior, A–P), and that motion cannot be repaired: a rescan is advised when the motion tool returns 0.033 or more (an error of 3.3 % of white matter), the level at which a motion scan in the Movement-Related Artefacts (MR-ART) dataset [2] was likely to be judged unusable by radiologists as usable. It gives no order of repairs and no hints about the data.

The MLLM acts only through eleven tools and finish (Figure 1), each taking a version handle (v0v_0 is the input). Look returns slices from 3-D volumes and the MLLM sees 2-D views, while tools work on whole 3-D volumes. Compare returns the difference of two versions and its root mean square (RMS). Each of the five diagnostic tools says whether one artifact is present or absent, with a value, a confidence, a reason and a picture of its evidence. The noise tool estimates the standard deviation (σ\sigma) in flat tissue; the spike tool finds isolated bright points in k-space [10]; the ghosting tool finds faint copies of the head along A–P; the bias tool fits an N4 field [11] over the brain, found with HD-BET [12]; the motion tool measures head signal leaking into the air along A–P [1]. The four restoration tools remove spikes in k-space; put back the signal that ghosting moved along A–P; denoise with DRUNet [13], a Gaussian denoiser, at the measured σ\sigma slice by slice along each axis, averaging the three resulting volumes (Rician noise is near-Gaussian in tissue [14]); and divide out the N4 field. Each repair runs its diagnostic tool before and after, so the agent sees at once whether the artifact is gone. Figure 2 shows what the agent receives. Nothing is trained. The tools are classical methods or published weights, each with one threshold and one scale set on development volumes. Finish ends the run.

Figure 2. What the agent receives from a tool (t0100, GPT-6.1 Terra, shortened). A diagnostic tool returns whether its artifact is present, a value, a confidence, a reason and a picture of its evidence. A restoration tool returns the new version and its diagnostic tool’s new answer.

Dx-Rx runs a diagnose–restore loop inspired by ReAct [4] (Figure 1): the MLLM reasons, calls tools, reads their results (text and pictures) and decides again. Every version is kept and any tool can act on any version, so the agent can check a repair by measuring it again, compare two versions, and return to an earlier version to try another order, as AgenticIR reschedules after reflection [5].

Finish returns a version and a report under radiology headings, from examination to limits [15]. Each artifact gets a finding that starts with present, absent or uncertain and gives the evidence. The repairs are listed in order, with their reasons. A model’s explanation can differ from what it did [16], and a clinical report must not state anything the measurements do not support. Every report is therefore fact-checked deterministically against the run log: (a) the repairs it lists are the returned version’s history; (b) every number in its text was returned by a tool; (c) its written findings agree with its own yes/no answers. A report that passes all three is faithful.

Experiments

We used the public IXI T1-weighted scans (three hospitals, 1.5 T and 3 T) [17]. We computed each scan’s brain mask with HD-BET brain extraction [12], removed the coil shading with N4 [11], resampled each volume to 1 mm and scaled it to white matter = 1. Five artifacts were simulated on the whole volume as one 3-D acquisition, in physical order: a bias field, rigid motion as k-space segments of moved copies [18], ghosting and k-space spikes [10], then Rician noise [14] and the magnitude. Ghosting and spikes use TorchIO [19], with the image kept complex until the magnitude is taken.

Each artifact has three levels, mild, moderate and borderline, calibrated to real scans. For motion we used 30 MR-ART subjects [2], each scanned once still and twice while moving, and radiologists graded their 60 motion scans good (10), medium (17) or bad, i.e. unusable (33). For each motion scan, we measured how much its image entropy [20] rose over the same subject’s still scan. We then applied our motion to the same still scans at many strengths. The entropy rise grew linearly (r=0.92r = 0.92) with the damage we applied, defined as the RMS change over the brain as a fraction of white-matter intensity. From this linear fit, each real scan gets the damage at which our motion raises entropy by the same amount. On this damage scale, a quarter of the medium scans lay below 0.019, half below 0.028 and three quarters below 0.033, and half of the bad scans lay below 0.055. These four values bound the three levels: mild (0.019–0.028), moderate (0.028–0.033) and borderline (0.033–0.055). At 0.033, a real scan was as likely to be graded unusable as usable, so we set the agent’s rescan line there. Ghosting and spikes, which have no clinical grade, use motion’s damage scale; noise follows clinical noise grades (total σ\sigma 3.0–6.1 % of white matter) [21]; the bias stays within the fields N4 removed from IXI scans.

Four disjoint sets of IXI subjects were used. 10 calibrated the levels. 10 more, each with single artifacts, set each tool’s threshold and scale. 60 development volumes with mixed artifacts were used to develop the agent. The test set has 148 subjects, one volume each: 82 from Guy’s Hospital, 47 from Hammersmith Hospital and 19 from the Institute of Psychiatry. Five volumes have no artifact, 25 have one, 50 have two, 50 have three, 15 have four and 3 have all five. Each method ran on it once after the agent was frozen. The files are blind: the agent cannot learn anything from a file name or header since names are opaque and all volumes share one header, and no method sees the labels or the clean volumes.

The share of error removed is $1 - \lVert y - r \rVert/\lVert x - r \rVert$ inside the brain (HD-BET mask), for input xx, output yy and the clean volume rr. No tool repairs motion, so rr keeps the volume’s own simulated motion. The metric scores only what repairs can fix. It is defined for the 138 test volumes with a repairable artifact. For the other 10 (5 clean and 5 motion-only), the input already equals rr, so there is no error to remove. We report means ±\pm standard deviation (std). We also count volumes made worse, correct diagnoses (the yes/no for 5 artifacts ×\times 148 volumes), faithful reports, cost, PSNR and SSIM [22] inside the brain. Methods are compared per volume with the Wilcoxon signed-rank test [23], zero differences dropped, and Holm’s adjustment [24] across the models in each comparison.

Four questions organize the comparisons; Table 1 shows what each method can do. Q1: is an agent the smart choice? Apply-all runs the four repairs on every volume in the fixed order: spike, ghosting, noise, bias. The rule-based pipeline uses the same order but runs a repair only when its diagnostic tool says yes. Q2: how much can the restoration tools recover? The oracle pipeline runs the same repairs in the same order, but on the ground-truth artifacts instead of the diagnostic tools’ results. With the diagnosis perfect, it shows how much our restoration tools can recover. Q3: which component of the agent matters? In an ablation, three variants of Dx-Rx remove (i) both the loop and the diagnostic tools, (ii) only the loop, or (iii) only the diagnostic tools. Single pass, no diagnostic tools, as in AgentMRI [6]: the MLLM sees the three planes once and names the repairs, which run in the fixed order. Single pass + diagnostic tools: the previous variant plus the five diagnostic tools’ results on the input. Loop, no diagnostic tools: the Dx-Rx loop, which can look, compare and repair, but without its diagnostic tools’ answers. Q4: does a larger model help? We ran Dx-Rx with a smaller and a larger model of two families, Claude Haiku 5.5 and Sonnet 5.5, and GPT-6 Luna and GPT-6.1 Terra. We also ran the open-weights Qwen 3.8-27B.

MethodMLLMImageDiag. toolsChecks, undoesChooses order
Apply-all pipeline–××××
Rule-based pipeline–×✓××
Oracle pipeline–×truth××
Single pass, no diag. tools1 call✓×××
Single pass + diag. tools1 call✓✓××
Loop, no diag. toolsloop✓×✓✓
Dx-Rx (ours)loop✓✓✓✓

Table 1. Compared methods and their components.

Results

Q1: an agent can replace hand-set rules. Running every repair made 11 volumes worse (Table 2). Gating each repair by its diagnostic tool removed this harm and raised the mean from 52.1 % to 62.3 %. Dx-Rx needed no hand-set order or gating rule beyond the tools, and with none of the five MLLMs did it make a volume worse. With every MLLM, it gave the same result as the rule-based pipeline on most volumes (at least 112 of 138).

MethodError removed (%)Made worsePSNRSSIM
No restoration0–32.3 ± 3.70.951 ± 0.036
Apply-all pipeline52.1 ± 15.81138.0 ± 3.40.981 ± 0.010
Rule-based pipeline62.3 ± 17.9040.1 ± 8.20.985 ± 0.012
Dx-Rx, GPT-6.1 Terra64.5 ± 18.9040.7 ± 9.10.985 ± 0.012
Oracle pipeline (true artifacts)64.6 ± 15.6040.4 ± 8.20.985 ± 0.012

Table 2. Q1 and Q2: Pipelines and the agent. Error removed (%) is the mean ± std over the 138 volumes with a repairable artifact. Made worse is out of 148 volumes. PSNR (dB) and SSIM are means ± std inside the brain over the 143 volumes with an artifact. The oracle pipeline is told the true artifacts.

Q2: the tools set the ceiling. Given the true artifacts, the same tools in the fixed order removed 64.6 %. Without being told, Dx-Rx nearly matched it, removing 64.5 % with GPT-6.1 Terra, and with no MLLM did it differ significantly from the oracle (p≥0.06p \ge0.06). Even with a perfect diagnosis, the repairs leave the rest of the error.

Q3: measuring is what makes it work. Looking at the image alone, a single-pass MLLM removed at most 19.7 % of the error (Table 3). With each MLLM, Dx-Rx was better than this single pass on at least 114 of the 138 volumes and worse on none. Given the diagnostic tools’ results, the same single pass also came close but stayed below Dx-Rx with every MLLM, though not significantly (p≥0.07p \ge0.07). Without the diagnostic tools, the loop also stayed below Dx-Rx with every MLLM. The difference was significant with Claude Haiku 5.5 and Qwen 3.8-27B, but not with GPT-6 Luna. The diagnostic tools carry most of the gain in error removed. The loop adds feedback: it sees each repair’s result, so it can check it, go back and change the order. For example, the fixed order repairs the spike before ghosting. In 18 test runs, Dx-Rx repaired ghosting first instead and these runs beat the oracle 16 times and were never worse.

VariantClaude Haiku 5.5GPT-6 LunaQwen 3.8-27B
Single pass, no diag. tools19.7 ± 25.819.6 ± 24.43.3 ± 13.0
Single pass + diag. tools61.7 ± 18.660.0 ± 21.361.7 ± 18.6
Loop, no diag. tools60.1 ± 21.162.0 ± 18.959.3 ± 22.0
Dx-Rx (loop + diag. tools)62.2 ± 18.062.4 ± 17.863.1 ± 18.3

Table 3. Q3: What each component adds. Each value is the error removed (%), as in Table 2.

Figure 3 shows one such run. The agent first repaired the spike and then ghosting like the fixed order, but ghosting remained even after two more tries. It went back to the input and repaired ghosting first and then the spike, removing 96.5 % of the error against 47.7 % for the fixed order, and its report says why it changed course.

Figure 3. One test volume (t0122: spike and ghosting) from input to output, GPT-6.1 Terra

Q4: with a larger MLLM, Dx-Rx nearly reaches the oracle. With GPT-6.1 Terra it removed 64.5 %, nearly matching the 64.6 % of the oracle pipeline, and significantly more than the smaller GPT-6 Luna of the same family, which removed 62.4 % (p=0.02p = 0.02). It was also the only MLLM never worse than the rule-based pipeline on any volume, and it was better on 8 volumes (Table 4, p=0.04p = 0.04).

ModelError removed (%)vs. rule-basedDiag. (%)Faithful (%)Cost ($)
Claude Haiku 5.562.2 ± 18.011 / 1490.995.90.003
GPT-6 Luna62.4 ± 17.88 / 991.596.60.002
Qwen 3.8-27B63.1 ± 18.313 / 691.287.20.010
GPT-6.1 Terra64.5 ± 18.98 / 0*92.097.30.017
Claude Sonnet 5.562.2 ± 18.813 / 1389.799.30.035

Table 4. Q4: Dx-Rx with smaller and larger MLLMs. Error removed is as in Table 2. Vs. rule-based counts volumes with more / less error removed than the rule-based pipeline (* significant after Holm’s adjustment). Diag. and Faithful are the shares of correct diagnoses and faithful reports. Cost is the mean per volume.

In the Claude 5.5 family, the larger Sonnet removed only about as much as Haiku (both 62.2 %, p=0.85p = 0.85), but it wrote the most faithful reports of all five MLLMs (147 of 148 reports).

Conclusion

Dx-Rx restores whole 3-D brain MRI with several artifacts as well as or better than an expert-designed rule-based pipeline built from the same tools, without hand-set rules for which repair to run or in what order, and also explains each decision in a radiology-style report. Its strength comes from measuring before repairing. An MLLM that only looks at slices removes little, while the same MLLM with diagnostic tools comes close to the expert pipeline, and the loop lets it notice when a repair did not work and change course. With a larger MLLM, Dx-Rx nearly reached the oracle pipeline that is told the ground truth artifacts. The tools set the ceiling. It also worked well with an open-weight model, which a hospital can run on site to keep scans in-house and comply with patient privacy regulations.

Compliance with Ethical Standards

This research study was conducted retrospectively using human subject data made available in open access by the IXI dataset [17] (CC BY-SA 3.0) and the MR-ART dataset (OpenNeuro ds004173, CC0) [2]. Ethical approval was not required as confirmed by the licenses attached with the open access data.

Acknowledgments

We thank the IXI project and the MR-ART authors, through OpenNeuro, for making their data available. The authors declare no conflicts of interest.

References

  1. [1]Maxim Zaitsev, Julian Maclaren, and Michael Herbst, “Motion artifacts in MRI: A complex problem with many partial solutions,” Journal of Magnetic Resonance Imaging, vol. 42, no. 4, pp. 887–901, 2015.DOI
  2. [2]Ádám Nárai et al., “Movement-related artefacts (MR-ART) dataset of matched motion-corrupted and clean structural MRI brain scans,” Scientific Data, vol. 9, no. 1, 2022.DOI
  3. [3]Yuxian Tang, Feng Li, Feng Shi, and Qian Wang, “ResMAP: restoring MRIs of mixed artifacts by prompt cascading retrieval,” in Medical Image Computing and Computer Assisted Intervention – MICCAI 2025, 2026, pp. 506–515.
  4. [4]Shunyu Yao et al., “ReAct: Synergizing reasoning and acting in language models,” in International Conference on Learning Representations (ICLR), 2023.arxiv.org/abs/2210.03629
  5. [5]Kaiwen Zhu, Jinjin Gu, Zhiyuan You, Yu Qiao, and Chao Dong, “An intelligent agentic system for complex image restoration problems,” International Conference on Learning Representations (ICLR), 2025.arxiv.org/abs/2410.17809
  6. [6]Gulfam Ahmed Saju, Marjan Akhi, and Yuchou Chang, “AgentMRI: a vison language Model-Powered AI system for self-regulating MRI reconstruction with multiple degradations,” Journal of Imaging Informatics in Medicine, vol. 39, no. 2, pp. 1422–1440, 2025.DOI
  7. [7]Gulfam Ahmed Saju, Marjan Akhi, and Yuchou Chang, “MRI-AgentNet: a vision language Models-Based Multi-Agent AI system for solving inverse problems in MRI,” in 2026 IEEE International Conference on AI and Data Analytics (ICAD), 2026, pp. 1–8.DOI
  8. [8]Jiyao Liu, Jinjie Wei, Wanying Qu, Chenglong Ma, et al., “MedQ-Bench: Evaluating and exploring medical image quality assessment abilities in MLLMs,” arXiv preprint, 2025.DOI
  9. [9]Fankai Jia et al., “MMRQA: Signal-enhanced multimodal large language models for MRI quality assessment,” in 2026 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2026, pp. 7281–7285.
  10. [10]Yi-Hsuan Kao and James R. MacFall, “Correction of MR k-space data corrupted by spike noise,” IEEE Transactions on Medical Imaging, vol. 19, no. 7, pp. 671–680, 2000.pubmed.ncbi.nlm.nih.gov/11055782
  11. [11]Nicholas J. Tustison et al., “N4ITK: Improved N3 bias correction,” IEEE Transactions on Medical Imaging, vol. 29, no. 6, pp. 1310–1320, 2010.DOI
  12. [12]Fabian Isensee et al., “Automated brain extraction of multisequence MRI using artificial neural networks,” Human Brain Mapping, vol. 40, no. 17, pp. 4952–4964, 2019.DOI
  13. [13]Kai Zhang, Yawen Li, Wangmeng Zuo, Lei Zhang, Luc Van Gool, and Radu Timofte, “Plug-and-Play image restoration with deep denoiser prior,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 44, no. 10, pp. 6360–6376, 2022.DOI
  14. [14]Hákon Gudbjartsson and Samuel Patz, “The Rician distribution of noisy MRI data,” Magnetic Resonance in Medicine, vol. 34, no. 6, pp. 910–914, 1995.pubmed.ncbi.nlm.nih.gov/8598820
  15. [15]American College of Radiology, “ACR practice parameter for communication of diagnostic imaging findings,” Revised 2025 (Resolution 9), 2025.
  16. [16]Miles Turpin, Julian Michael, Ethan Perez, and Samuel Bowman, “Language models don’t always say what they think: Unfaithful explanations in Chain-of-Thought prompting,” in Advances in Neural Information Processing Systems 36 (NeurIPS), 2023, pp. 74952–74965.arxiv.org/abs/2305.04388
  17. [17]“IXI Dataset,” https://brain-development.org/ixi-dataset/.
  18. [18]Richard Shaw, Carole Sudre, Sébastien Ourselin, and M. Jorge Cardoso, “MRI k-Space motion artefact augmentation: Model robustness and Task-Specific uncertainty,” in Proceedings of The 2nd International Conference on Medical Imaging with Deep Learning (MIDL), 2019, vol. 102 of Proceedings of Machine Learning Research, pp. 427–436.
  19. [19]Fernando Pérez-García, Rachel Sparks, and Sébastien Ourselin, “TorchIO: A Python library for efficient loading, preprocessing, augmentation and patch-based sampling of medical images in deep learning,” Computer Methods and Programs in Biomedicine, vol. 208, pp. 106236, 2021.
  20. [20]David Atkinson, Derek L. G. Hill, Peter N. R. Stoyle, Paul E. Summers, and Stephen F. Keevil, “Automatic correction of motion artifacts in magnetic resonance images using an entropy focus criterion,” IEEE Transactions on Medical Imaging, vol. 16, no. 6, pp. 903–910, 1997.pubmed.ncbi.nlm.nih.gov/9533590
  21. [21]Sophie Loizillon et al., “Automated MRI quality assessment of brain t1-weighted MRI in clinical data warehouses: A transfer learning approach relying on artefact simulation,” Machine Learning for Biomedical Imaging, vol. 2024, no. June 2024, pp. 888–915, 2024.DOI
  22. [22]Zhou Wang, Alan C. Bovik, Hamid R. Sheikh, and Eero P. Simoncelli, “Image quality assessment: from error visibility to structural similarity,” IEEE Transactions on Image Processing, vol. 13, no. 4, pp. 600–612, 2004.pubmed.ncbi.nlm.nih.gov/15376593
  23. [23]Frank Wilcoxon, “Individual comparisons by ranking methods,” Biometrics Bulletin, vol. 1, no. 6, pp. 80, 1945.
  24. [24]Sture Holm, “A simple sequentially rejective multiple test procedure,” Scandinavian Journal of Statistics, vol. 6, pp. 65–70, 1979.DOI

Paper details

vlnc:W_stttjpgm
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Engineering

Not recorded for this paper · View statement →

Looking for related papers…
Contents