  One of the most promising non-invasive markers of the activity of the
autonomic nervous system is Heart Rate Variability (HRV). HRV analysis toolkits
often provide spectral analysis techniques using the Fourier transform, which
assumes that the heart rate series is stationary. To overcome this issue, the
Short Time Fourier Transform is often used (STFT). However, the wavelet
transform is thought to be a more suitable tool for analyzing non-stationary
signals than the STFT. Given the lack of support for wavelet-based analysis in
HRV toolkits, such analysis must be implemented by the researcher. This has
made this technique underutilized. This paper presents a new algorithm to
perform HRV power spectrum analysis based on the Maximal Overlap Discrete
Wavelet Packet Transform (MODWPT). The algorithm calculates the power in any
spectral band with a given tolerance for the band's boundaries. The MODWPT
decomposition tree is pruned to avoid calculating unnecessary wavelet
coefficients, thereby optimizing execution time. The center of energy shift
correction is applied to achieve optimum alignment of the wavelet coefficients.
This algorithm has been implemented in RHRV, an open-source package for HRV
analysis. To the best of our knowledge, RHRV is the first HRV toolkit with
support for wavelet-based spectral analysis.
