Detection refinement to local ECG peaks¶
What it does¶
This utility moves each candidate detection to the maximum ECG sample inside a local search window.
When to use it¶
Use it to refine approximate ECG detections after a detector has identified the correct neighborhood but not the exact local peak sample.
Canonical ID: tools.snaptopeak
Inputs¶
| Name | Meaning | Type | Unit | Requirements |
|---|---|---|---|---|
ecg |
Sampled ECG signal used to refine candidate detections. | real vector | a.u. | minimum length: 2; NaN allowed; finite |
detections |
Candidate sample positions, one-based in MATLAB and zero-based in Python. | real vector | sample | NaN allowed; finite |
Parameters¶
| Name | Meaning | Type | Unit | Default | Requirements |
|---|---|---|---|---|---|
window_size |
Search radius around each candidate detection. | real scalar | sample | 20 |
greater than: 0 |
Outputs¶
| Name | Meaning | Type | Unit |
|---|---|---|---|
refined_detections |
Refined sample positions using the same native index origin as the input detections. | real vector | sample |
Interpretation and limitations¶
Detection inputs and outputs use the native index origin: 1 in MATLAB and 0 in Python. Fractional detections and the search radius round to the nearest integer, with half-way values rounded upward. Bounds are checked before rounding.
The method assumes the desired fiducial is the local maximum. Wide windows can jump to a neighboring wave, while narrow windows may not reach the intended peak. Missing samples inside the search region are ignored according to the defined NaN behavior.