WorksComputer Science
Fast Slice-Wise Deep Learning Motion Correction for Spinal Cord Functional MRI
Abstract
Respiratory and bulk motion displace the spinal cord between the volumes of a functional MRI time series. Current methods such as the Spinal Cord Toolbox (SCT) take several minutes per time series, and general-purpose brain tools register whole volumes, whereas the cord moves mainly slice by slice. We propose a lightweight convolutional neural network that regresses the in-plane translation aligning each axial slice to a reference. Two models, trained without motion labels, correct large and then residual motion. On a 3T (120 scans) and a 7T (59 scans) dataset, the proposed method improves on SCT on every metric (tSNR +10 to +25%, DVARS -20 to -38%), leaves almost no slice displaced by more than one voxel (<0.1%), performs on par with a slice-wise AFNI variant and better than slice-wise FSL FLIRT, and runs in about 10 s per scan, about 30 times faster than SCT. The code is available at https://github.com/ivadomed/moco-dl and the method is available in SCT v7.4.
Introduction
In spinal cord functional MRI, respiration and voluntary movements displace the cord between volumes [1], which lowers the temporal signal-to-noise ratio (tSNR) and adds fluctuations that can hamper the detection of functional activity. Unlike the brain, the cord does not move as a rigid block: its displacement varies along its length, mostly within the axial plane, and the thick axial slices (3–5 mm) are acquired at different times, so motion is usually corrected slice by slice with in-plane transforms [2, 3], as we do here.
The Spinal Cord Toolbox (SCT, v7.3) [3] provides a slice-wise correction, sct_fmri_moco, built on ANTs [4], which takes 4–7 min per time series. Brain tools such as AFNI 3dvolreg [5] and FSL MCFLIRT [6] register whole volumes and must be adapted to slice-wise registration around the cord, as in the Neptune toolbox [7]. DeepRetroMoCo [8], an unsupervised network predicting dense deformation fields, was trained and tested on a single 3T dataset and is released as
research code rather than a ready-to-use tool.
Our main contribution is a fast, ready-to-use tool, available in SCT v7.4: a lightweight CNN regressing slice-wise in-plane translations, trained without labels on multi-site 3T and 7T data with random-walk motion augmentation, and applied in two stages (large, then residual motion) with an NCC check that rejects harmful predictions. We compare it with sct_fmri_moco and slice-wise AFNI and FSL FLIRT on two cord fMRI datasets, at 3T and 7T.
Methods
Network and preprocessing
For each axial slice of each volume, the network takes the slice to correct, , and a reference slice, (by default the temporal mean), stacked as channels, and outputs the translation aligning to (Figure 1). The architecture consists of four stride-2 convolutions with LeakyReLU (16 to 128 channels), adaptive average pooling and a linear layer for about 98k parameters in total. Images are first cropped around the cord with sc_crop (detection on the first volume, same box for all volumes), which removes background structures that move differently from the cord and speeds up inference. Each slice is padded or cropped to 64 × 64 and its intensities are clipped to the 1st–99th percentiles and rescaled to [0, 1].
Figure 1. Overview. (a) Training: the CNN predicts from a slice and the temporal mean ; an NCC loss compares the warped slice with . M1 sees random-walk displacements of up to 3 voxels. (b) Inference: M1, then M2 up to times, updating ; translations that lower the NCC are discarded and the composed transform is applied once to the raw data.
Training
Two models share this architecture: M1 for large, persistent movements and M2 for small residual ones. They are trained on five public OpenNeuro datasets: ds004386, ds004616, ds005075, ds006729, ds007932, comprising 141 subjects total acquired at 3T (n=133) and 7T (n=8), in-plane resolution 0.75–3.4 mm, slice thickness 1–5 mm, TR = 1.55–3.2 s. The method is tested on two other public datasets, unseen during training (ds008784 and ds007067, Section 3.1). Some of the datasets included multiple runs per subject: the total number of runs was 420, which were split by subject into 337 for training and 83 for validation, giving 2,603,976 and 683,041 slice pairs.
For M1, a synthetic random-walk translation is added to each series: , , independently along and , with voxels and each component clipped to voxels, so that displacements drift and persist as real motion does. M2 is trained on the real series without synthetic motion, to focus on the small displacements present in the data. The loss compares the warped slice with the mean of the series after data augmentation. For M1, the loss combines a global NCC over the non-zero pixels, , which keeps a useful gradient for large displacements, with a local NCC ( window [9]), , sensitive to subvoxel misalignment. For M2, uses the local NCC only. Both models are trained with Adam (learning rate , 100 epochs, batch size 128), keeping the checkpoint with the lowest validation loss on real pairs; each takes about 13 h on an NVIDIA RTX PRO 6000 GPU.
Two-stage iterative inference
M1 predicts a translation for every slice, with the temporal mean; any translation that lowers the NCC between the slice and is replaced by the identity. M2 then refines every slice iteratively: is recomputed from the corrected series, and
M2 predicts a residual translation, filtered by the same check and composed with the current transform. Refinement stops after iterations, when the mean parameter change falls below , or when it increases (the previous transform is then kept). The composed transform is applied once to the raw, uncropped slices.
Experiments and results
Datasets, baselines and metrics
Both test datasets are public on OpenNeuro. ds008784 [10] contains 120 runs (40 healthy subjects, 3 runs each) acquired at 3T ( mm in-plane, 4–5 mm slices, TR = 1.7 s). ds007067 [11] contains 59 runs from 14 subjects at 7T ( mm in-plane, 3 mm slices, TR = 2.5 s).
We compare against sct_fmri_moco (SCT v7.3) and a slice-wise AFNI variant following Neptune [7] (hereafter AFNI), in which 3dWarpDrive estimates the in-plane translation of each axial slice. We also apply FSL FLIRT [6] slice by slice (2D rigid, weighted by a cord mask), the approach of expert spinal cord pipelines: it estimates in-plane rotation in addition to translation, but optimizes each slice separately. All methods align to the temporal mean and, as interpolation reduces noise and changes the metrics by itself, use bilinear interpolation. Whole-volume tools such as 3dvolreg are not included: they apply one rigid transform per volume, whereas the cord moves differently at each level and each slice is acquired at a different time.
With no ground truth available, we use four metrics within a cord mask (the ds008784 segmentation, otherwise sct_deepseg_sc_epi on the raw temporal mean), one value per scan: tSNR; DVARS (RMS intensity change between consecutive volumes, in % of the mean signal); sharpness (mean gradient magnitude of the temporal mean near the cord over its mean intensity), which drops with residual motion and blur; and outlier slices, the percentage of slices whose cord is still displaced by more than one voxel from the temporal mean (cross-correlation around the cord). Times exclude file input/output, on the CPU of one workstation (Intel Xeon w7-2495X). Methods are compared with ours by paired Wilcoxon tests, Holm-corrected within each metric.
Results
3T data. With bilinear interpolation (Table 1), our method improves on sct_fmri_moco on every metric (all ) and is 24 times faster. It improves tSNR and DVARS in every scan, whereas sct_fmri_moco lowers it in some (Figure 2). It improves on AFNI on every metric but sharpness (). It also improves on FLIRT in tSNR, DVARS and outlier slices (), and is 25 times faster; FLIRT, which also estimates rotation, keeps slightly sharper images ( vs. ).
Figure 2. Per-scan tSNR change relative to the raw data, bilinear interpolation; bars: medians. Ours improves tSNR in every scan, whereas sct_fmri_moco lowers it in some.
| Method | tSNR↑ | DVARS↓ | Sharp.↑ | Outl.↓ | Time (s) |
| Raw | – | ||||
| sct_fmri_moco | |||||
| AFNI | |||||
| FSL FLIRT | |||||
| Ours |
Table 1. Results on ds008784 (3T, 120 scans, mean over scans, bilinear interpolation). Outl.: slices displaced by > 1 voxel (%); time per scan. Bold: best. : different from ours (paired Wilcoxon tests, Holm-corrected ).
7T data. With bilinear interpolation (Table 2), our method improves on sct_fmri_moco on every metric (tSNR 12.21 vs. 9.76, DVARS 12.40 vs. 20.17, all ) and is 38 times faster. Outlier slices drop from 15.6% before correction to 0.06%, against 4.7%. AFNI matches our tSNR and outlier slices, with slightly better DVARS and sharpness, but is three times slower. FLIRT has a lower tSNR and more outlier slices (0.21%, ), with similar DVARS and sharpness, and is 33 times slower (351 s).
| Method | tSNR | DVARS | Sharp. | Outl. | Time (s) |
| Raw | 6.87* | 26.31* | 0.170* | 15.62* | – |
sct_fmri_moco | 9.76* | 20.17* | 0.170* | 4.73* | 405.0* |
| AFNI | 12.09 | 12.23 | 0.196* | 0.12 | 32.4* |
| FSL FLIRT | 11.78* | 12.63 | 0.193 | 0.21* | 351.1* |
| Ours | 12.21 | 12.40 | 0.193 | 0.06 | 10.7 |
Table 2. Results on ds007067 (7T, 59 scans), as in Table 1.
Severe motion. Figure 3 shows an example scan (40% of slices displaced) in which the cord jumps by several voxels at volume 37. Only our method keeps the spinal cord within its initial edges for the whole scan: FLIRT reduces the jump but leaves the cord shifted by about one voxel afterwards, and sct_fmri_moco and AFNI leave it displaced. Run-level metrics barely reflect this: AFNI still raises the tSNR from 4.4 to 7.7 despite 27.9% outlier slices (0% for ours).
Figure 3. Example scan with severe motion, one slice: temporal mean, intensity along the dashed line over time, and tSNR map (mean tSNR in the cord of this slice). Red lines: spinal cord edges in the first volumes.
Discussion and Conclusion
Compared with sct_fmri_moco, a small unsupervised CNN with 98k parameters corrects spinal cord motion in fMRI timeseries better and runs 24 to 38 times faster. It performs on par with AFNI and better than slice-wise FLIRT, although more extensive tests are warranted.
The main limitation is the evaluation: with no ground truth, and all methods aligning to the temporal mean, the metrics measure temporal consistency rather than anatomical accuracy and depend on the interpolation. Simulated motion of known amplitude would quantify accuracy directly. Also, the network estimates translations only, whereas FLIRT also corrects in-plane rotation, which may explain its slightly sharper images at 3T. Future work will further validate in other databases, and extend the method to spinal cord diffusion MRI.
Compliance with Ethical Standards
This retrospective study uses open-access human data from OpenNeuro; ethical approval was not required, as confirmed by the data license.
Acknowledgments
This work was funded by AMX (France), CIHR, NSERC, Praxis and NVIDIA. The authors have no relevant financial or non-financial interests to disclose. Claude (Anthropic) assisted with writing and code; the authors reviewed all content.
References
- [1]M. Fratini, M. Moraschi, B. Maraviglia, and F. Giove, “On the impact of physiological noise in spinal cord functional MRI,” J. Magn. Reson. Imaging, vol. 40, no. 4, pp. 770–777, Oct. 2014.DOI
- [2]J. Cohen-Adad et al., “Slice-by-slice motion correction in spinal cord fMRI: SliceCorr,” in Proc. Intl. Soc. Mag. Reson. Med. (ISMRM), 2009, vol. 17.
- [3]B. De Leener et al., “SCT: Spinal Cord Toolbox, an open-source software for processing spinal cord MRI data,” NeuroImage, vol. 145, Part A, pp. 24–43, 2017.DOI
- [4]B. B. Avants, N. J. Tustison, G. Song, P. A. Cook, A. Klein, and J. C. Gee, “A reproducible evaluation of ANTs similarity metric performance in brain image registration,” NeuroImage, vol. 54, no. 3, pp. 2033–2044, 2011.DOI
- [5]R. W. Cox, “AFNI: software for analysis and visualization of functional magnetic resonance neuroimages,” Comput. Biomed. Res., vol. 29, no. 3, pp. 162–173, 1996.pubmed.ncbi.nlm.nih.gov/8812068
- [6]M. Jenkinson, P. Bannister, M. Brady, and S. Smith, “Improved optimization for the robust and accurate linear registration and motion correction of brain images,” NeuroImage, vol. 17, no. 2, pp. 825–841, 2002.pubmed.ncbi.nlm.nih.gov/12377157
- [7]D. Rangaprakash and R. L. Barry, “Neptune: a toolbox for spinal cord functional MRI data processing and quality assurance,” in Proc. Intl. Soc. Mag. Reson. Med. (ISMRM), 2022, p. 0396.DOI
- [8]M. Mobarak-Abadi et al., “DeepRetroMoCo: deep neural network-based retrospective motion correction algorithm for spinal cord functional MRI,” Front. Psychiatry, vol. 15, pp. 1323109, June 2024.DOI
- [9]M. J. Cardoso et al., “MONAI: An open-source framework for deep learning in healthcare,” arXiv preprint arXiv:2211.02701, 2022.arxiv.org/abs/2211.02701
- [10]S. Bédard et al., “Spatial distribution of spinal cord fMRI activity with electrocutaneous stimulation,” Imaging Neuroscience, vol. 4, pp. IMAG.a.1383, 2026.DOI
- [11]A. D’Astous et al., “Spine fMRI 7T,” OpenNeuro, doi:10.18112/openneuro.ds007067.v4.0.0, 2026.


