edfread
Description
reads the file into a timetable with additional options specified by one or more
name-value pair arguments.data
= edfread(filename
,Name,Value
)
[
also returns the annotations present in the data records.data
,annotations
] = edfread(___)
Examples
Read EDF File into Timetable
Read data from the EDF file example.edf
into a timetable. The file contains two signals, ECG
and ECG2
. Each signal contains six data records, and each data record has a duration of 10 seconds.
tt = edfread('example.edf')
tt=6×2 timetable
Record Time ECG ECG2
___________ _______________ _______________
0 sec {1280x1 double} {1280x1 double}
10 sec {1280x1 double} {1280x1 double}
20 sec {1280x1 double} {1280x1 double}
30 sec {1280x1 double} {1280x1 double}
40 sec {1280x1 double} {1280x1 double}
50 sec {1280x1 double} {1280x1 double}
Create an edfinfo
object containing information about example.edf
. Verify that the signals have the expected names. Extract the sample rates of the signals using the DataRecordDuration and NumSamples properties of the object.
info = edfinfo('example.edf');
info.SignalLabels
ans = 2x1 string
"ECG"
"ECG2"
fs = info.NumSamples/seconds(info.DataRecordDuration)
fs = 2×1
128
128
Plot the first record of the first signal. For more information about accessing data in tables, see Access Data in Tables.
recnum = 1; signum = 1; t = (0:info.NumSamples(signum)-1)/fs(signum); y = tt.(signum){recnum}; plot(t,y) legend(strcat("Record ",int2str(recnum), ... ", Signal ",info.SignalLabels(signum))) hold on
Extract and plot the fifth record of the second signal.
recnum = 5; signum = 2; t = (0:info.NumSamples(signum)-1)/fs(signum); y = tt.(signum){recnum}; plot(t,y, ... 'DisplayName',strcat("Record ",int2str(recnum), ... ", Signal ",info.SignalLabels(signum))) hold off xlabel('t (seconds)')
Read Subset of EDF File
Create an edfinfo
object to obtain information about the EDF file example.edf
. Extract the number of records and the names of the variables contained in the file.
info = edfinfo('example.edf');
nrec = info.NumDataRecords
nrec = 6
vars = info.SignalLabels
vars = 2x1 string
"ECG"
"ECG2"
Read the second and fifth records corresponding to the variable ECG2
. Return the signals as timetables with row times corresponding to signal sample times. Express the time information as datetime
arrays.
data = edfread('example.edf', ... 'SelectedDataRecords',[2 5],'SelectedSignals',"ECG2", ... 'DataRecordOutputType','timetable','TimeOutputType','datetime')
data=2×1 timetable
Record Time ECG2
____________________ __________________
10-Oct-2020 12:02:28 {1280x1 timetable}
10-Oct-2020 12:02:58 {1280x1 timetable}
Change the name of the row times to "Date and Time"
and the name of the variable to "Electrocardiogram"
.
data.Properties.DimensionNames = ["Date and Time" "Variables"]; data.Properties.VariableNames = "Electrocardiogram"; data
data=2×1 timetable
Date and Time Electrocardiogram
____________________ __________________
10-Oct-2020 12:02:28 {1280x1 timetable}
10-Oct-2020 12:02:58 {1280x1 timetable}
Input Arguments
filename
— Name of EDF or EDF+ file
character vector | string scalar
Name of EDF or EDF+ file, specified as a character vector or string scalar.
Depending on the location of the file, filename
can take one of
these forms.
Location | Form |
---|---|
Current folder or folder on the MATLAB® path | Specify the name of the file in
Example:
|
File in a folder | If the file is not in the current folder or in a folder on the MATLAB path, then specify the full or relative path name. Example:
Example:
|
Note
edfread
does not support EyeLink® EDF files.
Data Types: char
| string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'SelectedSignals',["Thorax" "Abdomen"],'SelectedDataRecords',[2
7],'TimeOutputType','datetime'
instructs edfread
to
read the second and seventh data records corresponding to the Thorax
and
Abdomen
signals and return the time information as
datetime
arrays.
SelectedSignals
— Names of signals to read
string vector | cell array of character vectors
Names of signals to read, specified as the comma-separated pair consisting of
'SelectedSignals'
and a string vector or a cell array of
character vectors.
'SelectedSignals'
must be a subset of the signal names contained in the file. To get the names of all the signals in the file, create anedfinfo
object and use theSignalLabels
property.If this argument is not specified,
edfread
reads all the signals in the file.
Example: Both ["Thorax 1" "Abdomen 3"]
and {'Thorax 1'
'Abdomen 3'}
specify Thorax 1
and Abdomen
3
as the signals to read from a file.
Data Types: char
| string
SelectedDataRecords
— Indices of records to read
1:height(edfread
(filename
))
(default) | vector of positive integers
edfread
(filename
))Indices of records to read, specified as the comma-separated pair consisting of
'SelectedDataRecords'
and a vector of positive integers. The
integers in the vector must be unique and strictly increasing.
'SelectedDataRecords'
must be a subset of the data records contained in the file. To see how many records are in the file, create anedfinfo
object and use theNumDataRecords
property. Alternatively, read the whole file and use the MATLAB functionheight
.If this argument is not specified,
edfread
reads all the data records in the file.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
DataRecordOutputType
— Data output type
'vector'
(default) | 'timetable'
Data output type, specified as the comma-separated pair consisting of
'DataRecordOutputType'
and either 'vector'
or
'timetable'
.
'vector'
— Return the signals indata
as vectors.'timetable'
— Return the signals indata
as timetables with row times corresponding to signal sample times.
Data Types: char
| string
TimeOutputType
— Time output type
'duration'
(default) | 'datetime'
Output Arguments
data
— Output data
timetable
Output data, returned as a timetable. Each row of data
corresponds to a record, and each variable of data
corresponds to a signal.
If
'DataRecordOutputType'
is specified as'vector'
, the signal segment for each data record is returned as a vector.If
'DataRecordOutputType'
is specified as'timetable'
, the signal segment for each data record is returned as a timetable with row times corresponding to signal sample times.
Each row time of data
contains the start time of the
corresponding data record.
If
'TimeOutputType'
is set to'duration'
, the start time of each record is relative to the start time of the file recording.If
'TimeOutputType'
is set to'datetime'
, the start time of each record is the absolute start time.
annotations
— Record annotations
timetable
Record annotations, returned as a timetable. The timetable contains these variables:
Onset
— Time at which the annotation occurred. The data type ofOnset
depends on the value specified for'TimeOutputType'
.Annotations
— A string that contains the annotation text.Duration
— A duration scalar that indicates the duration of the event described by the annotation. If the file does not specify an annotation duration, this variable is returned asNaN
.
References
[1] Kemp, Bob, Alpo Värri, Agostinho C. Rosa, Kim D. Nielsen, and John Gade. “A Simple Format for Exchange of Digitized Polygraphic Recordings.” Electroencephalography and Clinical Neurophysiology 82, no. 5 (May 1992): 391–93. https://doi.org/10.1016/0013-4694(92)90009-7.
[2] Kemp, Bob, and Jesus Olivan. "European Data Format 'plus' (EDF+), an EDF Alike Standard Format for the Exchange of Physiological Data." Clinical Neurophysiology 114, no. 9 (2003): 1755–1761. https://doi.org/10.1016/S1388-2457(03)00123-8.
Version History
Introduced in R2020b
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)