m3resp.coerce_breath_event#

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

Convert one detected breath into a BreathEvent.

The turning point is read from extremum_time and extremum_index, then from the older peak_time and peak_index, then from eitprocessing’s middle_time. The first pair with a value is used, and both time and index come from that pair. Reading peak_time or peak_index gives a UserWarning naming the current fields.

Parameters:
  • value (Any) – A BreathEvent, a dictionary or object with start_time and end_time, or a (start_time, end_time) sequence with an optional third entry, extremum_time. All times are in seconds.

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

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

Returns:

The existing breath unchanged, or a new breath with the

input’s timing, sample indices, label, identifier and metadata. A new identifier is generated when the input omits one.

Return type:

BreathEvent

Raises:
  • ValueError – If the input has a name other than 'breath', omits a required modality or dictionary time, has other than two or three sequence entries, or ends before it starts. Also raised when 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.