Pranov888 commited on
Commit
77ac706
·
verified ·
1 Parent(s): 0d8d370

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +185 -0
README.md ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - eeg
5
+ - depression
6
+ - mental-health
7
+ - mdd
8
+ - biosignals
9
+ - ensemble
10
+ - pytorch
11
+ - xgboost
12
+ - svm
13
+ - neuroscience
14
+ datasets:
15
+ - figshare-eeg-depression
16
+ metrics:
17
+ - accuracy
18
+ - roc_auc
19
+ - f1
20
+ language: []
21
+ model-index:
22
+ - name: EEG Depression Detection V4
23
+ results:
24
+ - task:
25
+ type: classification
26
+ name: EEG-based MDD Detection
27
+ dataset:
28
+ name: Figshare EEG Depression (64 subjects, LOSO CV)
29
+ type: figshare-eeg-depression
30
+ metrics:
31
+ - type: accuracy
32
+ value: 0.9688
33
+ name: Subject Accuracy (threshold=0.575)
34
+ - type: roc_auc
35
+ value: 0.9980
36
+ name: AUC-ROC
37
+ - type: f1
38
+ value: 0.9714
39
+ name: F1 Score (threshold=0.575)
40
+ ---
41
+
42
+ # EEG-Based Depression (MDD) Detection — V4 Ensemble
43
+
44
+ **Leave-One-Subject-Out (LOSO) cross-validated EEG classifier for Major Depressive
45
+ Disorder, achieving 96.88 % subject-level accuracy and 99.80 % AUC-ROC on 64 subjects
46
+ from the public figshare EEG dataset.**
47
+
48
+ ---
49
+
50
+ ## Model Architecture
51
+
52
+ This is a **3-model heterogeneous ensemble**:
53
+
54
+ | Component | Details |
55
+ |-----------|---------|
56
+ | **1D-CNN** (weight=0.60) | Multi-scale convolution stem → 4 × ResBlock1D + SEBlock1D → GlobalAvgPool → MLP. Input: raw EEG (19 ch × 1000 samples). |
57
+ | **XGBoost** (weight=0.25) | 800 estimators, max_depth=6, trained on 1047-dim handcrafted features. |
58
+ | **SVM** (weight=0.15) | RBF kernel (C=10, γ=scale), trained on the same 1047-dim features. |
59
+
60
+ Epoch-level probabilities from each model are aggregated as a weighted sum, then
61
+ subject-level probability is the trimmed mean (5 % trim) of epoch probabilities.
62
+
63
+ ### Handcrafted Feature Set (1047 dimensions)
64
+
65
+ | Group | Dims | Description |
66
+ |-------|------|-------------|
67
+ | Spectral power | 95 | Band power per channel (δ/θ/α/β/γ) |
68
+ | Temporal stats | 171 | Mean, variance, skewness, kurtosis, Hjorth params, zero-crossing rate |
69
+ | Wavelet / WPD | 304 | Wavelet Packet Decomposition energy + entropy |
70
+ | Connectivity | 342 | Phase Locking Value + coherence between all channel pairs |
71
+ | Asymmetry | 40 | Frontal/temporal α asymmetry (8 electrode pairs) |
72
+ | Band ratios | 95 | Cross-band power ratios per channel |
73
+
74
+ ---
75
+
76
+ ## Performance (LOSO Cross-Validation, 64 subjects)
77
+
78
+ | Metric | Threshold=0.575 |
79
+ |--------|-----------------|
80
+ | Subject Accuracy | **96.88 %** (62/64) |
81
+ | AUC-ROC | **99.80 %** |
82
+ | Sensitivity (MDD recall) | 100 % |
83
+ | Specificity (Healthy recall) | 93.3 % |
84
+ | F1 Score | 97.14 % |
85
+
86
+ *Post-hoc threshold optimisation on LOSO predictions (threshold=0.575) yields 96.88 %
87
+ accuracy while maintaining 100 % sensitivity — no MDD subject is ever missed.*
88
+
89
+ ---
90
+
91
+ ## Dataset
92
+
93
+ - **Source**: [figshare EEG dataset](https://figshare.com/articles/dataset/EEG_Data_New/4244171)
94
+ - **Subjects**: 64 (34 MDD, 30 Healthy Controls)
95
+ - **EDF files**: 181
96
+ - **Channels**: 19 (standard 10-20 system)
97
+ - **Signal**: Bandpass 1–45 Hz, notch 50/60 Hz, resampled to 250 Hz
98
+ - **Epochs**: 4 s, 50 % overlap → ~570 epochs/subject on average
99
+ - **Total epochs**: 36,247
100
+
101
+ ---
102
+
103
+ ## Repository Files
104
+
105
+ ```
106
+ models/
107
+ final/
108
+ cnn_final.pt # CNN state dict (trained on all 64 subjects)
109
+ xgboost_final.json # XGBoost model (all 64 subjects)
110
+ svm_and_scaler_final.pkl # SVM + StandardScaler (all 64 subjects)
111
+ fold_NN_SID/ # One directory per LOSO fold (64 total)
112
+ cnn_weights.pt
113
+ xgboost.json
114
+ svm_and_scaler.pkl
115
+ checkpoints/
116
+ fold_NN_SID.pkl # Per-fold LOSO results (probs, labels, metrics)
117
+ config/
118
+ model_config.yaml
119
+ data_config.yaml
120
+ training_config.yaml
121
+ test_loso_results.json # Metrics from test_loso.py
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Usage
127
+
128
+ ### Load CNN
129
+
130
+ ```python
131
+ import torch
132
+ from eeg_depression_detection.models.full_model import EEG1DCNN # adjust import path
133
+
134
+ CNN_CONFIG = dict(
135
+ n_channels=19,
136
+ n_samples=1000,
137
+ n_classes=2,
138
+ )
139
+ model = EEG1DCNN(**CNN_CONFIG)
140
+ state = torch.load("models/final/cnn_final.pt", map_location="cpu")
141
+ model.load_state_dict(state)
142
+ model.eval()
143
+ ```
144
+
145
+ ### Load XGBoost
146
+
147
+ ```python
148
+ import xgboost as xgb
149
+ xgb_model = xgb.XGBClassifier()
150
+ xgb_model.load_model("models/final/xgboost_final.json")
151
+ ```
152
+
153
+ ### Load SVM + Scaler
154
+
155
+ ```python
156
+ import pickle
157
+ with open("models/final/svm_and_scaler_final.pkl", "rb") as f:
158
+ bundle = pickle.load(f)
159
+ svm_model = bundle["svm"]
160
+ scaler = bundle["scaler"]
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Citation
166
+
167
+ If you use this model or dataset pipeline in your research, please cite:
168
+
169
+ ```bibtex
170
+ @misc{eeg_depression_v4,
171
+ author = {Pranov prahaladh},
172
+ title = {EEG Depression Detection V4 Ensemble},
173
+ year = {2026},
174
+ publisher = {HuggingFace},
175
+ howpublished = {\url{https://huggingface.co/lebiraja/eeg-depression-v4-full}},
176
+ }
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Licence
182
+
183
+ MIT — see [LICENSE](https://github.com/pranov888/eeg-depression/blob/main/LICENSE)
184
+
185
+ *Generated 2026-03-11*