| readEDF | R Documentation |
Read data from a European Data Format (EDF, EDF+, BDF, BDF+) file.
readEDF(
file,
records = "all",
signals = "all",
multifreq = c("group", "separate", "downsample", "upsample"),
physical = TRUE
)
file |
Character string. The name of the file which the data are to be read from. |
records |
Numeric or |
signals |
Numeric, character string, or |
multifreq |
Character string. Specifies what to do when signals with different sampling frequencies are present in the file. Options are:
Up- and downsampling are performed by the |
physical |
Logical. If true, convert the digital data values to physical values. |
The function readEDF reads files containing electrophysiological data stored in the European Data Format (EDF) or its variants.
EDF was published in 1992 and stores multichannel data, allowing different sample rates for each signal. Internally it includes a header and one or more data records. The header contains some general information (patient identification, start time...) and technical specs of each signal (calibration, sampling rate, filtering, ...), coded as ASCII characters. The data records contain samples as little-endian 16-bit integers.
EDF+ was published in 2003 and is largely compatible to EDF, but EDF+ files also allow coding discontinuous recordings as well as annotations, stimuli and events in UTF-8 format.
Biosemi developed an EEG acquisition system with 24-bit A/D converters, which could not be stored in the 16-bit EDF format. They introduced a 24-bit variant of EDF called BDF (Biosemi Data Format), and a BDF+ variant is sometimes also found.
The function readEDF can read all of these variants and produce different output that can be used for further processing
by function in the eegr package.
list (head, ctd, ..., anno). The function returns a list containing three possible elements: the
file header, the data, and annotations, if present. The header is always returned; the other two elements depend on the
input arguments.
A list named 'header' consisting of the following elements:
id0First identification byte. For BDF: -1 (0xFF), for EDF: ASCII "0" (0x30, old) or " " (0x32, new)
id1 Identification string, "" for EDF, "BIOSEMI" for BDF (7 bytes ASCII)
lsiLocal subject identification (80 bytes ASCII)
lriLocal recording identification (80 bytes ASCII)
dateStarting date of recording (8 bytes ASCII - "dd.mm.yy")
timeStarting time of recording (8 bytes ASCII - "hh.mm.ss")
nbytesNumber of bytes in header record (converted from 8 bytes ASCII to numeric)
versionReserved. Used for version of format. Empty for EDF, "EDF+C" for EDF continuous data, "EDF+D" for EDF discontinuous data, "BIOSEMI" or "24BIT" for BDF (44 bytes ASCII)
nrecNumber of data records (converted from 8 bytes ASCII to numeric), -1 if unknown
durationDuration of one data record in seconds (converted from 8 bytes ASCII to numeric)
nsNumber of signals in each data record (converted from 4 bytes ASCII to numeric)
labelSignal labels, e.g. "Fpz", "Fz" (ns * 16 bytes ASCII)
transducerTransducer type, e.g. "AgAgCl electrode" (ns * 80 bytes ASCII)
dimensionPhysical dimension of signal, e.g., "uV", "Ohm" (ns * 8 bytes ASCII)
physminPhysical minimum in units of dimension (ns * 8 bytes ASCII converted to numeric)
physmaxPhysical maximum in units of dimension (ns * 8 bytes ASCII converted to numeric)
digiminDigital minimum ((ns * 8 bytes ASCII converted to numeric)
digimaxDigital maximum (ns * 8 bytes ASCII converted to numeric)
gainGain factor used for mapping digital to physical values (ns * numeric)
offsetOffset value used for mapping digital to physical values (ns * numeric)
prefiltPrefiltering, e.g., "TC:3s;LP:70Hz" (ns * 80 bytes ASCII)
nsampNumber of samples in one data record (ns * 8 bytes ASCII converted to numeric)
resvdReserved (ns * 32 bytes ASCII)
One or more Continuous Time Domain (ctd) objects. If the input file contains signals
which all have the same sampling frequency, or if either the "upsample" or "downsample" options were
specified in the multifreq parameter, then there is a single ctd object, and it is named 'ctd'.
In case of multiple sampling frequencies, then if the multifreq = "group", as many ctd objects are
returned as there are sampling frequencies, and they are named ctdF, where F equals the sampling frequency
of the data in that object. For instance, for a data file with sampling frequencies of 256 and 1024 Hz, two ctd
objects will be returned, named ctd256 and ctd1024.
In case multifreq = "separate" is specified, there will be as many ctd objects as there are signals,
and they will be named 'ctd1...ctdN', where N equals the number of signals in the file.
A (list of) data frame(s) named 'anno' containing the annotations parsed from
the EDF+/BDF+ annotation channels, or from the Biosemi 'status' channel. Each annotation consists of the following fields:
samplesample number of annotation
timecorresponding time, relative to beginning of file
valuevalue of annotation, as per EDF+ specification, see https://www.edfplus.info/specs/edfplus.html. For Biosemi this ia a 16 bit number, as only bits 0-15 of 24 are used as triggers, see http://biosemi.com/faq/trigger_signals.htm
. For EDF+ and BDF+ files, the Time-stamped Annotation Lists (TALs) will also be returned. In this case, sample numbers and times are relative to the beginning of the file, irrespective of the records read.
Geert van Boxtel, G.J.M.vanBoxtel@gmail.com
Kemp B., Värri, A., Rosa, A.C., Nielsen, K.D. and Gade, J. (1992). A simple format for exchange of digitized polygraphic recordings. Electroencephalogr Clin Neurophysiol, 82(5), 391-393.
Kemp, B. and Olivan, J. (2003). European data format ’plus’ (EDF+), an EDF alike standard format for the exchange of physiological data. Clin Neurophysiol, 114(9), 1755-1761.
European Data Format. https://www.edfplus.info/
Which file format does Biosemi use? https://www.biosemi.com/faq/file_format.htm
## Not run:
edf <- readEDF('test.edf', signals = 1:10, records = "all")
summary(edf$ctd)
header <- readEDF(file.bdf, records = NA)
header
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.