Functionality

EDF.jl

EDF.jl is a Julia package for working with European Data Format (EDF) files, including reading, writing, and an intermediate representation for direct access to data.

Package API

Representation of Data

EDF files consist of a header record, which contains file-level metadata, and a number of contiguous data records, each containing a chunk of each signal. In Julia, we represent this with an EDF.File type that consists of an EDF.Header object and a vector of EDF.Signals.

EDF.FileType.
EDF.File

Type representing a parsed EDF file. All data defined in the file is accessible from this type by inspecting its fields and the fields of the types of those fields.

Fields

  • header (EDF.Header): File-level metadata extracted from the file header
  • signals (Vector{EDF.Signal}): All signals extracted from the data records
  • annotations (Vector{EDF.RecordAnnotation} or Nothing): A vector of length header.n_records where each element contains annotations for the corresponding data record, if annotations are present in the file
source
EDF.HeaderType.
EDF.Header

Type representing the header record for an EDF file.

Fields

  • version (String): Version of the data format
  • patient (String or EDF.PatientID): Local patient identification
  • recording (String or EDF.RecordingID): Local recording identification
  • start (DateTime): Date and time the recording started
  • n_records (Int): Number of data records
  • duration (Float64): Duration of a data record in seconds
  • n_signals (Int): Number of signals in a data record
  • nb_header (Int): Total number of raw bytes in the header record
source
EDF.SignalType.
EDF.Signal

Type representing a single signal extracted from an EDF file.

Fields

  • label (String): The name of the signal, e.g. F3-M2
  • transducer (String): Transducer type
  • physical_units (String): Units of measure for the signal, e.g. uV
  • physical_min (Float32): The physical minimum value of the signal
  • physical_max (Float32): The physical maximum value of the signal
  • digital_min (Float32): The minimum value of the signal that could occur in a data record
  • digital_max (Float32): The maximum value of the signal that could occur in a data record
  • prefilter (String): Description of any prefiltering done to the signal
  • n_samples (Int16): The number of samples in a data record (NOT overall)
  • samples (Vector{Int16}): The encoded sample values of the signal
Note

Samples are stored in a Signal object in the same encoding as they appear in raw EDF files. See decode for decoding signals to their physical values.

source
EDF.RecordAnnotation

Type containing all annotations applied to a particular data record.

Fields

  • offset (Float64): Offset from the recording start time (specified in the header) at which the current data record starts
  • event (Vector{String} or Nothing): The event that marks the start of the data record, if applicable
  • annotations (Vector{EDF.AnnotationsList}): The time-stamped annotations lists (TALs) in the current data record
  • n_bytes (Int): The number of raw bytes per data record in the "EDF Annotation" signal
source
EDF.AnnotationsList

Type representing a time-stamp annotations list (TAL).

Fields

  • offset (Float64): Offset from the recording start time (specified in the header) at which the event in this TAL starts
  • duration (Float64 or Nothing): Duration of the event, if specified
  • event (Vector{String}): List of events for this TAL
source
EDF.PatientIDType.
EDF.PatientID

Type representing the local patient identification field of an EDF header, assuming the file is EDF+ compliant. EDF.Files which are parsed from files which are not EDF+ compliant do not contain this type; the corresponding field is instead a String.

Fields

  • code (String or Missing): The code by which a patient is referred, if known
  • sex (Char or Missing): Patient sex, 'M', 'F', or missing if unknown
  • birthdate (Date or Missing): Patient date of birth, if known
  • name (String or Missing): Patient name, if known
source
EDF.RecordingIDType.
EDF.RecordingID

Type representing the local recording identification field of an EDF header, assuming the file is EDF+ compliant. EDF.Files which are parsed from files which are not EDF+ compliant do not contain this type; the corresponding field is instead a String.

Fields

  • startdate (Date or Missing): Start date of the recording
  • admincode (String or Missing): Administration code for the recording
  • technician (String or Missing): Identifier for the technician or investigator
  • equipment (String or Missing): Identifier for the equipment used
source

Per the original EDF specification, the signals are assumed to be continuous across data records. However, the EDF+ specification introduced the notion of discontinuous signals, denoted with a value of "EDF+D" in one of the reserved fields. The EDF.Header type notes this in a Bool field called continuous. The signal data is always store contiguously, regardless of whether the data records are declared to be continuous, but, given an EDF.Signal object, users of the package can divide the signal by records if needed using

Iterators.partition(signal.samples, signal.n_samples)

This will construct a lazy iterator over non-overlapping chunks of the signal, iterating which yields a total of header.n_records items.

Reading

EDF.readFunction.
EDF.read(file::AbstractString)

Read the given file and return an EDF.File object containing the parsed data.

source
EDF.decodeFunction.
EDF.decode(signal::Signal)

Decode the sample values in the given signal and return a Vector of the physical values.

source

Writing

EDF.writeFunction.
EDF.write(io::IO, edf::EDF.File)
EDF.write(path::AbstractString, edf::EDF.File)

Write the given EDF.File object to the given stream or file and return the number of bytes written.

source