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 |
required |
label
|
str | None
|
Name of the recording; |
None
|
phase
|
str | None
|
Name of the phase, e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, DataFrame]
|
|
dict[str, DataFrame]
|
|
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 |
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 |
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 |
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. |