Teaching 4D fMRI Models to Preserve Voxel-Wise Connectivity

Functional connectivity is the pattern of which brain locations rise and fall together over time in a functional MRI scan. Psychiatric imaging increasingly measures it voxel by voxel (a voxel is one 3D pixel, a few millimeters on a side), because averaging over predefined regions blurs out small or boundary-crossing abnormalities. Deep models for raw 4D fMRI (3D volumes over time) now exist, but they are trained to reproduce intensities or to tell scans apart, and nobody checks whether they preserve the voxel-to-voxel correlations that clinical analyses actually use. We propose to make connectivity itself the training target. The loss correlates a random set of "seed" voxels with every other voxel, which is the standard seed-to-voxel analysis from neuroimaging, and compares those seed maps between model output and real data. Because the seeds are random, the loss is a cheap, unbiased estimate of the error over the full billion-entry voxel correlation matrix.

The second half of the idea uses this loss as a measuring instrument for volumetric context loss. Volumetric context loss is what happens when a model processes a 3D volume as independent 2D slices and so loses information along the slice axis. If slice-wise processing damages 3D structure, the damage should show up as a specific failure in connectivity: correlations between voxels on different slices should be distorted more than correlations within a slice. We split connectivity error into through-plane and in-plane parts and test whether this asymmetry exists. We also test whether native 4D models remove it, and whether a connectivity-aware objective improves downstream use of the learned representations.

Core Claim

Losses on intensity, such as mean squared error and structural similarity, constrain each voxel's predicted value but say nothing directly about how pairs of voxels co-vary. Second-order structure can therefore be wrong even when first-order fit looks excellent. Our claim has three testable parts. First, current 4D fMRI forecasters and encoders reproduce voxel intensities well but distort voxel-wise seed connectivity, with larger distortion for long-range and through-plane pairs. Second, adding a sketched seed-correlation loss repairs this at a small cost in intensity error. Third, the error decomposition exposes volumetric context loss in slice-based encoders as a measurable through-plane connectivity deficit.

Relation to Prior Work

Two papers supply the architecture we build on and also motivate the gap. SwiFT is a 4D shifted-window transformer: it computes attention inside local windows that shift between layers, and here those windows span three spatial axes and time. It ingests un-parcellated fMRI and is pretrained with instance and temporal contrastive losses. Voxel-Level Brain States Prediction Using Swin Transformer turns this into a forecaster that predicts 10 future volumes from 32 past ones, using masked MSE plus SSIM. Neither paper ever computes or optimizes a correlation between voxel time series. We keep their encoder and change what it is asked to preserve.

The connectivity side comes from brain-wide association work. Cheng et al. correlated all pairs among 47,636 gray-matter voxels and found thalamocortical dysconnectivity in schizophrenia. Seed-to-voxel studies such as the amygdala subregion analysis map one seed against the whole brain. Degree-centrality studies such as Ding et al. and Gao et al. summarize each voxel's total connectivity. These papers supply our evaluation quantities. Our loss is effectively a stochastic seed-to-voxel analysis run inside the training loop.

Two connectivity-aware models are the closest work, and both stop short of voxel-level connectivity targets. BrainMixer maximizes mutual information between a voxel-activity encoder and a functional-connectivity encoder. Its connectivity lives on a graph of atlas regions, and its voxel patches follow the Schaefer atlas. The Spatiomolecular Transformer predicts parcellated connectomes from gene expression conditioned on 3D coordinates. We differ from both by computing the connectivity target between individual voxels in native space, with no parcellation in the loss.

BrainMixer's finding that atlas patching beats grid patching is a real counterpoint. We therefore include a region-level version of our loss as an ablation instead of assuming voxel resolution wins.

The volumetric-context literature motivates the through-plane diagnostic. Roth et al. showed that slice-wise CNNs produce structures that appear on one slice and vanish on the next. MMGPL concedes that a dimensionality gap remains between 2D pretrained encoders and 3D data. Both describe the problem for segmentation and classification. To our knowledge no one has asked what slicing does to a second-order quantity like connectivity, where errors can hide behind good per-voxel fit.

Research Program

Let $Y \in \mathbb{R}^{N \times T}$ be the true voxel time series over a window of $T$ frames inside a brain mask of $N$ voxels, and let $\hat{Y}$ be the model's output for the same window (a forecast or a reconstruction). At each step we draw a random seed set $S$ of $K$ voxels. For seed $s$, we compute the seed map $r_s(Y) \in \mathbb{R}^N$: the Pearson correlation of voxel $s$'s time series with every voxel's time series. The connectivity loss is

$$ \mathcal{L}_{\mathrm{FC}} = \frac{1}{K}\sum_{s \in S} \frac{1}{N}\,\big\| z\big(r_s(\hat{Y})\big) - z\big(r_s(Y)\big) \big\|_2^2 , $$

where $z$ is the Fisher transform, $z(r) = \operatorname{arctanh}(r)$, applied elementwise. The Fisher transform makes errors comparable across correlation strengths. Because the seeds are uniform, the expected value of this loss equals the mean squared Fisher-$z$ error over the whole $N \times N$ correlation matrix. The cost is $O(KNT)$ rather than $O(N^2 T)$, and it is computed per window, so it targets time-varying connectivity rather than one static matrix. The full objective adds $\lambda \mathcal{L}_{\mathrm{FC}}$ to the existing masked MSE and SSIM terms.

We train in two settings. The first is the HCP forecasting setup of the voxel-level forecaster: 32 frames in, 10 out, on a $48^3$ grid. Here the loss applies to the predicted frames concatenated with the history, because 10 frames alone are too short for stable correlations. The second is SwiFT-style self-supervised pretraining with a masked-reconstruction head, where the loss applies to reconstructed windows.

For the diagnostic, we bin each seed–target pair along two axes. The first axis is whether the pair shares an acquisition slice, differs by one slice, or lies further apart through-plane. The second axis is Euclidean distance. We report connectivity error in each bin.

Baselines

The naive reference is a pair of trivial predictors scored with the same metrics: a persistence forecast that repeats the last observed frame, and a mean-frame forecast. Each gives a seed-map error floor that any learned model must beat. A model that matches or loses to persistence on connectivity, while beating it on MSE, is direct evidence for our core claim.

The strongest existing forecaster is the 4D Swin encoder with a 3D transposed-convolution decoder from Voxel-Level Brain States Prediction, trained with masked MSE and SSIM. It reports masked MSE 0.035 and SSIM 0.954 on HCP at $48^3$. We retrain it on identical subject splits, preprocessing, compute budget, and hyperparameter search budget. Our variant differs only by the added $\lambda \mathcal{L}_{\mathrm{FC}}$ term, with $\lambda$ tuned on validation within the same budget. No reported connectivity-fidelity result was found on Lacuna for this or any forecaster, so we establish that number ourselves.

Beating this baseline means two things together. Mean seed-map Fisher-$z$ error must fall by a margin outside the across-seed confidence interval. Masked MSE must stay within 10% of the baseline's.

For representation quality, the strongest baseline is SwiFT with its contrastive pretraining. SwiFT reports 97.7% accuracy and 99.8% AUC for UK Biobank sex classification and 2.36-year mean absolute error for HCP age. We fine-tune both pretrained encoders under the same protocol and compare.

Three ablations isolate the key ingredient. A region-level ablation replaces voxel seeds with Schaefer-parcel mean time series, which tests the BrainMixer position. A fixed-seed ablation uses a fixed set of 64 seeds in place of random ones, which tests whether unbiased coverage matters. A slice-encoder ablation swaps the 4D encoder for a 2D-per-slice encoder plus a temporal transformer at matched parameter count. That 2D encoder is trained with and without $\mathcal{L}_{\mathrm{FC}}$, which tests whether the loss can compensate for missing through-plane context.

Why not just…?

Why not just compute connectivity post hoc from the existing MSE-trained forecaster? This is the most serious threat. If intensity fit already implies connectivity fit, our loss is unnecessary. There is a reason to doubt it: squared-error forecasts shrink toward the conditional mean, which damps independent fluctuations and can inflate correlations between voxels. That is an argument, not evidence. Our first experiment scores the unmodified baseline on seed-map error. If its error is statistically indistinguishable from the variant trained with $\mathcal{L}_{\mathrm{FC}}$, we report that negative result and drop the loss. The through-plane diagnostic would still remain as a contribution.

Why not just use region-level connectivity, which is cheaper and was favored by BrainMixer? BrainMixer found that atlas-based patching helped representation learning. The voxel-wise literature, by contrast, holds that focal and boundary-crossing effects such as thalamocortical links (Voxel-based, brain-wide association study of aberrant functional connectivity in schizophrenia implicates thalamocortical circuitry) vanish under averaging. The parcel-loss ablation settles this on our task. If it matches voxel seeds on held-out voxel seed maps, the cheaper version should be preferred. We expect it to lose specifically on within-parcel and border-straddling pairs, and we report that bin separately.

Why not just spatially smooth the data or the outputs? Gaussian smoothing is standard and would remove slice-to-slice jitter. It does so by imposing correlation between neighbors, which inflates short-range connectivity, the exact bias seed-based analyses try to avoid. We include smoothed baseline outputs at three kernel widths in the evaluation. The distance-binned error will show whether smoothing trades short-range bias for apparent continuity.

Why not just give a slice-based model the connectivity loss and skip 4D attention? If the loss alone recovers through-plane connectivity in a 2D encoder, then volumetric context matters less for this quantity than the segmentation literature suggests. That would be a useful finding in its own right. The slice-encoder ablation tests exactly this.

Proposed Experiments

The decisive first check is on HCP resting-state data using the forecaster protocol. We report masked MSE, SSIM, and mean seed-map Fisher-$z$ error for persistence, mean frame, the baseline forecaster, and our variant. Errors are binned by through-plane offset and distance and averaged over 2,000 random held-out seeds per subject.

Volumetric context loss predicts that the 2D slice encoder's error grows with through-plane offset faster than with in-plane distance. The 4D encoder should show a flatter profile. We also check degree-centrality maps computed from model outputs against maps from real data, using voxel-wise correlation, because centrality is the summary clinicians report.

The second experiment tests whether connectivity-aware pretraining yields more useful representations. We pretrain on UK Biobank, then fine-tune on HCP age and UK Biobank sex against SwiFT's reported numbers. We add ABIDE autism-versus-control classification with site-held-out splits, where no reported result was found on Lacuna for a 4D voxel-level transformer.

The third experiment is a validity check against established findings. For an ABIDE site subset, we compute the autism-related homotopic connectivity effect described by Floris et al. on real data and on model reconstructions. We then ask which pretraining objective preserves the effect's sign and location. The criterion is preserved structure, not inflated effect size, since a model that manufactures group differences would be worse, not better.

The proposal succeeds if three things hold. The baseline shows measurable connectivity distortion that intensity metrics hide. The loss reduces it without hurting intensity fit. The through-plane asymmetry appears in slice-based models and shrinks in native 4D ones. If the first fails, the remaining value is the diagnostic itself, which the field currently lacks.