pyhealth.tasks.temple_university_EEG_tasks#
The temple_university_EEG_tasks module contains the tasks for the Temple University EEG Corpus.
The tasks are: - EEGEventsTUEV: EEG event classification task for the TUEV dataset. - EEGAbnormalTUAB: Binary classification task for the TUAB dataset (abnormal vs normal).
Tasks Parameters: - resample_rate: int, default=200 # Resample rate - bandpass_filter: tuple, default=(0.1, 75.0) # Bandpass filter - notch_filter: float, default=50.0 # Notch filter
- class pyhealth.tasks.temple_university_EEG_tasks.EEGEventsTUEV(resample_rate=200, bandpass_filter=(0.1, 75.0), notch_filter=50.0, normalization=None, compute_stft=True)[source]#
Bases:
BaseTaskMulti-class classification task for EEG event detection on TUEV.
- For each EDF recording, this task:
reads the EDF
applies bandpass (0.1-75 Hz), notch (50 Hz), resamples to 256 Hz
loads the paired .rec file (same path, .edf -> .rec)
constructs 5-second event-centered windows (16 bipolar channels)
returns one sample per event
- Each returned sample contains:
“signal”: np.ndarray, shape (16, 256*5)
“offending_channel”: int
“label”: int
Examples
>>> from pyhealth.datasets import TUEVDataset >>> from pyhealth.tasks import EEGEventsTUEV >>> dataset = TUEVDataset( ... root="/srv/local/data/TUH/tuh_eeg_events/v2.0.0/edf/", ... ) >>> sample_dataset = dataset.set_task(EEGEventsTUEV()) >>> sample = sample_dataset[0] >>> print(sample['label'])
For a complete example, see examples/conformal_eeg/tuev_eeg_quickstart.ipynb.
- static BuildEvents(signals, times, EventData, resample_rate=200)[source]#
- Return type:
Tuple[ndarray,ndarray,ndarray]
- static readEDF(fileName, resample_rate=200, bandpass_filter=(0.1, 75.0), notch_filter=50.0)[source]#
- Return type:
Tuple[ndarray,ndarray,ndarray,BaseRaw]
- pre_filter(df)#
- Return type:
LazyFrame
- class pyhealth.tasks.temple_university_EEG_tasks.EEGAbnormalTUAB(resample_rate=200, bandpass_filter=(0.1, 75.0), notch_filter=50.0, normalization=None, compute_stft=True)[source]#
Bases:
BaseTaskBinary classification task for abnormal EEG detection on TUAB.
- For each EDF recording, this task:
reads the EDF
Applies bandpass (0.1-75 Hz), notch (50 Hz) and resamples to 200 Hz
Constructs 16 bipolar channels from the TCP montage of non-overlapping 10 second windows # following BIOT
assigns a binary label (1 = abnormal, 0 = normal) derived from the metadata
labelattribute
- Each returned sample contains:
“signal”: np.ndarray, shape (16, 2000)
“label”: int (0 = normal, 1 = abnormal)
Examples
>>> from pyhealth.datasets import TUABDataset >>> from pyhealth.tasks import EEGAbnormalTUAB >>> dataset = TUABDataset( ... root="/srv/local/data/TUH/tuh_eeg_abnormal/v3.0.0/edf/", ... ) >>> sample_dataset = dataset.set_task(EEGAbnormalTUAB()) >>> sample = sample_dataset[0] >>> print(sample['signal'].shape) # (16, 2000) >>> print(sample['label']) # 0 or 1
- pre_filter(df)#
- Return type:
LazyFrame