m3resp.coerce_interval#

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

Convert one timed interval into an Interval.

Parameters:
  • value (Any) – An Interval, a dictionary or object with start_time and end_time (including eitprocessing’s Interval), or a (start_time, end_time) pair. Times are in seconds.

  • name (str | None) – Interval kind used when the input’s name is missing or empty. Required for a pair. 'breath' selects BreathEvent.

  • modality (str | None) – Device or technique used when the input’s modality is missing or empty. Required for a pair.

  • source (str | None) – Method name used when the input’s source is missing or empty.

Returns:

The existing interval unchanged, or a new interval with the

input’s fields. A converted input named 'breath' or carrying a turning point becomes a BreathEvent; the turning point is read as in coerce_breath_event(). Input identifiers are preserved; a new identifier is generated when omitted.

Return type:

Interval

Raises:
  • ValueError – If a required name, modality or dictionary time is missing, a pair has other than two entries, or the end precedes the start. Also raised when a time or sampling rate cannot be converted to a number, or an input with a turning point has a name other than 'breath'.

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