pyhealth.tasks.temple_university_EEG_tasks#
- pyhealth.tasks.temple_university_EEG_tasks.EEG_isAbnormal_fn(record)[source]#
Processes a single patient for the abnormal EEG detection task on TUAB.
Abnormal EEG detection aims at determining whether a EEG is abnormal.
- Parameters:
record –
a singleton list of one subject from the TUABDataset. The (single) record is a dictionary with the following keys:
load_from_path, patient_id, visit_id, signal_file, label_file, save_to_path
- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id, record_id,
and epoch_path (the path to the saved epoch {“signal”: signal, “label”: label} as key.
- Return type:
samples
Note that we define the task as a binary classification task.
Examples
>>> from pyhealth.datasets import TUABDataset >>> isabnormal = TUABDataset( ... root="/srv/local/data/TUH/tuh_eeg_abnormal/v3.0.0/edf/", download=True, ... ) >>> from pyhealth.tasks import EEG_isabnormal_fn >>> EEG_abnormal_ds = isabnormal.set_task(EEG_isAbnormal_fn) >>> EEG_abnormal_ds.samples[0] { 'patient_id': 'aaaaamye', 'visit_id': 's001', 'record_id': '1', 'epoch_path': '/home/zhenlin4/.cache/pyhealth/datasets/832afe6e6e8a5c9ea5505b47e7af8125/10-1/1/0.pkl', 'label': 1 }
- pyhealth.tasks.temple_university_EEG_tasks.EEG_events_fn(record)[source]#
Processes a single patient for the EEG events task on TUEV.
This task aims at annotating of EEG segments as one of six classes: (1) spike and sharp wave (SPSW), (2) generalized periodic epileptiform discharges (GPED), (3) periodic lateralized epileptiform discharges (PLED), (4) eye movement (EYEM), (5) artifact (ARTF) and (6) background (BCKG).
- Parameters:
record –
a singleton list of one subject from the TUEVDataset. The (single) record is a dictionary with the following keys:
load_from_path, patient_id, visit_id, signal_file, label_file, save_to_path
- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id, record_id, label, offending_channel,
and epoch_path (the path to the saved epoch {“signal”: signal, “label”: label} as key.
- Return type:
samples
Note that we define the task as a multiclass classification task.
Examples
>>> from pyhealth.datasets import TUEVDataset >>> EEGevents = TUEVDataset( ... root="/srv/local/data/TUH/tuh_eeg_events/v2.0.0/edf/", download=True, ... ) >>> from pyhealth.tasks import EEG_events_fn >>> EEG_events_ds = EEGevents.set_task(EEG_events_fn) >>> EEG_events_ds.samples[0] { 'patient_id': '0_00002265', 'visit_id': '00000001', 'record_id': 0, 'epoch_path': '/Users/liyanjing/.cache/pyhealth/datasets/d8f3cb92cc444d481444d3414fb5240c/0_00002265_00000001_0.pkl', 'label': 6, 'offending_channel': array([4.]) }