
Security News
AI Slop Is Polluting Bug Bounty Platforms with Fake Vulnerability Reports
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
An End-to-End PPG processing pipeline: from quality assessment and motion artifacts romval to HR/HRV extraction
Welcome to the PPG Signal Processing Pipeline, a comprehensive package designed for extracting accurate Heart Rate (HR) and Heart Rate Variability (HRV) data from Photoplethysmogram (PPG) signals.
This project provides a robust pipeline for processing PPG signals, extracting reliable HR and HRV parameters. The pipeline encompasses various stages, including filtering, signal quality assessment (SQA), signal reconstruction, peak detection and interbeat interval (IBI) extraction, and HR and HRV computation.
The input raw PPG signal undergoes filtering to remove undesired frequencies. A second-order Butterworth bandpass filter is employed, allowing frequencies within a specific range to pass while rejecting frequencies outside.
SQA involves identifying clean and noisy parts within PPG signals. Our SQA approach requires PPG signals in a fixed length, which necessitates segmenting the input signals. To this end, we apply a moving window segmentation technique, where the PPG signals are divided into overlapping segments, each spanning 30 seconds, by sliding a window over the signal. The SQA process includes PPG feature extraction and classification, employing a one-class support vector machine model to distinguish between "Reliable" and "Unreliable" segments.
Noisy parts within PPG signals, shorter than a specified threshold, are reconstructed using a deep convolutional generative adversarial network (GAN). The GAN model includes a generator trained to produce synthetic clean PPG segments and a discriminator to differentiate real from synthetic signals. The reconstruction process is applied iteratively to ensure denoising.
Systolic peaks in PPG signals are identified using a deep-learning-based method with dilated Convolutional Neural Networks (CNN) architecture. PPG peak detection enables the extraction of IBI values that serve as the basis for obtaining HR and HRV. IBI represents the time duration between two consecutive heartbeats and is computed by measuring the time interval between systolic peaks within the PPG signals.
HR and HRV parameters are computed from the extracted IBIs. A variety of metrics are calculated, including:
Install the e2epyppg
package using the following pip command:
pip install e2epyppg
e2e_hrv_extraction()
End-to-end HR and HRV extraction from an input raw PPG signal.
input_sig
(np.ndarray
): The input PPG signal.sampling_rate
(int
): The sampling rate of the input signal.window_length_sec
(int
, optional): The desired window length for HR and HRV extraction in seconds (default: 60).peak_detection_method
(str
, optional): The method used for peak detection. Valid inputs: 'kazemi', 'nk' (Neurokit), and 'heartpy' (default: 'kazemi').hrv_data
(pd.DataFrame
): A DataFrame containing HRV parameters ('None' if no clean segments detected in the signal).If it takes a long time to process, consider segmenting the signal into shorter segments for more efficient processing.
Feli, M., Kazemi, K., Azimi, I., Wang, Y., Rahmani, A., & Liljeberg, P. (2023). End-to-End PPG Processing Pipeline for Wearables: From Quality Assessment and Motion Artifacts Removal to HR/HRV Feature Extraction. In 2023 IEEE International Conference on Bioinformatics and Biomedicine (BIBM). IEEE.
from e2epyppg.utils import get_data
from e2epyppg.e2e_ppg_pipeline import e2e_hrv_extraction
# Provide your PPG signal and sampling rate (you can use your own signal in format `np.ndarray`)
file_name = "201902020222_Data.csv"
input_sig = get_data(file_name=file_name)
sampling_rate = 20
# Set the desired window length for HR and HRV features extraction (in seconds)
window_length_sec = 60
# Set the peak detection method (optional)
peak_detection_method = 'kazemi'
# Call the end-to-end function
hrv_data = e2e_hrv_extraction(input_sig, sampling_rate, window_length_sec, peak_detection_method)
sqa()
Perform PPG Signal Quality Assessment (SQA).
This function assesses the quality of a PPG signal by classifying its segments as reliable (clean) or unreliable (noisy) using a pre-trained model. The clean indices represent parts of the PPG signal that are deemed reliable, while the noisy indices indicate parts that may be affected by noise or artifacts.
sig
(np.ndarray
): PPG signal.sampling_rate
(int
): Sampling rate of the PPG signal.filter_signal
(bool
, optional): True if the signal has not been filtered using a bandpass filter.clean_indices
(list
): A list of clean indices.noisy_indices
(list
): A list of noisy indices.If it takes a long time to process, consider segmenting the signal into shorter segments for more efficient processing.
Feli, M., Azimi, I., Anzanpour, A., Rahmani, A. M., & Liljeberg, P. (2023). An energy-efficient semi-supervised approach for on-device photoplethysmogram signal quality assessment. Smart Health, 28, 100390.
from e2epyppg.utils import get_data
from e2epyppg.ppg_sqa import sqa
# Provide your PPG signal and sampling rate (you can use your own signal in format `np.ndarray`)
file_name = "201902020222_Data.csv"
input_sig = get_data(file_name=file_name)
sampling_rate = 20
# Set this parameter True if the signal has not been filtered:
filter_signal = True
# Call the PPG signal quality assessment function
clean_indices, noisy_indices = sqa(input_sig, sampling_rate, filter_signal)
reconstruction()
Reconstruct noisy PPG signals using Generative Adversarial Network (GAN).
sig
(np.ndarray
): Original PPG signal.clean_indices
(list
): List of indices representing clean parts (obtained from sqa()).noisy_indices
(list
): List of indices representing noisy parts (obtained from sqa()).sampling_rate
(int
): Sampling rate of the signal.filter_signal
(bool
, optional): True if the signal has not been filtered using a bandpass filter.ppg_signal
(np.ndarray
): Reconstructed PPG signal (if reconstruction is applied; otherwise, returns the original signal).clean_indices
(list
): Updated indices of clean parts (if reconstruction is applied; otherwise, returns the original indices of clean parts).noisy_indices
(list
): Updated indices of noisy parts (if reconstruction is applied; otherwise, returns the original indices of noisy parts).If it takes a long time to process, consider segmenting the signal into shorter segments for more efficient processing.
Wang, Y., Azimi, I., Kazemi, K., Rahmani, A. M., & Liljeberg, P. (2022, July). Ppg signal reconstruction using deep convolutional generative adversarial network. In 2022 44th Annual International Conference of the IEEE Engineering in Medicine & Biology Society (EMBC) (pp. 3387-3391). IEEE.
from e2epyppg.utils import get_data
from e2epyppg.ppg_sqa import sqa
from e2epyppg.ppg_reconstruction import reconstruction
# Provide your PPG signal and sampling rate (you can use your own signal in format `np.ndarray`)
file_name = "201902020222_Data.csv"
input_sig = get_data(file_name=file_name)
sampling_rate = 20
# Set this parameter True if the signal has not been filtered:
filter_signal = True
# Call the PPG signal quality assessment function
clean_indices, noisy_indices = sqa(input_sig, sampling_rate, filter_signal)
# Call the PPG reconstruction function
ppg_reconstructed, updated_clean_indices, updated_noisy_indices = reconstruction(input_sig, clean_indices, noisy_indices, sampling_rate, filter_signal)
clean_seg_extraction()
Scan the clean parts of the signal and extract clean segments based on the input window length.
sig
(np.ndarray
): Input PPG signal.noisy_indices
(list
): List of noisy segment indices (obtained from sqa() or reconstruction()).window_length
(int
): Desired window length for clean segment extraction in terms of samples (not seconds).clean_segments
(list
): List of clean PPG segments with the specified window length and their starting index.from e2epyppg.utils import get_data
from e2epyppg.ppg_sqa import sqa
from e2epyppg.ppg_reconstruction import reconstruction
from e2epyppg.ppg_clean_extraction import clean_seg_extraction
# Provide your PPG signal and sampling rate (you can use your own signal in format `np.ndarray`)
file_name = "201902020222_Data.csv"
input_sig = get_data(file_name=file_name)
sampling_rate = 20
window_length_sec = 60
# Set this parameter True if the signal has not been filtered:
filter_signal = True
# Call the PPG signal quality assessment function
clean_indices, noisy_indices = sqa(input_sig, sampling_rate, filter_signal)
# Call the PPG reconstruction function
ppg_reconstructed, updated_clean_indices, updated_noisy_indices = reconstruction(input_sig, clean_indices, noisy_indices, sampling_rate, filter_signal)
# Set the window length for HR and HRV extraction in terms of samples
window_length = window_length_sec*sampling_rate
# Call the clean segment extraction function
clean_segments = clean_seg_extraction(ppg_reconstructed, updated_noisy_indices, window_length)
peak_detection()
Detect peaks in clean PPG segments using the specified peak detection method.
clean_segments
(list
): List of clean PPG segments with the specified window length and their starting index (obtained from clean_seg_extraction()).sampling_rate
(int
): Sampling rate of the PPG signal.method
(str
, optional): Peak detection method. Valid inputs: 'kazemi', 'nk' (Neurokit), and 'heartpy'. (default: 'kazemi').total_peaks
(list
): List of lists, each containing the detected peaks for a corresponding clean segment.from e2epyppg.utils import get_data
from e2epyppg.ppg_sqa import sqa
from e2epyppg.ppg_reconstruction import reconstruction
from e2epyppg.ppg_clean_extraction import clean_seg_extraction
from e2epyppg.ppg_peak_detection import peak_detection
# Provide your PPG signal and sampling rate (you can use your own signal in format `np.ndarray`)
file_name = "201902020222_Data.csv"
input_sig = get_data(file_name=file_name)
sampling_rate = 20
window_length_sec = 60
# Set this parameter True if the signal has not been filtered:
filter_signal = True
# Call the PPG signal quality assessment function
clean_indices, noisy_indices = sqa(input_sig, sampling_rate, filter_signal)
# Call the PPG reconstruction function
ppg_reconstructed, updated_clean_indices, updated_noisy_indices = reconstruction(input_sig, clean_indices, noisy_indices, sampling_rate, filter_signal)
# Set the window length for HR and HRV extraction in terms of samples
window_length = window_length_sec*sampling_rate
# Call the clean segment extraction function
clean_segments = clean_seg_extraction(ppg_reconstructed, updated_noisy_indices, window_length)
# Set the peak detection method (optional)
peak_detection_method = 'kazemi'
# Call the peak detection function
peaks = peak_detection(clean_segments, sampling_rate, peak_detection_method)
hrv_extraction()
Calculate HR and HRV parameters from clean segments peak indices.
clean_segments
(list
): List of clean PPG segments and their starting index (obtained from clean_seg_extraction()).peaks
(list
): List of lists, each containing the detected peaks for a corresponding clean segment (obtained from peak_detection()).sampling_rate
(int
): Sampling rate of the PPG signal.window_length
(int
): Desired window length for HR and HRV extraction in terms of samples (not seconds).hrv_data
(pd.DataFrame
): DataFrame containing HRV parameters for all clean segments.from e2epyppg.utils import get_data
from e2epyppg.ppg_sqa import sqa
from e2epyppg.ppg_reconstruction import reconstruction
from e2epyppg.ppg_clean_extraction import clean_seg_extraction
from e2epyppg.ppg_peak_detection import peak_detection
from e2epyppg.ppg_hrv_extraction import hrv_extraction
# Provide your PPG signal and sampling rate (you can use your own signal in format `np.ndarray`)
file_name = "201902020222_Data.csv"
input_sig = get_data(file_name=file_name)
sampling_rate = 20
window_length_sec = 60
# Set this parameter True if the signal has not been filtered:
filter_signal = True
# Call the PPG signal quality assessment function
clean_indices, noisy_indices = sqa(input_sig, sampling_rate, filter_signal)
# Call the PPG reconstruction function
ppg_reconstructed, updated_clean_indices, updated_noisy_indices = reconstruction(input_sig, clean_indices, noisy_indices, sampling_rate, filter_signal)
# Set the window length for HR and HRV extraction in terms of samples
window_length = window_length_sec*sampling_rate
# Call the clean segment extraction function
clean_segments = clean_seg_extraction(ppg_reconstructed, updated_noisy_indices, window_length)
# Set the peak detection method (optional)
peak_detection_method = 'kazemi'
# Call the peak detection function
peaks = peak_detection(clean_segments, sampling_rate, peak_detection_method)
# Call the HR and HRV feature extraction function
hrv_data = hrv_extraction(clean_segments, peaks, sampling_rate, window_length)
If you use our work in your research, please consider citing the following papers:
End-to-End PPG Processing Pipeline for Wearables: From Quality Assessment and Motion Artifacts Removal to HR/HRV Feature Extraction (PPG Pipeline Paper)
@inproceedings{feli2023end,
title={End-to-End PPG Processing Pipeline for Wearables: From Quality Assessment and Motion Artifacts Removal to HR/HRV Feature Extraction},
author={Feli, Mohammad and Kazemi, Kianoosh and Azimi, Iman and Wang, Yuning and Rahmani, Amir and Liljeberg, Pasi},
booktitle={2023 IEEE International Conference on Bioinformatics and Biomedicine (BIBM)},
year={2023},
organization={IEEE}
}
An Energy-Efficient Semi-Supervised Approach for On-Device Photoplethysmogram Signal Quality Assessment (PPG Signal Quality Assessment Paper)
@article{feli2023energy,
title={An Energy-Efficient Semi-Supervised Approach for On-Device Photoplethysmogram Signal Quality Assessment},
author={Feli, Mohammad and Azimi, Iman and Anzanpour, Arman and Rahmani, Amir M and Liljeberg, Pasi},
journal={Smart Health},
volume={28},
pages={100390},
year={2023},
publisher={Elsevier}
}
PPG Signal Reconstruction Using Deep Convolutional Generative Adversarial Network (PPG Reconstruction Paper)
@inproceedings{wang2022ppg,
title={PPG Signal Reconstruction Using Deep Convolutional Generative Adversarial Network},
author={Wang, Yuning and Azimi, Iman and Kazemi, Kianoosh and Rahmani, Amir M and Liljeberg, Pasi},
booktitle={2022 44th Annual International Conference of the IEEE Engineering in Medicine \& Biology Society (EMBC)},
pages={3387--3391},
year={2022},
organization={IEEE}
}
Robust PPG Peak Detection Using Dilated Convolutional Neural Networks (PPG Peak Detection Paper)
@article{kazemi2022robust,
title={Robust PPG Peak Detection Using Dilated Convolutional Neural Networks},
author={Kazemi, Kianoosh and Laitala, Juho and Azimi, Iman and Liljeberg, Pasi and Rahmani, Amir M},
journal={Sensors},
volume={22},
number={16},
pages={6054},
year={2022},
publisher={MDPI}
}
We would like to express our sincere gratitude to Prof Pasi Liljeberg and Prof Amir M. Rahmani for their guidance and support throughout this project.
We welcome contributions to enhance and extend the capabilities of the PPG Signal Processing Pipeline.
This project is licensed under the terms of the MIT License.
FAQs
An End-to-End PPG processing pipeline: from quality assessment and motion artifacts romval to HR/HRV extraction
We found that e2epyppg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
Research
Security News
The Socket Research team investigates a malicious Python package disguised as a Discord error logger that executes remote commands and exfiltrates data via a covert C2 channel.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.