EEG Pathology Detection with Deep Learning
At TUKL R&D Lab (NUST), we've been working on automating the detection of neurological pathologies from EEG signals. This post walks through the core ideas behind NeuroGATE, the system we built.
The Problem
Manual EEG analysis is time-consuming and requires expert neurologists. A single recording can span hours, and the features of interest — epileptiform discharges, sleep stages, pathological slowing — are intermittent and easy to miss.
Our goal: build a model that can flag likely-abnormal recordings and localize the time windows that drive the prediction.
Data
We used the TUH EEG Corpus, the largest publicly available clinical EEG dataset. After preprocessing (re-referencing to average, bandpass 0.5–70 Hz, notch at 50 Hz), we segmented recordings into 4-second epochs with 50% overlap.
Architecture
The model is a two-stage pipeline:
- Feature extraction: A shallow ConvNet (two temporal conv layers + spatial depthwise conv) inspired by EEGNet produces compact per-epoch embeddings.
- Sequence modeling: A bidirectional GRU over the epoch sequence captures longer temporal dependencies at the recording level.
Final classification uses a sigmoid head for binary normal/abnormal prediction.
class NeuroGATE(nn.Module):
def __init__(self, n_channels=19, n_classes=1):
super().__init__()
self.temporal = nn.Sequential(
nn.Conv2d(1, 8, kernel_size=(1, 64), padding=(0, 32), bias=False),
nn.BatchNorm2d(8),
)
self.spatial = nn.Sequential(
nn.Conv2d(8, 16, kernel_size=(n_channels, 1), groups=8, bias=False),
nn.BatchNorm2d(16),
nn.ELU(),
nn.AvgPool2d((1, 4)),
)
self.gru = nn.GRU(input_size=16*32, hidden_size=128,
bidirectional=True, batch_first=True)
self.classifier = nn.Linear(256, n_classes)
def forward(self, x):
# x: (B, T, C, S) — batch, epochs, channels, samples
B, T, C, S = x.shape
x = x.view(B*T, 1, C, S)
x = self.spatial(self.temporal(x))
x = x.flatten(1).view(B, T, -1)
_, h = self.gru(x)
h = torch.cat([h[-2], h[-1]], dim=-1)
return self.classifier(h)
Results
On the TUH Abnormal EEG Corpus test set, NeuroGATE achieves:
| Metric | Score |
|---|---|
| AUROC | 0.89 |
| Sensitivity | 0.84 |
| Specificity | 0.82 |
These are competitive with published baselines while using a significantly smaller model (< 200K parameters).
What's Next
We're currently exploring self-supervised pretraining on unlabeled EEG data to reduce dependence on the relatively small labeled set. Stay tuned.