EDF.jl
EDF.jl is a Julia package for working with European Data Format (EDF) and BioSemi Data Format (BDF) files, including reading, writing, and an intermediate representation for direct access to data.
Package API
Representation of Data
EDF.File
— TypeEDF.File{T,I<:IO}
Type representing an EDF file with samples encoded as values of type T
, which is Int16
for EDF files and Int24
(internally defined) for BDF files.
Fields
io::I
header::FileHeader
signals::Vector{Union{Signal{T},AnnotationsSignal}}
EDF.FileHeader
— TypeEDF.FileHeader
Type representing the parsed header record of an EDF.File
(excluding signal headers).
Fields
version::String
: data format versionpatient::Union{String,PatientID}
: local patient identificationrecording::Union{String,RecordingID}
: local recording identificationstart::DateTime
: start date/time of the recordingis_contiguous::Bool
: iftrue
, data records are contiguous; istrue
for non-EDF+-compliant filesrecord_count::Int
: number of data records in the recordingseconds_per_record::Float64
: duration of a data record in seconds
EDF.SignalHeader
— TypeEDF.SignalHeader
Type representing the header for a single EDF signal.
Fields
label::String
: the signal's type/sensor label, see https://www.edfplus.info/specs/edftexts.html#labeltransducer_type::String
: non-standardized transducer type informationphysical_dimension::String
: see https://www.edfplus.info/specs/edftexts.html#physidimphysical_minimum::Float32
: physical minimum value of the signalphysical_maximum::Float32
: physical maximum value of the signaldigital_minimum::Float32
: minimum value of the signal that could occur in a data recorddigital_maximum::Float32
: maximum value of the signal that could occur in a data recordprefilter::String
: non-standardized prefiltering informationsamples_per_record::Int16
: number of samples in a data record (NOT overall)
EDF.Signal
— TypeEDF.Signal{T}
Type representing a single EDF signal with sample type T
.
Fields
header::SignalHeader
samples::Vector{T}
EDF.AnnotationsSignal
— TypeEDF.AnnotationsSignal
Type representing a single EDF Annotations signal.
Fields
samples_per_record::Int16
records::Vector{Vector{TimestampedAnnotationList}}
EDF.TimestampedAnnotationList
— TypeEDF.TimestampedAnnotationList
A type representing a time-stamped annotations list (TAL).
Note that this type's constructor may attempt to round given onset_in_seconds
and duration_in_seconds
arguments to their nearest representable values in accordance with the EDF+ specification, which a) represents these values as ASCII, b) constrains these values to an 8 character limit, and c) does not allow the use of scientific notation for these fields.
See EDF+ specification for details.
Fields
onset_in_seconds::Float64
: onset w.r.t. recording start time (may be negative)duration_in_seconds::Union{Float64,Nothing}
: duration of this TALannotations::Vector{String}
: the annotations associated with this TAL
EDF.PatientID
— TypeEDF.PatientID
A type representing the local patient identification field of an EDF+ header.
See EDF+ specification for details.
Fields
code::Union{String,Missing}
sex::Union{Char,Missing}
('M'
,'F'
, ormissing
)birthdate::Union{Date,Missing}
name::Union{String,Missing}
EDF.RecordingID
— TypeEDF.RecordingID
A type representing the local recording identification field of an EDF+ header.
See EDF+ specification for details.
Fields
startdate::Union{Date,Missing}
admincode::Union{String,Missing}
technician::Union{String,Missing}
equipment::Union{String,Missing}
EDF.sample_type
— FunctionEDF.sample_type(file::EDF.File{T})
Return the encoded type T
of the samples stored in file
.
EDF.is_bdf
— FunctionEDF.is_bdf(file)
Return true
if file
is a BDF (BioSemi Data Format) file, otherwise false
.
The EDF+ specification introduced the notion of discontiguous signals, denoted with a value of "EDF+D" in one of the reserved fields; the EDF.FileHeader
type notes this in a Bool
field called is_contiguous
. EDF.jl always stores signal data contiguously, regardless of whether the data records are declared to be contiguous, but, given an EDF.Signal
, users of the package can construct a lazy iterator over non-overlapping chunks of a signal::EDF.Signal
via:
Iterators.partition(signal.samples, signal.header.samples_per_record)
Reading
EDF.read
— FunctionEDF.read(path)
Return open(EDF.read, path)
.
EDF.read!
— FunctionEDF.read!(file::File)
Read all EDF sample and annotation data from file.io
into file.signals
and file.annotations
, returning file
. If eof(file.io)
, return file
unmodified.
EDF.decode
— FunctionEDF.decode(signal::Signal)
Return signal.samples
decoded into the physical units specified by signal.header
.
Writing
EDF.write
— FunctionEDF.write(io::IO, file::EDF.File)
EDF.write(path::AbstractString, file::EDF.File)
Write file
to the given output, returning the number of bytes written.