Anchoring Intracranial Electrodes in Patient Anatomy, Not Template Coordinates

Models that decode brain activity from electrodes implanted during epilepsy surgery have to deal with every patient having a different number of electrodes in different places. The current fix is to map each electrode into a shared "average brain" coordinate system (the MNI template) and tell the model where each electrode sits in that space. This works when the patient's brain looks roughly like the average brain. It breaks for the patients who most often receive these implants: people with lesions, cysts, enlarged ventricles, or prior resections. For them, the warp that maps their brain onto the template stretches and folds space, and an electrode in damaged cortex can be assigned the coordinates of healthy tissue several centimetres away. The model then reasons about the electrode as if it were somewhere it is not.

We propose to describe each electrode by the 3D tissue that actually surrounds it in the patient's own MRI, encoded by a volumetric network trained to tolerate pathology. Template coordinates are kept only where the warp near the electrode is mild. The claim is narrow and testable. As anatomical deformation near the contacts increases, decoding with template-coordinate encodings should degrade, and decoding with anatomy-anchored encodings should not. On neurotypical anatomy the two should perform about the same.

Core Claim

The closest existing system is seegnificant from Neural decoding from stereotactic EEG: accounting for electrode variability across subjects. It treats stereotactic EEG (sEEG, depth electrodes placed inside the brain) contacts as an unordered set, tokenizes each contact's signal with a 1D convolution, and adds a positional code built from radial basis functions of the contact's MNI coordinate. Across 21 subjects it reaches a test $R^2$ of 0.54 for response-time decoding, against about 0.30 for single-subject models. That paper motivates our work, because it shows that spatial information is what enables pooling across patients. It also sets up the weakness we target, because all of that spatial information passes through template registration.

The broader pattern in the file is the same. Graph methods that impose a healthy anatomical template, such as DeepEZ with its tractography graph built from 50 Human Connectome Project subjects, gain accuracy from that prior. Yet nothing in their design handles tracts that a lesion has displaced or destroyed. Our claim is that the non-Euclidean "where is this sensor" question should be answered in the patient's own anatomy, using 3D tissue context, and that the template should be trusted per electrode only to the extent that the registration is locally well behaved.

Concretely, each contact $i$ gets a positional embedding

$$p_i = g_i \, \phi(x_i^{\text{MNI}}) + (1-g_i)\, f(V_i), \qquad g_i = \sigma\big(a - b\,|\log \det J(x_i)|\big).$$

Here $\phi$ is seegnificant's radial-basis encoding of the template coordinate $x_i^{\text{MNI}}$. $V_i$ is a 3D patch of the patient's native-space MRI centred on the contact. $f$ is a pretrained volumetric encoder. $\det J(x_i)$ is the determinant of the registration warp's Jacobian at the contact, meaning the local volume change the warp imposes there. $\sigma$ is the logistic function. $a$ and $b$ are learned scalars. When the warp locally expands or compresses tissue a lot, the gate shifts weight toward the anatomical description.

Research Program

The volumetric encoder $f$ is the central component. We train it in the style of Towards contrast- and pathology-agnostic clinical fetal brain MRI segmentation using SynthSeg. The network learns tissue segmentation from synthetic images with randomized contrast. Synthetic pathology is injected through morphological operations: ventricle dilation, carved resection cavities, and spherical cyst and tumour masses at graded severity. Training is fully 3D because the file documents what slicing loses. Independent 2D slices produce incoherent boundaries (Deep convolutional networks for pancreas segmentation in CT imaging), and 2D vision-language models perform at chance on relative 3D position (Your other Left!). Whether an electrode sits at the bottom of a sulcus, in white matter, or on the rim of a cavity is a through-plane question. We keep the patch modest (on the order of 3 cm) so that cost stays low, in line with the efficiency concerns raised by 3D TractFormer.

The tissue description also carries physiological meaning that coordinates lack. A contact in white matter or in a cavity records differently from one in grey matter. This is a second, independent reason the anatomy-anchored code could help.

The decoder is otherwise unchanged from seegnificant: per-contact temporal convolution, then spatial attention over the set of contacts. Holding the rest fixed means any difference comes from the positional code. We also inject intra-subject geometry. Attention between two contacts receives a bias from their native-space distance, so relative layout survives even when template positions are wrong.

Because the published sEEG cohort is small and likely contains few large-lesion cases, we add a controlled stress test. We apply synthetic deformations to each patient's MRI (enlarge ventricles, carve resection cavities, place mass lesions at set distances from the contacts), rerun the standard registration, and recompute the MNI coordinates. The neural signals are untouched, so any drop in decoding comes purely from corrupted spatial encoding. This isolates the mechanism we claim.

Baselines

The naive reference point is a single-subject decoder trained only on each patient's own data. It needs no spatial alignment at all. Neural decoding from stereotactic EEG reports $R^2 \approx 0.30$ for this setting. Any multi-subject method that falls to this level on deformed brains has lost its reason to exist.

The strongest existing method is seegnificant with RBF-encoded MNI coordinates, reported at test $R^2 = 0.54$ on the 21-subject, 29-session response-time task in the same paper. We will reimplement it on the identical splits, use the same temporal tokenizer and attention depth, give it the same hyperparameter-search budget as our model, and confirm we reproduce roughly 0.54 before comparing. Beating it means two things. First, a statistically significant $R^2$ advantage in the tercile of contacts and subjects with the largest local deformation, and a flatter $R^2$ curve under the synthetic stress test. Second, staying within about 0.02 $R^2$ of seegnificant on the least-deformed tercile. Winning only on average would not support the claim.

The second strong competitor is seegnificant with a better registration step. The patient's lesion is masked out of the registration cost so the warp does not try to match tissue that does not exist in the template. For this we found no reported result on Lacuna, so we will run it ourselves with the same decoder.

Three ablations isolate the key ingredient. The first is the gate fixed at $g_i = 0$, which uses anatomy only. The second replaces the patient's patch $V_i$ with the template's MRI patch at $x_i^{\text{MNI}}$. This tests whether the benefit comes from patient-specific tissue or merely from a richer encoding of template position. The third replaces the 3D patch with three orthogonal 2D slices through the contact, encoded by a 2D network of matched size. This tests whether volumetric context matters or slice context is enough.

Why not just…?

Why not just fix the registration instead? This is the real threat, and we treat it as a primary baseline rather than dismissing it. Lesion-masked registration can reduce distortion near small lesions. It cannot invent correspondence for tissue that has been resected or replaced by a cyst, because there is no template location that such a contact truly occupies. The stress test settles the question. If lesion-masked seegnificant matches our model's curve as cavity size grows, the anatomy encoder is unnecessary, and we would report that.

Why not just use native-space coordinates and drop the template? Native coordinates preserve within-patient layout. They give no correspondence across patients, and that correspondence is exactly what raised $R^2$ from 0.30 to 0.54 in Neural decoding from stereotactic EEG. We nonetheless include native distance as an attention bias. The anatomy-only ablation tests whether tissue context alone can carry cross-patient correspondence.

Why not just label each contact with its atlas region? Atlas labels come from the same template warp, so they fail in the same deformed regions. They are also coarse: the region-level resolution limit noted for DeepEZ applies. We will include an atlas-token variant in the stress test. We expect it to degrade at least as fast as raw coordinates.

Why not just fine-tune seegnificant on each new patient? Few-shot adaptation helps when a patient's signals differ. It cannot correct a spatial code that tells the model the electrode is somewhere else, and in the clinical setting few labelled trials exist. We will compare few-shot adaptation curves on the most deformed held-out subjects.

Proposed Experiments

The primary experiment uses the sEEG response-time benchmark from Neural decoding from stereotactic EEG, which requires access to that dataset and its MRI and CT images. We use leave-subjects-out evaluation and report test $R^2$ overall and stratified by deformation near the contacts. Deformation is measured by $|\log \det J|$ and by lesion or cavity volume within a fixed radius of each contact.

The decisive check is the synthetic stress test. We plot $R^2$ against simulated cavity and mass volume for our model, seegnificant, lesion-masked seegnificant, and the atlas variant. A secondary check examines the learned gate. If $g_i$ does not drop at contacts near real lesions, the mechanism is not doing what we claim, even if aggregate numbers improve.

To address the "tug-of-war" that SynthSeg documented, where pathology-oriented training cost accuracy on neurotypical brains, we also report $R^2$ on the least-deformed subjects. The gate exists to avoid that trade-off, so a loss there would count against the proposal.

A smaller-scale check reuses the encoder in the resection-cohort setting of DeepEZ. The 14 patients there are too few for strong conclusions, so this is reported only as exploratory.