m3resp.Interval#

class m3resp.Interval(modality, start_time, end_time, *, name, id=<factory>, label=None, start_index=None, end_index=None, sample_frequency=None, signal_name=None, source=None, confidence=None, metadata=<factory>)[source]#

A stretch of time from one modality, with a start and an end.

Use it for an occlusion, a period of noise, an expiratory hold, or an intervention. Times are in seconds on the recording’s time axis or the shared clock after alignment. Zero duration is allowed when only one time point is known, as with EMG breaths detected from their peaks. BreathEvent is an Interval with one more point inside it, the signal’s turning point.

Variables:
  • modality (str) – The device or technique the interval came from, e.g. 'ventilator' or 'emg'.

  • start_time (float) – Start of the interval, in seconds on its time axis.

  • end_time (float) – End of the interval, in seconds on the same time axis.

  • name (str) – What kind of interval this is, e.g. 'occlusion' or 'noise'. Required, and given by keyword.

  • id (str) – Random identifier that stays the same through time shifts and saving. See Event for the full explanation.

  • label (str | None) – Optional name for this particular occurrence of the interval.

  • start_index (int | None) – Position of start_time in the signal this interval was found in. None when the interval wasn’t derived from indexing into a signal.

  • end_index (int | None) – Position of end_time in that signal, or None.

  • sample_frequency (float | None) – Sampling rate of that signal, in Hz. Together with signal_name it says which time axis the *_index fields are relative to, since different signals have different start times, durations, and sampling rates.

  • signal_name (str | None) – Which signal the *_index fields refer to.

  • source (str | None) – Optional name of the method that produced this interval.

  • confidence (float | None) – Optional measure of how sure that method was.

  • metadata (dict[str, Any]) – Optional extra information about the interval.

Parameters:

Everything after end_time is given by keyword, e.g. Interval("ventilator", 10.0, 12.5, name="occlusion").

Raises:

ValueError – If end_time is before start_time.

Parameters:

Attributes

confidence: float | None = None#
property duration: float#

Return the interval duration in seconds.

end_index: int | None = None#
end_time: float#
id: str#
label: str | None = None#
metadata: dict[str, Any]#
modality: str#
name: str#
sample_frequency: float | None = None#
signal_name: str | None = None#
source: str | None = None#
start_index: int | None = None#
start_time: float#