Skip to main content Inicio Creadores hiyenwong ai_collection eeg-criticality-deep-sleep-classification-neurofeedback
eeg-criticality-deep-sleep-classification-neurofeedback Deep Sleep Classification via EEG Signal Criticality using Detrended Fluctuation Analysis (DFA) for passive Brain-Computer Interface (pBCI) neurofeedback applications. Probabilistic decoding of EEG criticality features for state-dependent sleep improvement interventions.
Ir a la instalación Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/hiyenwong/ai_collection --skill eeg-criticality-deep-sleep-classification-neurofeedbackEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... Ocupaciones relacionadas SOC
Basado en la clasificación ocupacional SOC
name eeg-criticality-deep-sleep-classification-neurofeedback description Deep Sleep Classification via EEG Signal Criticality using Detrended Fluctuation Analysis (DFA) for passive Brain-Computer Interface (pBCI) neurofeedback applications. Probabilistic decoding of EEG criticality features for state-dependent sleep improvement interventions. version 1.0.0 category neuroscience authors ["Stanisław Narębski","Tomasz Komendziński","Tomasz M. Rutkowski"] arxiv_id 2606.13017 published 2026-06-11T00:00:00.000Z activation_keywords ["EEG criticality","deep sleep classification","DFA detrended fluctuation analysis","passive BCI","neurofeedback","sleep staging","N3 sleep","state-dependent intervention","probabilistic decoding","manifold learning"] related_skills ["eeg-foundation-model-adapters","eeg-test-time-adaptation-benchmark","bci-rehabilitation-protocols","sleep-like-consolidation-llm"]
EEG Criticality Deep Sleep Classification for Neurofeedback
Overview
This methodology presents a probabilistic decoding approach for deep sleep (N3) identification using EEG signal criticality features derived from Detrended Fluctuation Analysis (DFA). The framework enables passive Brain-Computer Interface (pBCI) applications for state-dependent neurofeedback interventions such as targeted auditory stimulation for cognitive recovery enhancement.
Core Innovation
Criticality-Based Features : DFA-derived scaling exponents capture sleep state transitions
Manifold Visualization : UMAP reveals non-linear criticality manifold structure
Bayesian Classification : Naive Bayes achieves 87.17% accuracy, outperforming deep networks
Clinical Dataset : 347,232 EEG epochs from 290 older women (real-world validation)
Scientific Foundation
Criticality Theory in Sleep Dynamics
The brain exhibits critical dynamics during sleep, characterized by:
Scale-free fluctuations : Long-range temporal correlations
Phase transitions : Sharp changes between sleep stages
Neural avalanches : Cascading activity patterns
Optimal information processing : Balance at critical point
Detrended Fluctuation Analysis (DFA)
DFA quantifies self-similarity and scaling behavior :
Algorithm :
Input: Time series x(t) of length N
Integrate: y(k) = Σᵢ₌₁ᵏ (xᵢ - ⟨x⟩)
For window sizes n:
- Divide into N/n segments
- Fit local trend yₙ(k) in each segment
- Compute fluctuation: F(n) = √(1/N Σₖ (y(k) - yₙ(k))²)
Scaling exponent α: F(n) ~ n^α
Interpretation :
α < 0.5: Anti-correlated (subcritical)
α = 0.5: Random (uncorrelated)
0.5 < α < 1.0: Long-range correlated (critical)
α = 1.0: 1/f noise (pink noise)
α > 1.0: Non-stationary (supercritical)
Sleep Stage Signatures :
Wake : α ≈ 0.5-0.7 (mild correlations)
N1 (light sleep) : α ≈ 0.6-0.8
N2 (intermediate) : α ≈ 0.7-0.9
N3 (deep sleep) : α ≈ 0.9-1.2 (strong correlations)
REM : α ≈ 0.5-0.6 (closer to wake)
Criticality as Sleep Biomarker Deep sleep (N3) exhibits highest criticality :
Enhanced long-range temporal correlations
Slow oscillation synchronization
Cortical down-states propagation
Memory consolidation window
Methodology Implementation
Step 1: EEG Data Preprocessing Dataset: 347,232 epochs from 290 older women
- Channel: Single-channel EEG (typically F3 or C3)
- Epoch duration: 30 seconds (standard sleep staging)
- Sampling rate: 100-256 Hz
- Preprocessing:
1. Bandpass filter: 0.5-35 Hz (preserve slow oscillations)
2. Artifact removal: ICA or wavelet denoising
3. Epoch extraction: 30-second non-overlapping windows
Step 2: DFA Feature Extraction For each epoch:
1. Compute DFA scaling exponent α
- Window sizes: n = 4 to n = N/4 (multiscale)
- Linear regression in log-log space
- Extract α as primary criticality feature
2. Extended features:
- α_short: scaling for short windows (4-16 samples)
- α_long: scaling for long windows (N/8 - N/4)
- α_ratio: α_long / α_short (measure of non-stationarity)
- F(n) trajectory: full fluctuation curve (multiscale representation)
Step 3: UMAP Manifold Learning Purpose: Visualize state transitions in criticality space
Implementation:
1. Input: DFA features across all epochs
2. UMAP parameters:
- n_neighbors: 15-30 (local structure)
- min_dist: 0.1-0.5 (cluster tightness)
- metric: euclidean or cosine
3. Visualization:
- Color by sleep stage (Wake, N1, N2, N3, REM)
- Identify N3 cluster structure
- Assess manifold geometry (linear vs. non-linear)
Key Finding: DFA features reside on **non-linear manifold**
- Linear classifiers fail (LDA: 57.21%, SVM: 51.01%)
- Deep networks struggle (FNN: 81.58%)
- Probabilistic models succeed (Naive Bayes: 87.17%)
Step 4: Classifier Benchmarking Models tested (10-fold cross-validation):
1. Naive Bayes: 87.17% ± 0.24% (BEST)
2. Random Forest: 80.97%
3. Fully Connected Network (FNN): 81.58%
4. LDA: 57.21% (POOR)
5. SVM: 51.01% (POOR)
Evaluation metric: Balanced accuracy
- Addresses class imbalance (N3 less common than N2/N1)
- Weighted by class frequency
- Suitable for clinical deployment
Step 5: Probabilistic Decoding Pipeline Naive Bayes classifier:
- Prior probabilities: P(N3), P(not-N3) from dataset
- Likelihood: Gaussian modeled from DFA distribution
- Posterior: P(N3|α) = P(α|N3)P(N3) / P(α)
Decision rule:
- Threshold posterior probability (e.g., 0.5)
- Output: binary classification (N3 vs. not-N3)
State-sensing engine:
- Continuous probability output
- Enables soft decision-making
- Supports confidence-weighted neurofeedback
Criticality-Based Neurofeedback Design
State-Dependent Intervention Targeted Auditory Stimulation Protocol :
Trigger Condition :
if P(N3|α) > threshold:
# Deep sleep detected
# Check duration criterion
if consecutive_N3_epochs > 90 seconds:
# Sufficient N3 consolidation
deliver_stimulation()
Stimulation Parameters :
Auditory clicks : 50-100 ms duration
Timing : Phase-locked to slow oscillations
Frequency : 0.8-2 Hz (slow oscillation range)
Intensity : Below arousal threshold
Mechanism :
Enhance slow oscillation power
Boost memory consolidation
Increase hippocampal-cortical coupling
Extend deep sleep duration
Closed-Loop Implementation Real-time pBCI pipeline:
1. Continuous EEG acquisition
2. Epoch DFA computation (30-second windows)
3. Naive Bayes classification
4. Probability smoothing (temporal filter)
5. Decision threshold comparison
6. Stimulation trigger generation
7. Auditory delivery via earphones
8. Feedback loop: monitor α changes post-stimulation
Empirical Results
Dataset Characteristics
Participants : 290 older women (65-85 years)
Epochs : 347,232 total (~1,200 per participant)
N3 prevalence : ~15-20% of total epochs
Recording : Full-night polysomnography
Classification Performance
UMAP Manifold Insights
N3 cluster : Well-separated from other stages
Transition paths : Visible Wake→N1→N2→N3 trajectory
Non-linearity : High curvature manifold
Interpretation : Criticality as phase order parameter
Advantages Over Traditional Methods
vs. Spectral Features (PSD)
Criticality : Captures temporal structure, not just frequency content
DFA : Insensitive to transient artifacts
Biophysical : Links to neural avalanche dynamics
vs. Deep Learning (CNN/RNN)
Naive Bayes : 5.59% higher accuracy than FNN
Computational efficiency : Real-time viable on embedded hardware
Interpretability : Probabilistic framework, transparent decision-making
vs. Standard Sleep Scoring (Manual)
Automated : No expert annotation required
Continuous : Probabilistic output, not discrete labels
Objective : DFA derived from physics, not heuristic rules
Pitfalls and Limitations
1. Single Channel Dependency
Issue : DFA computed from single EEG channel
Mitigation : Use multiple channels, spatial averaging
Alternative : Multi-channel criticality analysis
2. Epoch Duration Constraints
Issue : 30-second epochs may miss short N3 episodes
Mitigation : Adaptive epoch sizing
Alternative : Continuous DFA sliding window
3. Age Group Specificity
Issue : Validated on older women (65-85)
Mitigation : Cross-age validation studies
Alternative : Age-stratified training
4. Noise Sensitivity
Issue : DFA requires clean signals for accurate α
Mitigation : Robust artifact rejection
Alternative : Noise-robust DFA variants
5. Threshold Optimization
Issue : Decision threshold affects false positive rate
Mitigation : ROC curve analysis, clinical tuning
Alternative : Adaptive thresholding
Clinical Applications
1. Sleep Quality Enhancement
Target : Older adults with reduced N3 sleep
Protocol : Nightly auditory stimulation
Outcome : Extended N3 duration, improved memory
2. Cognitive Rehabilitation
Target : Post-stroke, dementia patients
Protocol : N3-targeted neurofeedback
Outcome : Enhanced memory consolidation
3. Sleep Disorder Diagnosis
Target : Insomnia, sleep apnea patients
Protocol : Automated N3 quantification
Outcome : Objective sleep quality metric
4. Home Sleep Monitoring
Target : Consumer sleep tracking
Protocol : Single-channel EEG headband
Outcome : Real-time N3 detection and tracking
Implementation Code
DFA Computation import numpy as np
def detrended_fluctuation_analysis (signal, window_sizes ):
"""
Compute DFA scaling exponent α
Parameters:
- signal: EEG time series (1D array)
- window_sizes: List of window sizes n
Returns:
- alpha: Scaling exponent
- fluctuations: F(n) curve
"""
N = len (signal)
y = np.cumsum(signal - np.mean(signal))
fluctuations = []
for n in window_sizes:
n_segments = N // n
F_n_values = []
for i in range (n_segments):
segment = y[i*n:(i+1 )*n]
x_segment = np.arange(n)
trend = np.polyfit(x_segment, segment, 1 )
y_trend = np.polyval(trend, x_segment)
F_n = np.sqrt(np.mean((segment - y_trend)**2 ))
F_n_values.append(F_n)
F_n_avg = np.mean(F_n_values)
fluctuations.append(F_n_avg)
log_n = np.log(window_sizes)
log_F = np.log(fluctuations)
alpha, _ = np.polyfit(log_n, log_F, 1 )
return alpha, fluctuations
eeg_epoch = load_eeg_epoch()
window_sizes = [4 , 8 , 16 , 32 , 64 , 128 , 256 ]
alpha, F_n = detrended_fluctuation_analysis(eeg_epoch, window_sizes)
print (f"Criticality exponent α = {alpha:.3 f} " )
Naive Bayes Classifier from sklearn.naive_bayes import GaussianNB
from sklearn.model_selection import cross_val_score
import umap
class DeepSleepClassifier :
def __init__ (self ):
self .nb_classifier = GaussianNB()
self .umap_reducer = umap.UMAP(
n_neighbors=20 ,
min_dist=0.3
)
def extract_features (self, eeg_epochs ):
"""
Extract DFA features from EEG epochs
Parameters:
- eeg_epochs: List of 30-second EEG segments
Returns:
- features: DFA scaling exponents α
"""
features = []
for epoch in eeg_epochs:
alpha, _ = detrended_fluctuation_analysis(
epoch,
window_sizes=[4 , 8 , 16 , 32 , 64 , 128 ]
)
features.append(alpha)
return np.array(features)
def fit (self, features, labels ):
"""
Train Naive Bayes classifier
Parameters:
- features: DFA scaling exponents
- labels: Binary (N3=1, not-N3=0)
"""
scores = cross_val_score(
self .nb_classifier,
features.reshape(-1 , 1 ),
labels,
cv=10 ,
scoring='balanced_accuracy'
)
print (f"Cross-validation accuracy: {scores.mean():.3 f} ± {scores.std():.3 f} " )
self .nb_classifier.fit(features.reshape(-1 , 1 ), labels)
def predict_proba (self, eeg_epoch ):
"""
Predict deep sleep probability
Returns:
- probability: P(N3|α) between 0-1
"""
alpha, _ = detrended_fluctuation_analysis(
eeg_epoch,
window_sizes=[4 , 8 , 16 , 32 , 64 , 128 ]
)
prob = self .nb_classifier.predict_proba([[alpha]])[0 , 1 ]
return prob
def visualize_manifold (self, features, labels ):
"""
UMAP visualization of criticality manifold
"""
embedding = self .umap_reducer.fit_transform(
features.reshape(-1 , 1 )
)
plt.scatter(
embedding[:, 0 ],
embedding[:, 1 ],
c=labels,
cmap='viridis'
)
plt.title('DFA Criticality Manifold' )
plt.xlabel('UMAP 1' )
plt.ylabel('UMAP 2' )
plt.colorbar(label='N3 Probability' )
plt.show()
classifier = DeepSleepClassifier()
features = classifier.extract_features(eeg_epochs)
classifier.fit(features, sleep_labels)
classifier.visualize_manifold(features, sleep_labels)
current_epoch = acquire_eeg_epoch()
p_n3 = classifier.predict_proba(current_epoch)
if p_n3 > 0.8 :
trigger_stimulation()
Closed-Loop Neurofeedback class SleepNeurofeedbackSystem :
def __init__ (self, classifier, stimulation_device ):
self .classifier = classifier
self .stimulation = stimulation_device
self .n3_buffer = []
self .threshold = 0.75
self .min_duration = 3
def process_epoch (self, eeg_epoch ):
"""
Real-time epoch processing
"""
p_n3 = self .classifier.predict_proba(eeg_epoch)
if p_n3 > self .threshold:
self .n3_buffer.append(p_n3)
else :
self .n3_buffer = []
if len (self .n3_buffer) >= self .min_duration:
self .deliver_stimulation()
self .n3_buffer = []
def deliver_stimulation (self ):
"""
Targeted auditory stimulation
"""
click_duration = 80
frequency = 1
intensity = 0.5
self .stimulation.play_click(
duration=click_duration,
frequency=frequency,
intensity=intensity
)
log_neurofeedback_event(
timestamp=time.time(),
n3_duration=len (self .n3_buffer) * 30 ,
stimulation_params={
'duration' : click_duration,
'frequency' : frequency,
'intensity' : intensity
}
)
def run_realtime (self, duration_hours=8 ):
"""
Full-night closed-loop operation
"""
for _ in range (duration_hours * 3600 // 30 ):
epoch = acquire_eeg_epoch()
self .process_epoch(epoch)
sleep(30 )
system = SleepNeurofeedbackSystem(
classifier=DeepSleepClassifier(),
stimulation_device=AuditoryStimulator()
)
system.run_realtime(duration_hours=8 )
References
Narębski, S., Komendziński, T., & Rutkowski, T.M. (2026). "Deep Sleep Classification via EEG Signal Criticality: A Passive BCI Approach for Sleep-Improvement Neurofeedback." arXiv:2606.13017. Graz BCI Conference 2026.
Peng, C.K. et al. (1994). "Mosaic organization of DNA nucleotides." Physical Review E. (Original DFA method)
Nishimiya, T. et al. (2024). "Phase-locked auditory stimulation during deep sleep." Scientific Reports.
Lemieux, M. et al. (2024). "Closed-loop auditory stimulation for memory enhancement." Nature Communications.
Related Research
Slow Oscillation Enhancement : Auditory stimulation synchronized to cortical down-states
Memory Consolidation : N3-dependent hippocampal-cortical dialogue
Brain Criticality : Phase transitions in neural dynamics
DFA Applications : Heart rate variability, gait analysis, stock markets
Sleep EEG Biomarkers : Alternative features (spectral power, coherence, entropy)
Example Clinical Application Patient Profile : 72-year-old woman with reduced N3 sleep (15% vs. normal 20-25%), mild cognitive impairment.
Assessment : Full-night PSG with EEG DFA analysis
Baseline : N3 duration quantification via criticality classifier
Intervention : 8-hour closed-loop auditory stimulation
Outcome Metrics :
N3 duration: +30% increase
Memory test (word recall): +15% improvement
Subjective sleep quality: Improved
patient_classifier = DeepSleepClassifier()
patient_data = load_patient_eeg(patient_id='P001' )
features = patient_classifier.extract_features(patient_data)
fpr, tpr, thresholds = roc_curve(labels, features)
optimal_threshold = thresholds[np.argmax(tpr - fpr)]
system = SleepNeurofeedbackSystem(
classifier=patient_classifier,
stimulation_device=AuditoryStimulator()
)
system.threshold = optimal_threshold
pre_n3 = quantify_n3_duration(patient_data['baseline' ])
post_n3 = quantify_n3_duration(patient_data['post_stimulation' ])
improvement = (post_n3 - pre_n3) / pre_n3 * 100
print (f"N3 improvement: {improvement:.1 f} %" )