• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

EIT-ALIVE / eitprocessing / 17213080321

25 Aug 2025 03:19PM UTC coverage: 84.761% (+2.0%) from 82.774%
17213080321

push

github

psomhorst
Bump version: 1.7.3 → 1.8.0

745 of 958 branches covered (77.77%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

37 existing lines in 9 files now uncovered.

2737 of 3150 relevant lines covered (86.89%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.0
/eitprocessing/datahandling/loading/__init__.py
1
from functools import reduce
1✔
2
from pathlib import Path
1✔
3

4
from eitprocessing.datahandling.datacollection import DataCollection
1✔
5
from eitprocessing.datahandling.eitdata import EITData, Vendor
1✔
6
from eitprocessing.datahandling.sequence import Sequence
1✔
7

8

9
def load_eit_data(
1✔
10
    path: str | Path | list[str | Path],
11
    vendor: Vendor | str,
12
    label: str | None = None,
13
    name: str | None = None,
14
    description: str = "",
15
    sample_frequency: float | None = None,
16
    first_frame: int = 0,
17
    max_frames: int | None = None,
18
) -> Sequence:
19
    """Load EIT data from path(s).
20

21
    Args:
22
        path: relative or absolute path(s) to data file.
23
        vendor: vendor indicating the device used.
24
            Note: for load functions of specific vendors (e.g. `load_draeger_data`), this argument is defaulted to the
25
            correct vendor.
26
        label: short description of sequence for computer interpretation.
27
            Defaults to "Sequence_<unique_id>".
28
        name: short description of sequence for human interpretation.
29
            Defaults to the same value as label.
30
        description: long description of sequence for human interpretation.
31
        sample_frequency: sample frequency at which the data was recorded.
32
            No default for Draeger. Will be autodetected. Warns if autodetected differs from provided.
33
            Default for Timpel: 50
34
            Default for Sentec: 50.2
35
        first_frame: index of first frame to load.
36
            Defaults to 0.
37
        max_frames: maximum number of frames to load.
38
            The actual number of frames can be lower than this if this
39
            would surpass the final frame.
40

41
    Raises:
42
        NotImplementedError: is raised when there is no loading method for
43
        the given vendor.
44

45
    Returns:
46
        Sequence: a Sequence with the given label, name and description, containing the loaded data.
47

48
    Example:
49
    ```
50
    >>> sequence = load_eit_data(
51
    ...     ["path/to/file1", "path/to/file2"],
52
    ...     vendor="sentec",
53
    ...     label="initial_measurement"
54
    ... )
55
    >>> pixel_impedance = sequence.eit_data["raw"].pixel_impedance
56
    ```
57
    """
58
    from eitprocessing.datahandling.loading import (  # noqa: PLC0415
1✔
59
        draeger,
60
        sentec,
61
        timpel,
62
    )
63

64
    vendor = _ensure_vendor(vendor)
1✔
65
    load_from_single_path = {
1✔
66
        Vendor.DRAEGER: draeger.load_from_single_path,
67
        Vendor.TIMPEL: timpel.load_from_single_path,
68
        Vendor.SENTEC: sentec.load_from_single_path,
69
    }[vendor]
70

71
    first_frame = _check_first_frame(first_frame)
1✔
72

73
    paths = EITData.ensure_path_list(path)
1✔
74

75
    eit_datasets: list[DataCollection] = []
1✔
76
    continuous_datasets: list[DataCollection] = []
1✔
77
    sparse_datasets: list[DataCollection] = []
1✔
78
    interval_datasets: list[DataCollection] = []
1✔
79

80
    for single_path in paths:
1✔
81
        single_path.resolve(strict=True)  # raise error if any file does not exist
1✔
82

83
    for single_path in paths:
1✔
84
        loaded_data = load_from_single_path(
1✔
85
            path=single_path,
86
            sample_frequency=sample_frequency,
87
            first_frame=first_frame,
88
            max_frames=max_frames,
89
        )
90

91
        eit_datasets.append(loaded_data["eitdata_collection"])
1✔
92
        continuous_datasets.append(loaded_data["continuousdata_collection"])
1✔
93
        sparse_datasets.append(loaded_data["sparsedata_collection"])
1✔
94
        interval_datasets.append(loaded_data["intervaldata_collection"])
1✔
95

96
    return Sequence(
1✔
97
        label=label,
98
        name=name,
99
        description=description,
100
        eit_data=reduce(DataCollection.concatenate, eit_datasets),
101
        continuous_data=reduce(DataCollection.concatenate, continuous_datasets),
102
        sparse_data=reduce(DataCollection.concatenate, sparse_datasets),
103
        interval_data=reduce(DataCollection.concatenate, interval_datasets),
104
    )
105

106

107
def _check_first_frame(first_frame: int | None) -> int:
1✔
108
    if first_frame is None:
1✔
109
        first_frame = 0
1✔
110
    if int(first_frame) != first_frame:
1✔
111
        msg = f"`first_frame` must be an int, but was given as {first_frame} (type: {type(first_frame)})"
1✔
112
        raise TypeError(msg)
1✔
113
    if first_frame < 0:
1✔
114
        msg = f"`first_frame` can not be negative, but was given as {first_frame}"
1✔
115
        raise ValueError(msg)
1✔
116
    return int(first_frame)
1✔
117

118

119
def _ensure_vendor(vendor: Vendor | str) -> Vendor:
1✔
120
    """Check whether loading method for vendor exists, and ensure it's a Vendor object."""
121
    try:
1✔
122
        return Vendor(vendor)
1✔
UNCOV
123
    except ValueError as e:
×
UNCOV
124
        msg = f"No loading method for {vendor} exists."
×
UNCOV
125
        raise NotImplementedError(msg) from e
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc