HKU's NDL Framework Detects Brain Seizure Spikes Across Any EEG Setup
A research team introduces Nested Deep Learning, a spike detection framework that adapts across EEG/MEG channel setups and pinpoints where spikes originate.
ProTakeaways
- New Nested Deep Learning (NDL) framework detects epileptic spikes across varying EEG and MEG channel setups.
- Learns per-channel softmax weights, letting the model identify which channels contain the spike.
- Beats SpikeNet on TUH with 93.35% AUC and 86.96% sensitivity using only ~17k parameters.
- Model trained on UCSF MEG generalizes to Beijing Tiantan Hospital EEG despite different modality and channel count.
- Paper includes identifiability proof and asymptotic consistency for the two-level estimator.
- Replication code available on GitHub; open-data model published, private data models on request.
Spotting epileptic spikes in brain recordings is one of those problems where deep learning should have won years ago, yet clinicians still spend hours squinting at multichannel EEG traces. A team from the University of Hong Kong, Beijing Tiantan Hospital, and UCSF has now proposed a framework called Nested Deep Learning (NDL) that tries to fix two very specific pain points that have kept prior detectors from being broadly useful: they only work on the exact channel montage they were trained on, and they can flag that a spike happened without telling you which channel it came from.
The paper positions NDL not just as another spike classifier but as a step toward a foundation model for brain signal data, one that can be trained on MEG and then applied to EEG without retraining from scratch.
Why existing spike detectors keep breaking
Around 50 million people worldwide suffer from epilepsy, and detecting interictal spikes matters for both diagnosis and locating the seizure onset zone before surgery. The catch is that manual spike identification is labor-intensive, especially when analyzing continuous or video EEG studies that can last more than 24 hours, and requires specialized training that limits how many clinicians are qualified to interpret the recordings.
Plenty of CNN and LSTM-based detectors have been proposed, but two problems have stuck around:
- Different studies use different numbers and locations of channels, along with different montages, making it hard to build a universal algorithm. A model trained on a 22-channel temporal central parasagittal montage is essentially useless on a 19-channel common-average setup.
- Current algorithms can flag time segments containing spikes but cannot pinpoint the exact channels where the spikes originate, which is exactly what clinicians need to localize the seizure onset zone and rule out false positives.
The nested trick: learn a weight per channel, then combine
NDL is a two-level model. The inner level learns a channel-specific weight function; the outer level uses those weights to combine signals across all channels into a single spike-probability estimate. The framework applies a weighted combination of signals across all channels, ensuring adaptability to different channel setups, and lets clinicians identify key channels more accurately. Rather than treating each channel independently, NDL models the probability of a segment containing a spike as a weighted combination across every channel, with the weights themselves reflecting how important each channel is to the detection.

Concretely, each channel gets a softmax-normalized weight vector that depends on its own signal pattern and the surrounding channels. The weights sum to one across channels, which is what makes the model identifiable, meaning you can actually recover meaningful channel importance rather than an arbitrary permutation. The authors explicitly relate this to attention and Mixture-of-Experts but note that their method introduces structural constraints on the weight function which preserve model identifiability and enhance interpretability. The implementation uses stacked CNN blocks to approximate both the per-channel weight function and the final classifier, trained end-to-end with negative log-likelihood.
Importantly, the team also proves asymptotic consistency for the estimator, which is unusual for a deep learning paper and gives a theoretical grounding for why the weights should converge to something meaningful as data grows.
What the numbers look like
NDL was evaluated on three datasets: the public Temple University Hospital (TUH) EEG corpus, a private 140-channel MEG dataset from UCSF covering 277 epilepsy patients, and a private 19-channel EEG dataset from Beijing Tiantan Hospital. On TUH, NDL achieves the best performance among all compared methods, with the highest sensitivity, F1 score, PRAUC, and AUC, outperforming SpikeNet, a multi-head CNN, and the SpikeDet template-matching toolbox.
| Method | Sensitivity | F1 | AUC |
|---|---|---|---|
| NDL | 86.96% | 85.71% | 93.35% |
| SpikeNet | 81.33% | 84.05% | 89.63% |
| Multi-head CNN | 74.71% | 73.69% | - |
| SpikeDet | 13.30% | 22.74% | - |
The more interesting result is channel localization. By summing the learned weight vector for each channel, NDL produces a channel-level importance score. On TUH, this ranking substantially outperforms random selection at identifying which channels actually contain the labeled spike. On the UCSF MEG data, the topographic distribution of top channels concentrates in the temporal lobes, matching the clinical fact that seizures usually happen in the temporal lobes.
Trained on MEG, tested on EEG
The cross-modality experiment is where NDL earns its foundation-model framing. The team took a model trained only on UCSF MEG data and ran it directly on the Beijing EEG data, which uses a completely different sensor modality and a different channel count. Despite being trained on only 230,325 MEG segments and using just 17,683 parameters, NDL achieves performance comparable to the much larger SpikeNet model, which was trained on over 19 million EEG segments and contains more than 300,000 parameters.
The practical distinction: SpikeNet becomes unusable when the channel configuration deviates from that of the training data, as it was trained under fixed channel settings. NDL keeps working because the channel-weighting mechanism is defined per channel rather than tied to a global input layout.
For continuous recordings, the paper also proposes a sliding-window inference algorithm that scores overlapping windows, applies a threshold to the spike probability plus a channel-importance filter, and then uses DBSCAN clustering to deduplicate overlapping detections.
What it is good for, and where it falls short
The authors are direct about limitations. Their MEG model, when applied to EEG, sometimes selects prefrontal channels because scalp EEG spikes can often be confused with eye movements, which typically occur in the prefrontal areas. False positives on eye artifacts are a known issue, and the paper argues that channel localization itself is the mitigation: if the top two channels flagged are the ones nearest the eyes, the detection is likely an artifact rather than a real spike.
The other honest caveat is scale. NDL was trained on 370 TUH patients and 277 UCSF patients, which the authors acknowledge may not fully capture the variation in spike waveforms across different populations. This is a research prototype meant as scaffolding for larger labeled datasets, not a drop-in clinical tool.
Replication code is available at the team's GitHub repository, and the open-data model trained on TUH is published. The private MEG and EEG models require a formal request. For anyone working on multichannel biosignals more generally, the identifiability construction is the takeaway: it is a template for building attention-like weight functions that actually reflect input importance rather than arbitrary linear combinations.