Skip to content

Mixins

eitprocessing.datahandling.mixins.equality.Equivalence

Mixin class that adds an equality and equivalence check.

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.

eitprocessing.datahandling.mixins.slicing.SelectByIndex

Adds slicing functionality to subclass by implementing __getitem__.

Subclasses must implement a _sliced_copy function that defines what should happen when the object is sliced. This class ensures that when calling a slice between square brackets (as e.g. done for lists) then return the expected sliced object.

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.

eitprocessing.datahandling.mixins.slicing.SelectByTime

Adds methods for slicing by time rather than index.

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,
    start_inclusive: bool = False,
    end_inclusive: bool = False,
    label: str | None = None,
) -> Self

Get a shortened copy of the object, starting from start_time and ending at end_time.

Given a start and end time stamp (i.e. its value, not its index), return a slice of the original object, which must contain a time axis.

PARAMETER DESCRIPTION
start_time

first time point to include. Defaults to first frame of sequence.

TYPE: float | None DEFAULT: None

end_time

last time point. Defaults to last frame of sequence.

TYPE: float | None DEFAULT: None

start_inclusive

True), end_inclusive (default False): these arguments control the behavior if the given time stamp does not match exactly with an existing time stamp of the input. if True: the given time stamp will be inside the sliced object. if False: the given time stamp will be outside the sliced object.

TYPE: default DEFAULT: False

label

Description. Defaults to None, which will create a label based on the original object label and the frames by which it is sliced.

TYPE: str | None DEFAULT: None

RAISES DESCRIPTION
TypeError

if self does not contain a time attribute.

ValueError

if time stamps are not sorted.

RETURNS DESCRIPTION
Self

A shortened copy of the object.

eitprocessing.datahandling.mixins.slicing.TimeIndexer dataclass

TimeIndexer(obj: HasTimeIndexer)

Helper class for 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