pyheartlib.processing
Module Contents
Classes
Methods for processing signals. |
|
Short Time Fourier Transform. |
- class pyheartlib.processing.Processing
Methods for processing signals.
- static apply(processors, signal)
Applies processors in order.
- Parameters:
processors (list) – List of tuples of (‘processor_name’, params)
signal (numpy.ndarray) – Signal
- static custom_processors(signal, processors=None)
Applies custom processors in order.
- Parameters:
signal (numpy.ndarray) – one-dimensional signal.
processors (list) – Definition of processor functions as a list.
- static remove_baseline(signal, sampling_rate=360)
Removes the signal baseline by applying two median filters.
- Parameters:
signal (numpy.ndarray) – 1D ndarray.
sampling_rate (int, optional) – sampling frequency, by default 360
- Returns:
Baseline removed signal.
- Return type:
numpy.ndarray
- static lowpass_filter_butter(signal, cutoff=45, sampling_rate=360, order=15)
Applies low pass filter to the signal.
- Parameters:
signal (numpy.ndarray) – A one-dimensional signal.
cutoff (int, optional) – Filter parameter, by default 45
sampling_rate (int, optional) – Sampling frequency, by default 360
order (int, optional) – Filter parameter, by default 15
- Returns:
Low pass filtered signal.
- Return type:
numpy.ndarray
- static denoise_signal(signal, remove_bl=True, lowpass=False, sampling_rate=360, cutoff=45, order=15)
Denoises the signal by removing the baseline wander and/or applying a low pass filter.
- Parameters:
signal (numpy.ndarray) – A one-dimensional signal.
remove_bl (bool, optional) – If True, removes baseline wander, by default True
lowpass (bool, optional) – If True, applies a low pass filter, by default False
sampling_rate (int, optional) – Sampling frequency, by default 360
cutoff (int, optional) – Low pass filter parameter, by default 45
order (int, optional) – Low pass filter parameter, by default 15
- Returns:
Denoised signal.
- Return type:
numpy.ndarray
- class pyheartlib.processing.STFT
Short Time Fourier Transform.
Example
>>> dpr = STFT() >>> features = dpr.specgram(x, sampling_rate=360, >>> nperseg=127, noverlap=122)
- specgram(signals, sampling_rate=None, nperseg=None, noverlap=None)
Applies Short Time Fourier Transform on the signals.
- Parameters:
signals (numpy.ndarray) – 2D array of raw signals. Each row is one signal.
sampling_rate (int, optional) – sampling_rate, by default None
nperseg (int, optional) – Window size (parameter of STFT), by default None
noverlap (int, optional) – Overlap (parameter of STFT), by default None
- Returns:
3D array of transformed signals.
- Return type:
numpy.ndarray
- calc_feat_dim(samp, win, overlap)
Calculates the 2D spectral feature size.
- Parameters:
samp (int) – Number of samples.
win (int) – Window size (parameter of STFT).
overlap (int) – Overlap (parameter of STFT).
- Returns:
Height and width.
- Return type:
int