resurfemg.modelling.tau_estimation module¶
Copyright 2026 Netherlands eScience Center and University of Twente Licensed under the Apache License, version 2.0. See LICENSE for details.
This file contains functions for estimating the time constant (tau) of the respiratory system.
- tau_mask(p_aw, flow, volume, peep, fs, zc_idxs=None, **kwargs)¶
Function to create a mask for the breaths based on various criteria. The criteria include the difference between Paw and PEEP, the flow signal, and the quality of the breaths. The function returns a boolean mask indicating the samples that meet the criteria. Optional keyword arguments can be provided to customize the criteria: theta_paw_peep, theta_flow, flow_threshold (zero-crossing), min_duration, min_tv, max_v0, and min_vol. :param p_aw: The airway pressure signal. :type p_aw: ~numpy.ndarray :param flow: The flow signal. :type flow: ~numpy.ndarray :param volume: The volume signal. :type volume: ~numpy.ndarray :param peep: The PEEP signal. :type peep: ~numpy.ndarray :param fs: The sampling rate of the signals. :type fs: int :param zc_idxs: The indices of the zero-crossings of the flow signal. :type zc_idxs: ~numpy.ndarray :param kwargs: Additional keyword arguments for the criteria. :type kwargs: dict
- Return mask:
A boolean mask indicating the samples that meet the criteria.
- Return type:
- tau_switch_smf(df, theta_act_exp=4.685, verbose=False)¶
Estimate the time constant (tau) using a robust linear model with Tukey’s biweight function. The model is fitted to the end-expiratory slope between volume and flow data. The breath ID is included as a categorical variable to account for breath-specific offsets. :param df: A DataFrame containing the flow, volume, and breath identifier. :type df: ~pandas.DataFrame :param theta_act_exp: The tuning constant for Tukey’s biweight function. :type theta_act_exp: float :param verbose: If True, print the model summary and estimated tau. :type verbose: bool
- Return tau, mdl:
The estimated time constant and the fitted model.
- Return type:
float, RLMResults