Skip to content

Export (layer 4)

tables

The results as tables (layer 4): one analysis, a whole study, CSV files.

One analysis is the output of layer 3 for one phase of a recording (TidalFeatures or PeepTrialFeatures). Its tables start every row with the keys patient_id, label (the recording, e.g. a time point) and phase (the part analysed):

  • recordings: one row per analysis: file, breaths, results of a PEEP trial;
  • breaths: one row per breath of the phase;
  • steps: one row per PEEP step (PEEP trials only);
  • settings: the parameters, the context and the version of fastEIT used;
  • log: the messages of every layer.

The objects of layers 2-3 store each value once; here they are joined, so that a breath or a step is one row with everything (times, quality, pressures, volumes, indices). Regional values are columns named {index}__{region}, for the halves of the lung (ventral, dorsal, right, left; the layers and the quadrants stay in the objects), with two underscores because both names can contain one: in R tidyr::pivot_longer(contains("__"), names_to = c("index", "region"), names_sep = "__") gives back one row per region.

recording_tables

recording_tables(features: TidalFeatures | PeepTrialFeatures, label: str | None = None, phase: str | None = None) -> dict[str, pd.DataFrame]

Tables of one analysis (one phase of a recording).

Parameters:

Name Type Description Default
features TidalFeatures | PeepTrialFeatures

Output of tidal_features() or peep_trial_features().

required
label str | None

Name of the recording; RecordingContext.label if None.

None
phase str | None

Name of the phase, e.g. "baseline"; if None, the protocol ("tidal" or "peep_trial"). Needed when a recording has two phases of the same protocol.

None

Returns:

Type Description
dict[str, DataFrame]

recordings, breaths, steps (PEEP trials only), settings and

dict[str, DataFrame]

log; every row starts with patient_id, label, phase.

combine_tables

combine_tables(analyses: Sequence[dict[str, DataFrame]]) -> dict[str, pd.DataFrame]

The tables of several analyses (a study) as one set of tables.

A table missing in an analysis (steps of a tidal recording) is skipped; columns missing in an analysis (e.g. the results of a PEEP trial in a tidal row) are empty.

Parameters:

Name Type Description Default
analyses Sequence[dict[str, DataFrame]]

Outputs of recording_tables().

required

Returns:

Type Description
dict[str, DataFrame]

The same tables, with the rows of every analysis.

Raises:

Type Description
ValueError

if there is no analysis, or two have the same patient_id, label and phase.

write_csv

write_csv(tables: dict[str, DataFrame], folder: str | Path) -> dict[str, Path]

Write one CSV file per table, e.g. folder/breaths.csv.

UTF-8, comma separated, decimal point, empty cell for a missing value, booleans as 1 / 0: readable by R, SPSS, Excel and Python. Files with the same name are replaced.

Parameters:

Name Type Description Default
tables dict[str, DataFrame]

Output of recording_tables() or combine_tables().

required
folder str | Path

Folder of the files, created if missing.

required

Returns:

Type Description
dict[str, Path]

The path of each file, by table name.