Skip to content

IntervalData

eitprocessing.datahandling.intervaldata

Interval

A tuple containing the start time and end time of an interval.

IntervalData dataclass

IntervalData(
    label: str,
    name: str,
    unit: str | None,
    category: str,
    intervals: list[Interval | tuple[float, float]],
    values: list[Any] | None = None,
    parameters: dict[str, Any] = dict(),
    derived_from: list[Any] = list(),
    description: str = "",
    default_partial_inclusion: bool = False,
)

Container for interval data existing over a period of time.

Interval data is data that consists for a given time interval. Examples are a ventilator setting (e.g. end-expiratory pressure), the position of a patient, a maneuver (end-expiratory hold) being performed, detected periods in the data, etc.

Interval data consists of a number of intervals that may or may not have values associated with them.

Examples of IntervalData with associated values are certain ventilator settings (e.g. end-expiratory pressure) and the position of a patient. Examples of IntervalData without associated values are indicators of maneouvres (e.g. a breath hold) or detected occurences (e.g. a breath).

Interval data can be selected by time through the select_by_time(start_time, end_time) method. Alternatively, t[start_time:end_time] can be used.

PARAMETER DESCRIPTION
label

Computer readable label identifying this dataset.

TYPE: str

name

Human readable name for the data.

TYPE: str

unit

The unit of the data, if applicable.

TYPE: str | None

category

Category the data falls into, e.g. 'breath'.

TYPE: str

intervals

A list of intervals (tuples containing a start time and end time).

TYPE: list[Interval | tuple[float, float]]

values

An optional list of values associated with each interval.

TYPE: list[Any] | None DEFAULT: None

parameters

Parameters used to derive the data.

TYPE: dict[str, Any] DEFAULT: dict()

derived_from

Traceback of intermediates from which the current data was derived.

TYPE: list[Any] DEFAULT: list()

description

Extended human readible description of the data.

TYPE: str DEFAULT: ''

default_partial_inclusion

Whether to include a trimmed version of an interval when selecting data

TYPE: bool DEFAULT: False

has_values property

has_values: bool

True if the IntervalData has values, False otherwise.

t property

Slicing an object using the time axis instead of indices.

Example:

>>> sequence = load_eit_data(<path>, ...)
>>> time_slice1 = sequence.t[tp_start:tp_end]
>>> time_slice2 = sequence.select_by_time(tp_start, tp_end)
>>> time_slice1 == time_slice2
True

select_by_time

select_by_time(
    start_time: float | None = None,
    end_time: float | None = None,
    partial_inclusion: bool | None = None,
    newlabel: str | None = None,
) -> Self

Create a new copy of the object, selecting data between start_time and end_time.

This function returns a shortened copy of the object, containing data from the specified start_time to end_time.

If partial_inclusion is set to True, any intervals that overlap with the start_time or end_time are included in the selection, and their times are adjusted to fit within the specified range. If partial_inclusion is False, intervals that overlap the start or end times are excluded from the selection.

For example: - Set partial_inclusion to True for cases like "set_driving_pressure" where you want to include settings that were active before the start_time. - Set partial_inclusion to False for cases like "detected_breaths" where you want to exclude partial data that doesn't fully fit within the time range.

Note that the end_time is always included in the selection if it is present in the original object.

PARAMETER DESCRIPTION
start_time

The earliest time point to include in the copy.

TYPE: float | None DEFAULT: None

end_time

The latest time point to include in the copy.

TYPE: float | None DEFAULT: None

partial_inclusion

Whether to include intervals that overlap with the start_time or end_time.

TYPE: bool | None DEFAULT: None

newlabel

A new label for the copied object.

TYPE: str | None DEFAULT: None

select_by_index

select_by_index(
    start: int | None = None,
    end: int | None = None,
    newlabel: str | None = None,
) -> Self

De facto implementation of the __getitem__ function.

This function can also be called directly to add a label to the sliced object. Otherwise a default label describing the slice and original object is attached.

isequivalent

isequivalent(other: Self, raise_: bool = False) -> bool

Test whether the data structure between two objects are equivalent.

Equivalence, in this case means that objects are compatible e.g. to be merged. Data content can vary, but e.g. the category of data (e.g. airway pressure, flow, tidal volume) and unit, etc., must match.

PARAMETER DESCRIPTION
other

object that will be compared to self.

TYPE: Self

raise_

sets this method's behavior in case of non-equivalence. If True, an EquivalenceError is raised, otherwise False is returned.

TYPE: bool DEFAULT: False

RAISES DESCRIPTION
EquivalenceError

if raise_ == True and the objects are not

RETURNS DESCRIPTION
bool

bool describing result of equivalence comparison.

deepcopy

deepcopy() -> Self

Return a deep copy of the object.