Skip to content

Sequence

eitprocessing.datahandling.sequence

Sequence dataclass

Sequence(
    label: str | None = None,
    name: str | None = None,
    description: str = "",
    eit_data: DataCollection[EITData] = (lambda: DataCollection(EITData))(),
    continuous_data: DataCollection[ContinuousData] = (
        lambda: DataCollection(ContinuousData)
    )(),
    sparse_data: DataCollection[SparseData] = (
        lambda: DataCollection(SparseData)
    )(),
    interval_data: DataCollection[IntervalData] = (
        lambda: DataCollection(IntervalData)
    )(),
)

Sequence of timepoints containing respiratory data.

A Sequence object is a representation of data points over time. These data can consist of any combination of EIT frames (EITData), waveform data (ContinuousData) from different sources, or individual events (SparseData) occurring at any given timepoint. A Sequence can consist of an entire measurement, a section of a measurement, a single breath, or even a portion of a breath. A Sequence can consist of multiple sets of each type of data from the same time-points or can be a single measurement from just one source.

A Sequence can be split up into separate sections of a measurement or multiple (similar) Sequence objects can be merged together to form a single Sequence.

PARAMETER DESCRIPTION
label

Computer readable naming of the instance.

TYPE: str | None DEFAULT: None

name

Human readable naming of the instance.

TYPE: str | None DEFAULT: None

description

Human readable extended description of the data.

TYPE: str DEFAULT: ''

eit_data

Collection of one or more sets of EIT data frames.

TYPE: DataCollection[EITData] DEFAULT: (lambda: DataCollection(EITData))()

continuous_data

Collection of one or more sets of continuous data points.

TYPE: DataCollection[ContinuousData] DEFAULT: (lambda: DataCollection(ContinuousData))()

sparse_data

Collection of one or more sets of individual data points.

TYPE: DataCollection[SparseData] DEFAULT: (lambda: DataCollection(SparseData))()

time property

time: ndarray

Time axis from either EITData or ContinuousData.

data property

data: _DataAccess

Shortcut access to data stored in collections inside a sequence.

This allows all data objects stored in a collection inside a sequence to be accessed. Instead of sequence.continuous_data["global_impedance"] you can use sequence.data["global_impedance"]. This works for getting (sequence.data["label"] or sequence.data.get("label")) and adding data (sequence.data["label"] = obj or sequence.data.add(obj)).

Other dict-like behaviour is also supported:

  • label in sequence.data to check whether an object with a label exists;
  • del sequence.data[label] to remove an object from the sequence based on the label;
  • for label in sequence.data to iterate over the labels;
  • sequence.data.items() to retrieve a list of (label, object) pairs, especially useful for iteration;
  • sequence.data.labels() or sequence.data.keys() to get a list of data labels;
  • sequence.data.objects() or sequence.data.values() to get a list of data objects.

This interface only works if the labels are unique among the data collections. An attempt to add a data object with an exiting label will result in a KeyError.

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

concatenate classmethod

concatenate(a: Sequence, b: Sequence, newlabel: str | None = None) -> Sequence

Create a merge of two Sequence objects.

select_by_time

select_by_time(
    start_time: float | None = None,
    end_time: float | None = None,
    start_inclusive: bool = True,
    end_inclusive: bool = False,
    label: str | None = None,
    name: str | None = None,
    description: str = "",
) -> Self

Return a sliced version of the Sequence.

See SelectByTime.select_by_time().

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.