Configuration¶
config ¶
Configuration dataclasses for the fasteit pipeline.
Single source of truth for tuneable parameters. Parsers and algorithms read values from here - change once, propagates everywhere.
Structure
PreprocessingConfig - layer 2: cardiac filter, breaths, lung mask, regions, pressures and tidal volume of each breath SegmentationConfig - layer 2b: PEEP steps of a PEEP trial and the breaths analysed AnalysisConfig - layer 3: clinical indices (recruitment-to-inflation ratio) Config - top-level container for pipeline sections
Rates and frequencies are given per minute here, as read on a monitor; the preprocessing functions work in Hz and the pipeline converts.
Usage
from fasteit.config import Config
cfg = Config()
PreprocessingConfig
dataclass
¶
PreprocessingConfig(heart_rate_bpm: float | None = None, moving_average_seconds: float = 0.1, breath_short_seconds: float = 0.5, breath_long_seconds: float = 20.0, ti_ratio_low: float = 0.2, ti_ratio_high: float = 0.6, local_window_breaths: int = 21, amplitude_ratio_low: float = 0.5, amplitude_ratio_high: float = 2.0, duration_ratio_high: float = 2.0, lung_mask_threshold_fraction: float = 0.15, exclusion_margin_seconds: float = 0.5)
Parameters of the preprocessing layer (layer 2).
Frozen: a recording keeps the exact parameters it was made with. To change one,
make a new config, e.g. dataclasses.replace(config, heart_rate_bpm=80).
Only the choices a study may change are here; the details of the methods taken from
eitprocessing or fixed by the evidence are constants of their modules
(cardiac_filter, breaths, breath_quality, lung_mask,
breath_pressures, tidal_volume). Evidence:
notebooks/05_preprocessing_choices.ipynb (section in brackets).
Attributes:
| Name | Type | Description |
|---|---|---|
heart_rate_bpm |
float | None
|
Heart rate entered by the user (beats/min), e.g. from the monitor. If given, the MDN filter removes the cardiac component; if None, only the moving average is applied. The heart rate is never estimated from the data: the estimate was wrong in 2 of 11 recordings and a wrong heart rate close to the respiratory rate damages the breaths (section 5b). It is a snapshot: a heart rate that drifts during the recording, or an arrhythmia such as atrial fibrillation, is not removed by the MDN filter. |
moving_average_seconds |
float
|
Width of the centred moving average used when no heart
rate is given (section 5c): the |
breath_short_seconds, |
breath_long_seconds
|
A breath shorter or longer than this
is flagged ( |
ti_ratio_low, |
ti_ratio_high
|
A breath with Ti/Ttot outside this range is
flagged ( |
local_window_breaths |
int
|
Breaths, centred on each breath, whose median is the reference for the outlier flags: 21 are about 40 s at 30 breaths/min, long enough to ignore one event, short enough to follow a PEEP change (section 8). |
amplitude_ratio_low, |
amplitude_ratio_high
|
A breath with an amplitude below
or above these times the local median is flagged
( |
duration_ratio_high |
float
|
A breath longer than this times the local median duration
is flagged ( |
lung_mask_threshold_fraction |
float
|
A pixel is lung when its mean TIV (and, for the
watershed, its amplitude) is at least this fraction of the maximum TIV
(eitprocessing |
exclusion_margin_seconds |
float
|
Every exclusion (manual or from the device) is
widened by this margin on both sides, because the forward-backward filters
spread an artifact over the neighbouring samples (the margin around invalid
data of eitprocessing |
SegmentationConfig
dataclass
¶
SegmentationConfig(step_threshold: float = 1.0, analysis_skip_seconds: float = 15.0, analysis_max_breaths: int = 10, analysis_min_breaths: int = 5, peep_levels: tuple[float, ...] | None = None)
Parameters of the PEEP trial segmentation (layer 2b).
Protocol choices tested on four decremental trials
(notebooks/06_peep_trial_segmentation.ipynb, section in brackets); pressures in
cmH2O. The details of the step finding are constants of peep_steps.
Attributes:
| Name | Type | Description |
|---|---|---|
step_threshold |
float
|
Half of the PEEP step of the protocol (1 for steps of 2): a new step starts when 3 breaths in a row are further than this from the current level and within this of each other; a breath is analysed only if its PEEP is within half of this of the level of its step (section 3, 5). |
analysis_skip_seconds |
float
|
In each step the breaths in this time after the change of PEEP are not analysed, as EELI is still moving (section 5). |
analysis_max_breaths, |
analysis_min_breaths
|
Then the last valid breaths of the
step are analysed, up to |
peep_levels |
tuple[float, ...] | None
|
PEEP levels of the protocol, e.g. |
AnalysisConfig
dataclass
¶
AnalysisConfig(ri_peep_high: float = 15.0, ri_peep_low: float = 5.0, ri_min_peep_drop: float = 10.0)
Parameters of layer 3 (clinical indices).
The definitions of the indices are fixed in notebooks/07_clinical_indices.ipynb;
only the recruitment-to-inflation ratio has parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
ri_peep_high, |
(ri_peep_low, ri_min_peep_drop)
|
The R/I of a PEEP trial compares the
step nearest to |
Config
dataclass
¶
Config(preprocessing: PreprocessingConfig = PreprocessingConfig(), segmentation: SegmentationConfig = SegmentationConfig(), analysis: AnalysisConfig = AnalysisConfig())
Top-level configuration container for the fasteit pipeline.
Aggregates PreprocessingConfig, SegmentationConfig and AnalysisConfig.
Example
cfg = Config() cfg.preprocessing cfg.segmentation cfg.analysis