## 2 Materials and Methods
### Method #2: Detect  
_Detect_ finds peaks without signal segmentation. As a result, it must adopt a different approach to the task. This study proposes using maximum heart rate based on the age of the subject. To estimate maximum heart rate, researchers have introduced various models. A popular one is that of [PERSON] (2016) (see (1)). Among others, it has been utilised by  
Figure 4: Both signal enhancement and Algorithm #1 are presented as a block diagram. The asterisks in the figure represent the detected AO from the algorithm.  
[PERSON] et al. in a study involving 166 children [27]. [PERSON] et al. studied a bone marrow collection from 30 male subjects (40-65 years, BMI less than 35 kg/m2, type 2 diabetes) and 30 controls [28]. [PERSON] et al. evaluated various models on more than 500 military personnel and found that [PERSON]'s model provided a good correlation with the maximum heart rate, maxHR, obtained in a graded exercise test [29];  
\[\text{maxHR}=205-\text{age}/2, \tag{1}\]  
where age is expressed in years.  
Maximum HR results in minimal RR intervals (_minRRI_), which can be used to correct errors. Wrongly detected peaks may arise from various sources, such as noise and oscillation characteristics around target peaks. Three measures were derived from _minRRI_: minimum peak distance for envelope finding (_minDistEnv_), minimum peak distance for peak detection (_minDistPeak_) and span (_correctionSpan_) to the right and left for peak correction (lines 1 to 5 in Algorithm 2). They were empirically derived from experiments.  
```
1:enhanced signal \(s\)_enh, positive integer \(age\).
2:positive integer \(true\)_peak_loc.
3:\(maxHR\leftarrow\) get maximum HR using \(age\) based on (5).
4:\(minRRI\leftarrow\) from maxHR.
5:\(minDistEnv\leftarrow\) calculate minimum distance peak for envelope calculation, 25% of _minRRI_.
6:\(minDistPeak\leftarrow\) calculate minimum distance for peak detection, 125% of _minRRI_.
7:\(correction\)_span\(\leftarrow\) calculate distance to left and right for peak correction, 90% of _minRRI_.
8:for all level do
9:\([app\)_coef, det_coef] = DWT(\(s\)_enh, level(\(i\))).
10:\(s\)_reconst_1 \(\leftarrow\) reconstruct signal from the latest detail.
11:\(corr\)_coef(\(i\)) = corr(\(s\)_reconst_1, \(s\)_enh).
12:\(chosen\)_level = max(\(corr\)_coef(k)) // \(chosen\)_level holds index with the highest value in \(corr\)_coeff
13:\(s\)_reconst_2 \(\leftarrow\) reconstruct the latest Detail from \(chosen\)_level
14:\(up\)_env \(\leftarrow\) upper envelope from \(s\)_reconst_2 based on \(minDistEnv\)
15:\(peak\)_loc \(\leftarrow\) peak location from \(up\)_env based on \(minDistPeak\)
16:for all peak_loc do
17:\(true\)_peak_loc \(\leftarrow\) find the largest amplitude from peak_loc-correctionSpan to peak_loc + correctionSpan.
```  
**Algorithm 2** Detect.  
_Detect_ starts with the application of DWT to the signal, be it whole or segmented, at a specific level, as in _Slice and Detect_ (lines 6 to 11 in Algorithm 2). An upper envelope of the latest Detail from the selected level is generated based on its peaks, which are separated by at least _minDistEnv_ (line 12 in Algorithm 2).  
This envelope is then searched for its peaks. The distance between adjacent peaks must be at least _minDistPeak_ (line 13 in Algorithm 2). These peaks point to systolic peak candidates of the original signal. Since getting the true systolic peaks cannot be guaranteed, they should be verified by finding the largest amplitude around the detected location. The width of the search area is limited by _correctionSpan_ (lines 14 to 15 in Algorithm 2). Figure 5 presents Algorithm #2, including signal enhancement, in a block diagram.