Label-Indexed Channel Attention for Structured Sleep Staging

Models that read many sensors at once, such as a full overnight sleep recording with a dozen EEG, eye, and muscle channels, usually do two things in separate places. First, an attention layer (a learned weighting that decides how much each input contributes) picks which sensors to trust. Second, a structured output layer called a conditional random field, or CRF (a model that scores whole label sequences, so that "awake, then deep sleep, then awake" can be judged implausible as a unit), keeps the predicted sleep stages consistent over the night. In current systems the sensor-selection step does not know which label it is serving. It produces one channel weighting per 30-second epoch and hands a single summary vector to the classifier.

This proposal joins the two steps. Each candidate stage gets its own channel attention, and so does each candidate stage transition, and these become the CRF's scores. "Is this epoch REM?" is then answered by looking at the eye and chin-muscle channels. "Is this the moment N2 turns into REM?" is answered by comparing those channels across the boundary. The CRF still performs exact whole-night decoding. The bet is that tying sensor selection to labels and transitions improves the hardest, transition-heavy parts of sleep staging, chiefly stage N1 and stage boundaries. It should also make the model more robust when channels are corrupted, and it yields per-transition sensor relevance maps that can be checked against clinical scoring rules.

Core Claim

The obvious combination at this intersection is to put a CRF on top of an existing dual-attention sleep model. That idea is close to done and is unlikely to be interesting by itself. TSA-Net already runs flat multi-head self-attention over time-spectral CNN features and adds a linear-chain CRF, on single-channel EEG. Adding a channel-attention stage to that design is a small engineering step.

The claim here is different. The feature stage of dual attention should be indexed by the CRF's output variables, and the CRF's transition scores should depend on the input through their own channel attention, rather than being one learned constant matrix. Concretely, let $h_{t,c}$ be the embedding of channel $c$ at epoch $t$ after a within-epoch encoder and a cross-epoch temporal attention stage. For each stage $k$ there is a learned query, which produces channel weights $\alpha^{(k)}_{t,c}$. For each stage pair $(j,k)$ there is a second query, which produces weights $\beta^{(jk)}_{t,c}$ over the concatenated neighbouring embeddings $[h_{t-1,c}; h_{t,c}]$. The model is

$$p(\boldsymbol{y}\mid\boldsymbol{x}) \propto \exp\Big(\sum_{t} w_{y_t}^{\top}\sum_{c}\alpha^{(y_t)}_{t,c}h_{t,c} \;+\; \sum_{t} \big[A_{y_{t-1}y_t} + v_{y_{t-1}y_t}^{\top}\sum_{c}\beta^{(y_{t-1}y_t)}_{t,c}[h_{t-1,c};h_{t,c}]\big]\Big),$$

where $w_k$ and $v_{jk}$ are per-label and per-transition output vectors and $A$ is the usual constant transition matrix, kept as a prior. Because every score depends only on adjacent labels, forward-backward and Viterbi inference stay exact, at cost $O(TK^2)$ for $T$ epochs and $K$ stages. With $K=5$ there are only 25 transition queries.

Relation to Prior Work

Three groups of papers frame the proposal.

The first group supplies the factorized input attention we reuse. DA-RNN separates input-series attention from temporal attention for forecasting, and shows that input attention gives near-zero weight to 81 injected noise series. HybridAtt applies channel-wise plus time-wise attention to multi-sensor recordings. HASS adds inter- and intra-channel attention to existing EEG backbones. MSDAN serializes channel and temporal attention within an epoch. All of these compute one label-agnostic channel weighting and end in an independent softmax per epoch. We keep their two-axis factorization but make the channel axis label-indexed and place it inside the CRF.

The second group supplies the structured decoding and motivates the gap. The neural CRF for sleep staging puts a linear-chain CRF on a CNN-GRU over CPAP airflow, with no attention at all. It reports 74.1% accuracy and kappa 0.57 on MESA with a cost-sensitive prior, and it explicitly leaves open how structured transitions combine with richer encoders. Jagannatha shows in clinical text that independent per-token softmax yields structurally invalid label sequences. TSA-Net is the closest system, and it differs from ours on both axes: its attention is single-stage and its transition matrix is constant.

The third group constrains the design. TransSleep handles transitions with an auxiliary transition-detection loss and a 25-epoch BiLSTM context encoder, without a CRF. It reaches 87.4% accuracy and 82.6% macro-F1 on MASS. This is strong evidence that a good sequence encoder already absorbs much transition structure, so any CRF benefit must be shown on top of such an encoder, not instead of it. ACRF-RNN uses "CRF" in a different role, as attention-weighted smoothing of embeddings across companies. That confirms the word covers relational as well as sequential uses, but its design does not decode temporal labels and is not a competitor. Bregman CRFs parallelize CRF inference, training up to 7.3x faster on POS tagging. With five labels, exact inference is not our bottleneck, so we treat their code (lightspeed-crf) only as an optional speedup for whole-night training. It is not part of the claim.

Research Program

We will build one encoder and keep it fixed across all variants. It consists of a per-channel 1D CNN over each 30-second epoch, followed by a temporal attention stage over a window of neighbouring epochs, which produces $h_{t,c}$. The variants differ only in the output head:

  • an independent softmax over a label-agnostic channel pool;
  • a constant-transition CRF over that pool, which is the obvious combination;
  • label-indexed emissions with constant transitions;
  • the full model with label-indexed emissions and transition-indexed, input-dependent pairwise scores.

Training maximizes the exact CRF log-likelihood over whole-night sequences, with the cost-sensitive class prior from the neural CRF paper available to every CRF variant so that the minority stage N1 is not erased.

The analysis has two parts. The first is the transition-indexed weights $\beta^{(jk)}$, which show which channels the model consults for each stage change. Clinical scoring practice gives concrete expectations to test against. Chin muscle tone and eye movements should dominate transitions into REM, and occipital or frontal EEG plus eye channels should dominate wake-to-N1. Agreement with these expectations is a falsifiable sanity check, not a decoration. The second part is robustness. Following the noise-injection protocol of DA-RNN, we replace or zero random channels at test time and measure how gracefully each variant degrades.

Baselines

The naive reference point is the shared encoder with a label-agnostic channel pool and an independent per-epoch softmax, trained with the same class weighting. Every other gain is measured from it. We will also report post-hoc smoothing of its outputs with a first-order hidden Markov model whose transition matrix is estimated from training hypnograms, because that is the cheapest way to get transition consistency.

The strongest competitor on the actual question is the obvious combination: HybridAtt-style dual attention (HybridAtt) followed by a constant-transition linear-chain CRF, in the style of TSA-Net. We implement it on our shared encoder so that it has identical data splits, epoch windows, optimizer, and tuning budget, with the same number of hyperparameter trials per variant. We widen its channel-attention MLP so that its parameter count matches the full model's. On UCD, the only reported anchor in the file is HybridAtt's 0.7424 accuracy without a CRF. On MASS, the strongest reported system in the file is TransSleep at 87.4% accuracy and 82.6% macro-F1. On ISRUC, HASS reports TinySleepNet's F1 rising from 0.751 to 0.774. We will rerun TransSleep and HASS under our splits rather than rely on these numbers, because subject partitions differ across papers. To count as beating the obvious combination, the full model must improve N1 F1 and accuracy on epochs adjacent to a stage change. The improvement must exceed the variation across random seeds, measured over five seeds with subject-level cross-validation, and overall accuracy must not fall.

Two ablations isolate the key ingredient. Label-indexed emissions with constant transitions tests whether label-specific sensor selection matters on its own. A label-indexed softmax with no CRF tests whether that selection needs the structured layer at all.

Why not just…?

Why not just put a CRF on top of HybridAtt or HASS? That is the main baseline, and it is a real threat. If label-agnostic channel attention already gives the CRF good emissions, our indexing adds parameters for nothing. The evidence that it might fall short is indirect. A single channel weighting per epoch has to serve all five stage decisions and all 25 transition decisions at once, even though clinical scoring consults different channels for different stages. The matched-parameter comparison above settles this directly. If the full model does not beat the obvious combination on transition-adjacent epochs, we will report that the obvious combination suffices.

Why not just rely on a strong sequence encoder, as TransSleep does? TransSleep reaches 55.5% N1 F1 on Sleep-EDF without any CRF, so a 25-epoch BiLSTM may already capture most transition structure. Our encoder therefore includes cross-epoch temporal attention in every variant. The CRF gain we report is measured on top of that encoder, not against an encoder with no sequence context. A near-zero gain would be a real negative result, and we would publish it as such.

Why not just smooth softmax outputs with an HMM afterwards? Post-hoc smoothing enforces plausible transitions at almost no cost. However, it cannot change which sensors were consulted, and it cannot make a transition score depend on the signal at the boundary. The HMM-smoothed baseline, compared against the input-dependent transition variant, measures exactly this. If the two tie under clean inputs but diverge under channel corruption, that tells us where the value lies.

Why not just use per-label channel attention with a softmax and skip the CRF? This is the ablation that could undercut the CRF half of the proposal. If the label-indexed softmax matches the full model, the contribution reduces to label-specific pooling. Transition-indexed attention, however, needs pairwise label variables and has no softmax analogue. Its contribution therefore shows up as the gap between the full model and the label-indexed-emissions-only variant.

Proposed Experiments

The main benchmarks are multi-channel, because sensor selection is the point. We use MASS (20-channel EEG montage), ISRUC (6-channel clinical montage), and the UCD sleep apnea database (14-channel recordings), each with subject-level cross-validation. Sleep-EDF serves as a low-channel control, where we expect little advantage. MSDAN's 91.74% accuracy there is single-channel and not directly comparable. Metrics are overall accuracy, macro-F1, Cohen's kappa, and N1 F1. We add two transition-focused measures: accuracy restricted to epochs within one epoch of a reference stage change, and the ratio of predicted to true transitions per night, which captures label jitter.

The decisive checks are three. First, the full model must beat the matched-parameter constant-transition dual-attention CRF on transition-adjacent accuracy and N1 F1, consistently across MASS and ISRUC. Second, under test-time corruption of 25% and 50% of channels, the full model's macro-F1 must degrade more slowly than both the obvious combination and HMM smoothing. Third, the learned per-transition channel weights must place chin-muscle and eye channels highest for transitions into REM more often than a permutation baseline would, on UCD and ISRUC where those channels exist.

If the first check fails while the second passes, the honest conclusion is that label-indexing buys robustness rather than accuracy. If both fail, the obvious combination is enough and the proposal is refuted.