WindySprint Zachary1150 commited on
Commit
a3b7abb
·
0 Parent(s):

Duplicate from Zachary1150/EESM19-Processed

Browse files

Co-authored-by: Zhikai Li <Zachary1150@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +60 -0
  2. README.md +198 -0
  3. eesm19-in-ear-eeg.h5 +3 -0
  4. eesm19-scalp-eeg.h5 +3 -0
.gitattributes ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.avro filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
7
+ *.ftz filter=lfs diff=lfs merge=lfs -text
8
+ *.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.h5 filter=lfs diff=lfs merge=lfs -text
10
+ *.joblib filter=lfs diff=lfs merge=lfs -text
11
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
13
+ *.mds filter=lfs diff=lfs merge=lfs -text
14
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
+ *.model filter=lfs diff=lfs merge=lfs -text
16
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
17
+ *.npy filter=lfs diff=lfs merge=lfs -text
18
+ *.npz filter=lfs diff=lfs merge=lfs -text
19
+ *.onnx filter=lfs diff=lfs merge=lfs -text
20
+ *.ot filter=lfs diff=lfs merge=lfs -text
21
+ *.parquet filter=lfs diff=lfs merge=lfs -text
22
+ *.pb filter=lfs diff=lfs merge=lfs -text
23
+ *.pickle filter=lfs diff=lfs merge=lfs -text
24
+ *.pkl filter=lfs diff=lfs merge=lfs -text
25
+ *.pt filter=lfs diff=lfs merge=lfs -text
26
+ *.pth filter=lfs diff=lfs merge=lfs -text
27
+ *.rar filter=lfs diff=lfs merge=lfs -text
28
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
29
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
31
+ *.tar filter=lfs diff=lfs merge=lfs -text
32
+ *.tflite filter=lfs diff=lfs merge=lfs -text
33
+ *.tgz filter=lfs diff=lfs merge=lfs -text
34
+ *.wasm filter=lfs diff=lfs merge=lfs -text
35
+ *.xz filter=lfs diff=lfs merge=lfs -text
36
+ *.zip filter=lfs diff=lfs merge=lfs -text
37
+ *.zst filter=lfs diff=lfs merge=lfs -text
38
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
39
+ # Audio files - uncompressed
40
+ *.pcm filter=lfs diff=lfs merge=lfs -text
41
+ *.sam filter=lfs diff=lfs merge=lfs -text
42
+ *.raw filter=lfs diff=lfs merge=lfs -text
43
+ # Audio files - compressed
44
+ *.aac filter=lfs diff=lfs merge=lfs -text
45
+ *.flac filter=lfs diff=lfs merge=lfs -text
46
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
47
+ *.ogg filter=lfs diff=lfs merge=lfs -text
48
+ *.wav filter=lfs diff=lfs merge=lfs -text
49
+ # Image files - uncompressed
50
+ *.bmp filter=lfs diff=lfs merge=lfs -text
51
+ *.gif filter=lfs diff=lfs merge=lfs -text
52
+ *.png filter=lfs diff=lfs merge=lfs -text
53
+ *.tiff filter=lfs diff=lfs merge=lfs -text
54
+ # Image files - compressed
55
+ *.jpg filter=lfs diff=lfs merge=lfs -text
56
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
57
+ *.webp filter=lfs diff=lfs merge=lfs -text
58
+ # Video files - compressed
59
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
60
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc0-1.0
3
+ tags:
4
+ - eeg
5
+ - sleep-staging
6
+ - in-ear-eeg
7
+ - scalp-eeg
8
+ - hdf5
9
+ ---
10
+
11
+ # EESM19-Processed
12
+
13
+ Processed HDF5 export of the [EESM19 OpenNeuro dataset](https://doi.org/10.18112/openneuro.ds005185.v1.0.2) ("Ear-EEG Sleep Monitoring 2019", Mikkelsen et al., Aarhus University). It contains paired in-ear EEG and scalp EEG sleep-staging samples from the four home-sleep nights (`ses-001`–`ses-004`) of all 20 subjects — the nights recorded with **simultaneous partial PSG and ear-EEG** on one amplifier.
14
+
15
+ ## Preprocessing
16
+
17
+ Generated with `Ear-EEG-FM-Benchmark/dataset/preprocess_eesm19.py` using schema/eegfm version `0.5.0`:
18
+
19
+ - 0.1–100 Hz band-pass and 50 Hz notch filtering on each continuous recording
20
+ - no re-referencing, resampling, or channel renaming
21
+ - **each labeled 30-second AASM scoring event is stored as one 30-second window** (one sample = one epoch = one label = one prediction — the canonical sleep-staging unit)
22
+ - classes: `Wake`, `N1`, `N2`, `N3`, `REM`; `Artefact`/`Movement`/`Unscored` events are dropped
23
+ - real sensor/data-loss NaN/Inf samples are preserved and recorded in overall and per-channel quality fields
24
+ - all signal values are stored as `float32` microvolts at 500 Hz (15,000 samples per window)
25
+
26
+ ### Why 30-second windows (and how to get 4-second windows)
27
+
28
+ The 30-second epoch is the unit at which sleep is scored (AASM) and evaluated:
29
+ the benchmark's reference foundation models (BENDR, EEGPT, CBraMod, REVE, and the
30
+ EEGPT comparison implementations of LaBraM/BIOT) all ingest full 30-second epochs
31
+ downstream and emit one stage prediction per epoch. EEGPT in particular shows a
32
+ 4-second-pretrained backbone fine-tunes directly on 30-second sleep inputs. We
33
+ therefore store the full epoch rather than splitting one label into several
34
+ independently-scored short windows.
35
+
36
+ Storing 30 s loses nothing relative to a shorter export: it is a strict superset.
37
+ The benchmark loader (`dataset/loader.py`) accepts an `epoch_sec` argument and
38
+ crops a shorter window from each stored sample at load time, so a 4-second (or
39
+ any ≤30 s) view is available from these files without re-exporting. The reverse —
40
+ reconstructing a 30 s epoch from stored 4 s slices — is not possible, which is
41
+ why the 4-second layout used by `EESM23-Processed` is not used here.
42
+
43
+ Brief device data-loss gaps are interpolated before filtering to prevent FIR-kernel contamination, after which the original NaN positions are restored before window selection. A fully-dead channel (all-NaN for a night, e.g. `sub-001/ses-004` F3) is left NaN and flagged in the per-channel quality fields.
44
+
45
+ ### Notes specific to EESM19 (differences from EESM23-Processed)
46
+
47
+ Two things differ from the EESM23 export and are worth reading before use:
48
+
49
+ 1. **Single source file → inherently paired.** On these nights the ear and scalp
50
+ channels are recorded together in one file, `*_task-sleep_acq-PSG_eeg.set`
51
+ (there is no separate `acq-earEEG` file — that only exists on the ear-only
52
+ nights `ses-005+`, which are excluded here). Both modalities are sliced from
53
+ the same continuous recording on one shared timeline, so every window is
54
+ present in both — no cross-file pairing/intersection is needed and none is
55
+ dropped for lack of a partner.
56
+
57
+ 2. **Integer sleep-stage codes with a non-standard mapping.** The scoring column
58
+ `Scoring1` holds an integer code, not a string stage name, and the mapping
59
+ (from the dataset's `task-sleep_events.json`) is **not** the usual AASM digit
60
+ order — note `2 = REM` and `5 = N3`:
61
+
62
+ | code | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
63
+ |---|---|---|---|---|---|---|---|---|
64
+ | stage | Wake | REM | N1 | N2 | N3 | A (movement/arousal) | Artefact | Unscored |
65
+
66
+ Codes 6/7/8 are dropped. Labels are re-emitted in the EESM23 class order
67
+ (`Wake, N1, N2, N3, REM`) so class indices line up across datasets. Only the
68
+ **first scorer** (`acq-scoring1`) is used; the second scorer's labels are
69
+ ignored.
70
+
71
+ Channel groups are selected by name (the EEGLAB `.set` marks every channel as
72
+ `eeg`, so EOG/EMG cannot be told apart by type): 12 ear channels
73
+ (`ELA ELB ELC ELT ELE ELI ERA ERB ERC ERT ERE ERI`) and 8 scalp channels
74
+ (`M1 F3 C3 O1 M2 F4 C4 O2`); EOG/EMG are dropped.
75
+
76
+ ## Files
77
+
78
+ | File | Channels | Shape `(N, C, T)` | Size |
79
+ |---|---|---:|---:|
80
+ | `eesm19-in-ear-eeg.h5` | ELA, ELB, ELC, ELT, ELE, ELI, ERA, ERB, ERC, ERT, ERE, ERI | `(73,780, 12, 15000)` | 49.50 GiB |
81
+ | `eesm19-scalp-eeg.h5` | M1, F3, C3, O1, M2, F4, C4, O2 | `(73,780, 8, 15000)` | 33.01 GiB |
82
+
83
+ `T = 15000` is one 30-second epoch at 500 Hz. `N` is the number of scored epochs,
84
+ not a multiple of it — one sample per 30-second AASM epoch.
85
+
86
+ Label distribution (identical for both modalities — the samples are row-aligned):
87
+
88
+ | Wake | N1 | N2 | N3 | REM |
89
+ |---:|---:|---:|---:|---:|
90
+ | 11,084 | 5,421 | 31,508 | 12,497 | 13,270 |
91
+
92
+ ## Retained and discarded epochs
93
+
94
+ Scorer 1 labels 79,058 30-second epochs across the 80 nights (20 subjects ×
95
+ `ses-001`–`ses-004`). Of these, 76,054 carry one of the five retained sleep-stage
96
+ labels and 3,004 are labeled `Artefact` (codes 6 and 8 — Movement/Unscored — do
97
+ not occur in this dataset). Each retained epoch becomes exactly one 30-second
98
+ sample, so the final files contain **73,780** strictly paired samples per
99
+ modality. The exclusions from the 76,054 five-class candidates are:
100
+
101
+ | Reason | Epochs |
102
+ |---|---:|
103
+ | Two source-corrupt sessions with unreadable `.set`/`.fdt` (see below) | 2,119 |
104
+ | 30-second epoch not fully inside the recording bounds | 155 |
105
+ | **Total excluded** | **2,274** |
106
+
107
+ (The 3,004 `Artefact` epochs are outside the five-class task and are never
108
+ candidates, so they are listed separately from the table above.)
109
+
110
+ ### Source-corrupt sessions (2 dropped, 2,119 epochs)
111
+
112
+ Each EEGLAB recording is a pair: a `.set` header (metadata — how long the
113
+ recording is, how many channels) and a `.fdt` binary holding the raw signal. Two
114
+ sessions are dropped because **the `.set` header and the `.fdt` binary disagree
115
+ on the recording length**: the `.fdt` is truncated and contains far fewer samples
116
+ than the header declares, so the data matrix cannot be reconstructed and MNE
117
+ refuses to load it (`RuntimeError: Incorrect number of samples`).
118
+
119
+ | Session | `.set` header declares (`pnts` = `len(times)` = `xmax·srate`) | `.fdt` actually contains | Missing |
120
+ |---|---:|---:|---:|
121
+ | `sub-011/ses-004` | 17,403,870 samples/ch = **9.67 h** | 3,098,150 = **1.72 h** | ~8.0 h |
122
+ | `sub-013/ses-001` | 14,515,050 samples/ch = **8.06 h** | 9,094,592 = **5.05 h** | ~3.0 h |
123
+
124
+ For comparison, every intact session matches exactly (e.g. `sub-001/ses-001`:
125
+ header 14,255,560 = `.fdt` 14,255,560 = 7.92 h). The truncated samples are simply
126
+ absent from the `.fdt` on OpenNeuro — the local files are byte-identical to the
127
+ S3 source, so this is source-level corruption, not a download error, and it
128
+ cannot be repaired. (The intact prefix of each truncated `.fdt` is technically
129
+ recoverable by bypassing MNE, but that is ~1% of the data and is not attempted
130
+ here.) This is the same failure class as EESM23's known-corrupt `sub-006/ses-002`.
131
+ The other 78 sessions (all 20 subjects) load cleanly.
132
+
133
+ ### Out-of-bounds epochs (155 dropped)
134
+
135
+ These are benign, not corruption. A scoring epoch is annotated by an onset time
136
+ plus a 30-second duration, and a sample is only written when the full 30 s
137
+ (15,000 points) lies inside the recording. For the last one or two epochs of some
138
+ nights, `onset + 30 s` runs slightly past the end of the `.fdt` (the recording
139
+ stops before the final annotated epoch fully elapses), so those epochs are
140
+ dropped — about two per night across the 78 intact sessions. This is expected:
141
+ scoring files routinely annotate a little beyond the end of the signal.
142
+
143
+ Because both modalities are sliced from one file on a shared timeline, no sample
144
+ is excluded for lack of a cross-modality partner. No sample is excluded for
145
+ containing NaN/Inf: the files retain 38,155 in-ear and 11,399 scalp samples with
146
+ at least one non-finite value (e.g. a dead channel for a whole night, such as
147
+ `sub-001/ses-004` F3); their indices remain paired even when quality differs
148
+ between modalities.
149
+
150
+ ## HDF5 schema (v0.5)
151
+
152
+ ```text
153
+ /data (N, C, 15000) float32
154
+ /durations (N,) int64
155
+ /nan_fraction (N,) float32
156
+ /channel_nan_fraction (N, C) float32
157
+ /labels (N,) int64
158
+ /sample_id (N,) int64
159
+ /subject (N,) string
160
+ /session (N,) string
161
+ /task (N,) string
162
+ /acquisition (N,) string
163
+ /run (N,) string
164
+ /recording_id (N,) string
165
+ /trial_id (N,) int64
166
+ /event_id (N,) int64
167
+ /split_group_id (N,) int64
168
+ /window_start_sample (N,) int64
169
+ /window_stop_sample (N,) int64
170
+ /ch_names (C,) string
171
+ ```
172
+
173
+ `event_id` and `split_group_id` both identify the source 30-second scoring row; here each sample *is* one epoch, so there is one sample per split group (unlike a 4-second export, where seven windows share a group). For sequence-model sleep staging that needs adjacent-epoch context, group by `subject`+`session` and order by `window_start_sample`.
174
+
175
+ Important attributes include `sfreq`, `class_names`, `unit`, `eegfm_version`, `preprocess_config_json`, `split_group_kind`, and `window_reference`.
176
+
177
+ ## Storage format
178
+
179
+ The signal is stored **uncompressed** as `float32` microvolts at the native
180
+ 500 Hz, with `/data` chunked one sample per chunk — `chunks = (1, C, 15000)`.
181
+ This layout is chosen for map-style DataLoader training: each `__getitem__(i)`
182
+ reads exactly one contiguous chunk (one 30-second epoch with its channels), so
183
+ random access across the whole file costs one chunk read and no wasted I/O. When
184
+ the loader crops a shorter `epoch_sec` window it reads only that slice of the
185
+ chunk.
186
+
187
+ Compression is intentionally **not** applied. EEG windows are high-entropy
188
+ signals that gzip/lzf shrink only ~1.2–1.5×, and decompression would add CPU
189
+ cost on every sample fetched by the DataLoader workers; at this scale (tens of
190
+ GB on local disk) the trade is not worth it. The files are therefore ≈ the raw
191
+ array size (`N × C × 15000 × 4 bytes`).
192
+
193
+ Note on sample rate: this export keeps the native **500 Hz** (unlike
194
+ `EESM23-Processed`, which is 250 Hz). Every model in the benchmark resamples to
195
+ its own expected rate at load time (200 Hz for most; 256 Hz for EEGPT/BENDR), so
196
+ the stored rate does not affect model inputs — 500 Hz is retained purely to
197
+ preserve the recording as acquired. Downsampling to 250 Hz would roughly halve
198
+ the file size with no effect on any model.
eesm19-in-ear-eeg.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5db4e729754258f6586d3b61c417ad05ea85ea9a5a8e0d3e71fc03ff7aee4789
3
+ size 53154113640
eesm19-scalp-eeg.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:131a1ee4a7917bed9e116edfc9616545c5a4cc2e39ffe87ffb19829c8382e77b
3
+ size 35445717544