pyheartlib.beat_info
Module Contents
Classes
Provides information and features for a single beat. |
- class pyheartlib.beat_info.BeatInfo(beat_loc=10, fs=360, in_ms=True)
Provides information and features for a single beat.
- Parameters:
beat_loc (int) – Index of beat in the R-peaks locations list, considering preceding R-peak locations and subsequent R-peak locations.
fs (int, optional) – Sampling rate, by default 360
in_ms (bool, optional) – Whether to calculate RR-intervals in time (miliseconds) or samples, by default True
- beat_loc
Index of beat in the R-peaks locations list, considering preceding R-peak locations and subsequent R-peak locations.
- Type:
int
- fs
Sampling rate, by default 360
- Type:
int, optional
- in_ms
Whether to calculate RR-intervals in time (miliseconds) or samples, by default True
- Type:
bool, optional
- input_waveform
Input waveform, that is not trimmed (len_waveform, #channels).
- Type:
numpy.ndarray
- bwaveform
Segmented beat waveform. Selected as a segment of the input waveform (len_waveform, #channels).
- Type:
numpy.ndarray
- start_idx
The index of the first sample (onset) of the waveform on the original signal.
- Type:
int
- rri
List of RR-intervals, in miliseconds if the in_ms parameter has been set to True.
- Type:
list
- rri_smpl
RR-intervals in samples.
- Type:
list
- sdrri
Successive RR interval (RRI) differences.
- Type:
list
- avail_features
List of features names (strings) that already have a definition (predefined features).
- Type:
list
- features
Dictionary containing computed features. Keys are feature names and values are features values.
- Type:
dict
Notes
BeatInfo includes some predefined features, however custom features can also be defined. Each custom feature definition must adhere to this syntax and its name must start with F_:
>>> def F_new_feature(self): >>> return return_result
The return_result must be one of the following:
A real number.
2) A dictionary such as {“Feature_1”: value_1, “Feature_2”: value_2}. Each value can be a real number. Alternatively, each value can be a one-dimensional array, list, or tuple. In this case, their elements must correspond to the channels.
3) Tuple or one-dimensional NumPy array. Their elements must correspond to the channels. For example, the return value of F_feat_new() as a tuple (element1, element2) will produce F_feat_new(CH1) for element1 and F_feat_new(CH2) for element2. The order of channels is determined by the CHANNEL field in the config.yaml file.
A list. An output as a list will be a list.
The custom features can be added to the beatinfo object by using the add_features() method, the list of all available features can be obtained using the available_features() method, and to select desired features for computation the select_features() method can be used.
- __call__(data)
- Parameters:
data (dict) –
A dict containing data about the beat with keys:
- ’waveform’numpy.ndarray
Waveform (len_waveform, #channels).
- ’rpeak_locs’list
A list containing locations of rpeaks.
- ’rec_id’int
Record id of the original signal which the excerpt is extracted from.
- ’start_idx’int
Index of beginnig of the segmented waveform in the original signal.
- ’label’str
Type of the beat.
- available_features()
Returns available features that can be computed.
- Returns:
List containing features names.
- Return type:
list
- add_features(new_features)
Adds new features.
- Parameters:
new_features (list) – Names of new features in a list. Such as: [new_feature_1, new_feature_2]
- select_features(features)
Select desired features for computation.
- Parameters:
features (list) – List of features names (strings).
- compute_features()
Computes features.
- Returns:
Dictionary with keys(strings) equal to feature names and dict values equal to features values.
- Return type:
dict
- get_beat_waveform(win=[-0.35, 0.65])
Segment beat waveform according to the pre and post RR-intervals.
- get_rris(in_ms)
Compute RR-intervals.
- Parameters:
in_ms (bool) – If True result will be in time(miliseconds), otherwise in samples.
- Returns:
Contains RR-intervals.
- Return type:
list
- get_sdrri()
Computes successive differences of rri.
- Returns:
Contains successive differences of rri.
- Return type:
list
- F_post_rri()
Post RR interval.
- F_pre_rri()
Pre RR interval.
- F_ratio_post_pre()
Ratio of post and pre RR-intervals.
- F_diff_post_pre()
Difference of post and pre RR-intervals.
- F_diff_post_pre_nr()
Normalized difference of post and pre RR-intervals.
- F_median_rri()
Median of RR-intervals.
- F_mean_pre_rri()
Mean of pre RR-intervals.
- F_rms_rri()
RMS of RR-intervals.
- F_std_rri()
STD of RR-intervals.
- F_ratio_pre_rms()
Ratio of pre RR interval to RMS of RR-intervals.
- F_ratio_post_rms()
Ratio of post RR interval to RMS of RR-intervals.
- F_diff_pre_avg_nr()
Difference of pre RR interval and median of RR-intervals, normalized by their RMS.
- F_diff_post_avg_nr()
Difference of post RR interval and median of RR-intervals, normalized by their RMS.
- F_compensate_ratio()
Compensation ratio.
- F_compensate_diff_nr()
Compensation diff normalized by RMS.
- F_heart_rate()
Heart rate.
- F_mean_sdrri()
Mean of successive RRI differences.
- F_absmean_sdrri()
Mean of absolute successive RRI differences.
- F_mean_pre_sdrri()
Mean of pre successive RRI differences.
- F_rms_sdrri()
RMS of successive RRI differences.
- F_std_sdrri()
STD of successive RRI differences.
- reported_rpeak()
- F_beat_max()
Max value of heartbeat waveform.
- F_beat_min()
Min value of heartbeat waveform.
- F_maxmin_diff()
Difference of max and min values of heartbeat waveform.
- F_maxmin_diff_norm()
Difference of max and min values of heartbeat waveform, normalized by waveform RMS.
- F_beat_mean()
Mean of heartbeat waveform.
- F_beat_std()
STD of heartbeat waveform.
- F_beat_skewness()
Skewness of heartbeat waveform.
- F_beat_kurtosis()
Kurtosis of heartbeat waveform.
- F_beat_rms()
RMS of heartbeat waveform.
- F_nsampels(n_samples=10)
Gives equally spaced samples of the trimmed heartbeat waveform.
- Parameters:
n_samples (int, optional) – Number of samples, by default 10
- Returns:
Waveform sample values.
- Return type:
dict
- F_fft_features()
Returns FFT of each heartbeat trimmed waveform.
- Return type:
dict