LR-HSMM
Logistic Regression - Hidden Semi-Markov Model segmenter
Based on: D. B. Springer, L. Tarassenko and G. D. Clifford, “Logistic Regression-HSMM-Based Heart Sound Segmentation,” in IEEE Transactions on Biomedical Engineering, vol. 63, no. 4, pp. 822-832, April 2016, doi: 10.1109/TBME.2015.2475278.
- class pyPCG.lr_hsmm.LR_HSMM[source]
Main segmenter object
- signal_fs
Sampling frequency of the input signal. Default: 1000 [Hz]
- Type:
int
- feature_fs
Sampling frequency for feature calculations. Default: 50 [Hz]
- Type:
int
- mean_s1_len
Average S1 duration. Default: 122 [ms]
- Type:
float
- mean_s2_len
Average S2 duration. Default: 99 [ms]
- Type:
float
- std_s1_len
Standard deviation of S1 durations. Default: 22 [ms]
- Type:
float
- std_s2_len
Standard deviation of S2 durations. Default: 22 [ms]
- Type:
float
- bandpass_frq
Cutoff frequencies for pre-processing band-pass filtering (Butterworth, 4th order). Default: (25,400) [Hz]
- Type:
tuple[float,float]
- expected_hr_range
Minimum and maximum expected heartrates. Default: (30,120) [bpm]
- Type:
tuple[float,float]
- hsmm_model
State predictor model
- Type:
hsmmlearn.hsmm.HSMMModel
- lr_model
Probability emissions for the HSMM states. Includes a LogisticRegression model for each state
- Type:
hsmmlearn.emissions.AbstractEmissions
- load_model(filename: str) None[source]
Loads the model parameters from a json file
- Parameters:
filename (str) – Name of file containing model parameters
- save_model(filename: str) None[source]
Saves the model parameters to a json file
- Parameters:
filename (str) – Name of file to be saved
- segment_single(sig: ndarray[tuple[int, ...], dtype[float64]], recalc_timing: bool = False) tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]]][source]
Predicts the states for the given PCG signal
- Parameters:
sig (np.ndarray) – Input signal to be segmented
- Returns:
Predicted state for each sample and the calculated features
- Return type:
tuple[np.ndarray,np.ndarray]
- train_model(train_data: ndarray[tuple[int, ...], dtype[float64]] | list[float], train_s1_annot: ndarray[tuple[int, ...], dtype[float64]] | list[float], train_s2_annot: ndarray[tuple[int, ...], dtype[float64]] | list[float], multiprocess: int | None = None) None[source]
Trains the model on the specified data with S1 and S2 location annotations
- Parameters:
train_data (np.ndarray) – Array of input signals
train_s1_annot (np.ndarray) – Array of S1 annotations for each signal
train_s2_annot (np.ndarray) – Array of S2 annotations for each signal