EDF Reader

class gpype.backend.sources.edf_reader.EDFReader[source]

Bases: RecordingReader

Replays an EDF+ (.edf) recording as if it were a live source.

Reads back what EDFWriter writes: channel roles from the per-signal transducer field, each channel’s unit from its physical dimension (None where that field is empty, e.g. a trigger), the device serial from the equipment field, the entitlement mark from the recording-additional field, and the true sample count – not recoverable from the EDF header itself – from a gpype:samples EDF+ annotation. A file without that annotation (a foreign EDF, or one from an earlier draft) is still read, in full, with a logged warning that its tail may carry up to one data record of undetectable padding.

Every other EDF+ annotation is a marker: its onset and duration, in seconds, are moved onto the file’s sample grid, and it names no channel.

__init__(file_name, sampling_rate=None, frame_size=1, speed=1.0, loop=False, mode='realtime', edge_id=None, **kwargs)[source]

Initialize the reader core.

Parameters:
  • file_name (str) – Path to the .edf recording.

  • sampling_rate (Optional[float]) – The recording’s rate, if the file cannot say. EDF always can, so one given must agree with it.

  • frame_size (int) – Samples emitted per cycle. In batch mode the frame is the whole recording.

  • speed (float) – Replay speed relative to real time.

  • loop (bool) – Start again at the end of the file.

  • mode (str) – realtime or batch.

  • edge_id (Optional[str]) – Which edge runs this node, matched against the edge process’s –edge-id. None, the default, is every edge; ignored when the pipeline is not distributed.

  • **kwargs – Additional arguments for the parent reader.

Raises:
  • ImportError – If pyedflib is not installed.

  • ValueError – If signals disagree on their sample frequency, or a sampling_rate, channel_count or batch frame_size given by hand disagrees with the file.

setup(data, port_context_in)[source]

Describe the replayed channels, and warn about undetectable padding when this file carries no gpype:samples annotation.

Parameters:
Return type:

dict[str, dict]

Returns:

Output port contexts.