read_EDF¶
- read_EDF(edf_fname, varargin)¶
READ_EDF Load EDF or EDF+ file with full metadata, annotations, and MEX acceleration
READ_EDF reads European Data Format (EDF/EDF+) files using a compiled MEX reader when available, and a pure MATLAB fallback otherwise. The function provides full access to header metadata, per-signal_cellnal scaling (digital-to- physical conversion), and EDF+ annotations.
- Usage:
[header, signal_header, signal_cell, annotations] = read_EDF(filename, ‘Channels’, {‘EEG Fpz-Cz’})
- Inputs:
edf_fname : string - EDF or EDF+ file path ‘Channels’ : cell array - subset of channels to read (default: all)
Use ‘ChA-ChB’ to load ChA minus ChB as a rereferenced channel.
‘Epochs’ : 1x2 vector [start_epoch end_epoch] (0-indexed, default: all) ‘Verbose’ : logical - print progress and status info (default: false) ‘RepairHeader’ : logical - correct invalid record counts and save with _fixed suffix (default: false) ‘forceMATLAB’ : logical - disable MEX usage (default: false) ‘debug’ : logical - debug mode for MEX (default: false) ‘deidentify’ : logical - overwrite PHI fields and save with _deidentified suffix (default: false)
- Outputs:
header : structure containing EDF file-level metadata signal_header : structure array of per-signal_cellnal headers signal_cell : cell array containing each signal_cellnal vector (in physical units) annotations : structure array of EDF+ annotations with onset and text
Example
[header, signal_header, signal_cell, annotations] = read_EDF(‘sleep.edf’, ‘Channels’, {‘EEG C3-A2’});
Followed by per-signal_cellnal headers (16 fields × N signal_cellnals)
Digital samples stored as int16 are scaled to physical units:
phys_val = phys_min + (dig_val - dig_min) * (phys_max - phys_min) / (dig_max - dig_min)
EDF+ annotation channels (labelled ‘EDF Annotations’) contain onset times and event texts in TAL (Time-Annotation List) format.