TEA EEG analysis at the age the EDF header gives, the patient's rows as fallback; tea library 0.2.0
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
Written as the hospital's converter writes them: plain labels, microvolts, one fixed range, digital ±32767.
|
||||
"""
|
||||
import tempfile
|
||||
from datetime import time
|
||||
from datetime import date, time
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
@@ -108,14 +108,17 @@ def signals(*, fs: float, minutes: float, rhythm_hz: float, line_hz: float, bad:
|
||||
|
||||
|
||||
def edf_bytes(*, fs: float = 250.0, minutes: float = 4.0, rhythm_hz: float = 7.0, line_hz: float = 60.0,
|
||||
bad: dict | None = None, seed: int = 0) -> bytes:
|
||||
from edfio import Edf, EdfAnnotation, EdfSignal
|
||||
bad: dict | None = None, seed: int = 0, birthdate: date | None = None,
|
||||
startdate: date | None = None) -> bytes:
|
||||
"""`birthdate` and `startdate` go in the header; left out, it says `X` and the 01.01.85 placeholder."""
|
||||
from edfio import Edf, EdfAnnotation, EdfSignal, Patient, Recording
|
||||
|
||||
data, duration = signals(fs=fs, minutes=minutes, rhythm_hz=rhythm_hz, line_hz=line_hz, bad=bad or {}, seed=seed)
|
||||
labels = SCALP + list(EARS) + list(AUX)
|
||||
annotations = [EdfAnnotation(0.5, None, "Paciente despierto"), EdfAnnotation(duration / 2 + 0.5, None, "Dormido")]
|
||||
edf = Edf([EdfSignal(np.clip(data[ch], -FULL_SCALE, FULL_SCALE), fs, label=ch, physical_dimension="uV",
|
||||
physical_range=(-FULL_SCALE, FULL_SCALE), digital_range=(-32767, 32767)) for ch in labels],
|
||||
patient=Patient(birthdate=birthdate), recording=Recording(startdate=startdate),
|
||||
starttime=time(10, 0, 0), data_record_duration=1.0, annotations=annotations)
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
path = Path(folder) / "study.edf"
|
||||
|
||||
Reference in New Issue
Block a user