m3resp.coerce_event#

m3resp.coerce_event(value, *, name=None, modality=None, label=None)[source]#

Convert one timestamped event into an Event.

Parameters:
  • value (Any) – An Event, a dictionary with time, an object with a time attribute, or a (name, modality, time) sequence with an optional fourth entry, sample_index. Time is in seconds.

  • name (str | None) – Event name used when a dictionary or object omits it. For a sequence, this overrides its name.

  • modality (str | None) – Device or technique used when a dictionary or object omits it. For a sequence, this overrides its modality.

  • label (str | None) – Note used when a dictionary or object omits its label, or assigned to an event created from a sequence.

Returns:

The existing Event unchanged, or a new event with the

supplied fields. An input identifier is preserved; otherwise a new identifier is generated.

Return type:

Event

Raises:
  • KeyError – If a dictionary omits time.

  • ValueError – If the name or modality is missing, the sequence has other than three or four entries, or a time or sampling rate cannot be converted to a number.

  • TypeError – If the input has an unsupported form or a time or sampling rate has an unsupported type.