-
-
Notifications
You must be signed in to change notification settings - Fork 506
Description
I would like to propose the addition of a preprocessing step in the "nk.ppg_process()" pipeline that detects and corrects over-amplitude artifacts in PPG signals — specifically:
-
Abnormally large systolic peaks that exceed a physiological threshold (often due to motion or sensor pressure).
-
Elevated base point amplitudes between peaks that distort the waveform baseline and may lead to false HRV or peak detections.
The algorithm I’ve implemented uses:
-
Peak-to-peak segmentation
-
Local minimum detection to find base points
-
A thresholding method to identify and correct outliers.
This correction improves signal quality and downstream feature extraction (e.g., HRV, waveform morphology). I’d like to contribute this as a new optional step or utility function. I attach some figures of that:



The proposed feature could be implemented as an optional preprocessing function, either integrated into nk.ppg_process() or as a separate utility (e.g., nk.ppg_artifact_correction()), and follow this general approach:
Signal Cleaning: Use nk.ppg_clean() as usual to preprocess the raw PPG signal.
Peak Detection: Detect systolic peaks using nk.ppg_findpeaks().
Base Point Detection:
For each pair of adjacent peaks, find the local minimum between them (the base point).
This can be done using np.argmin() within the peak-to-peak segment.
Thresholding for Artifacts:
Compute statistical thresholds for both peak and base point amplitudes.
Identify over-amplified peaks and elevated base points as artifacts.
Correction Strategy:
Replace detected artifacts with a corrected value, such as the average of neighboring valid points, or clip to the threshold.
Optionally, mark corrected points in the Info dictionary for visualization and transparency.
Output:
Return the corrected signal along with updated info (e.g., PPG_Corrected, PPG_Artifacts).
Allow users to enable/disable this correction via an argument like artifact_correction=True.