Skip to content

DataCollection

eitprocessing.datahandling.datacollection

DataCollection

DataCollection(data_type: type[V], *args, **kwargs)

A collection of a single type of data with unique labels.

A DataCollection functions largely as a dictionary, but requires a data_type argument, which must be one of the data containers existing in this package. When adding an item to the collection, the type of the value must match the data_type of the collection. Furthermore, the key has to match the attribute 'label' attached to the value.

The convenience method add() adds an item by setting the key to value.label.

PARAMETER DESCRIPTION
data_type

the data container stored in this collection.

TYPE: type[V]

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

add

add(*item: V, overwrite: bool = False) -> None

Add one or multiple item(s) to the collection using the item label as the key.

get_loaded_data

get_loaded_data() -> dict[str, V]

Return all data that was directly loaded from disk.

get_data_derived_from

get_data_derived_from(obj: V) -> dict[str, V]

Return all data that was derived from a specific source.

get_derived_data

get_derived_data() -> dict[str, V]

Return all data that was derived from any source.

concatenate

concatenate(other: Self) -> Self

Concatenate this collection with an equivalent collection.

Each item of self of concatenated with the item of other with the same key.

select_by_time

select_by_time(
    start_time: float | None,
    end_time: float | None,
    start_inclusive: bool = True,
    end_inclusive: bool = False,
) -> DataCollection

Return a DataCollection containing sliced copies of the items.

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.