When using wavelet analysis with the CalculatePowerBand function, the user may specify:
Wavelet: mother wavelet used to calculate the spectrogram. Some of the most widely used wavelets are available: Haar (“haar”), extremal phase (“d4”, “d6”, “d8” and “d16”) and the least asymmetric Daubechies (“la8”, “la16” and “la20”) and the best localized Daubechies (“bl14” and “bl20”) wavelets among others. The default value is “d4”. The name of the wavelet specifies the “family” (the family determines the shape of the wavelet and its properties) and the length of the wavelet. For example, “la8” belongs to the Least Asymmetric family and has a length of 8 samples. We may give a simple advice for wavelet selection based on the wavelet’s length: shorter wavelets usually have better temporal resolution, but worse frequency resolution. On the other hand, longer wavelets usually have worse temporal resolution, but they provide better frequency resolution. Better temporal resolution means that we can study shorter time intervals. On the other hand, a better frequency resolution means better “frequency discrimination”. That is, shorter wavelets will tend to fail when discriminating close frequencies.
Bandtolerance: maximum error allowed when the wavelet-based analysis is performed [12], [13]. It can be specified as either an absolute or a relative error depending on the “relative” parameter value. Default value is 0.01.
Relative: logic value specifying which type of band tolerance shall be used: relative (in percentage) or absolute (default value)
Let [fl, fu] be any frequency band specified by the user and let [f1, f2] be a frequency interval associated with some node in the Maximal Overlap Discrete Wavelet Packet Transform (MODWPT) tree [29]. The relative error ϵr of fl over the [f1, f2] interval is computed as
ϵr ≡ \frac{\lvert fl - f1 \rvert}{\lvert fu - fl \rvert} \cdot 100\%
Similarly, we may define the error ϵr of the upper frequency fu as
ϵr ≡ \frac{ \lvert fu - f2 \rvert}{ \lvert fu - fl \rvert} \cdot 100\%
The relative error can be used to avoid introducing large errors at small frequency bands (usually both ULF and VLF bands).
The absolute value ϵ is defined as usual: ϵ =|f2 − fu| for the upper frequency and ϵ = |f1 − fl| for the lower frequency.
Figure 1: Plot obtained with the PlotPowerBand for the wavelet analysis.
Source Code
---title: Garmin FIT files for RHRV analysissubtitle: 4. Wevlet analysissubtitle-size: 2emauthor: - Kizen Sasakidate: 2023-11-30date-modified: todaydate-format: 'YYYY MMMM DD'language: title-block-published: First version titel-block-modified: This versionformat: html: html-math-method: katex code-tools: true code-fold: true pdf: geometry: - top=30mm - left=30mm docx: default---##### Fourier analysis and Plotting Fourier analysis```{r}#| message: falselibrary(readr)library(RHRV)``````{r}FileNo <-1FileName <-paste0("time_HR_", FileNo, ".csv")data <-read.table(file.path("csv_xls", FileName), header =TRUE, sep =",", colClasses =c("character", "numeric"))``````{r}hr <- data[,2]rr <-1/hrrr = rr*60*1000``````{r}#| message: falsehrv.data <-CreateHRVData()hrv.data <-SetVerbose(hrv.data, TRUE)hrv.data$Beat$RR = rrhrv.data$Beat$niHR = hrhrv.data$Beat$Time =cumsum(rr)/1000hrv.data <-BuildNIHR(hrv.data)hrv.data <-FilterNIHR(hrv.data)hrv.data <-InterpolateNIHR(hrv.data, freqhr =4)hrv.data <-CreateFreqAnalysis(hrv.data)hrv.data <-SetVerbose(hrv.data, TRUE)``````{r}#| message: falsehrv.data <-CalculatePowerBand(hrv.data, indexFreqAnalysis =1,type ="wavelet", wavelet ="la8",bandtolerance =0.01, relative =FALSE)```When using wavelet analysis with the CalculatePowerBand function, the user may specify:- Wavelet: mother wavelet used to calculate the spectrogram. Some of the most widely used wavelets are available: Haar ("haar"), extremal phase ("d4", "d6", "d8" and "d16") and the least asymmetric Daubechies ("la8", "la16" and "la20") and the best localized Daubechies ("bl14" and "bl20") wavelets among others. The default value is "d4". The name of the wavelet specifies the "family" (the family determines the shape of the wavelet and its properties) and the length of the wavelet. For example, "la8" belongs to the Least Asymmetric family and has a length of 8 samples. We may give a simple advice for wavelet selection based on the wavelet's length: shorter wavelets usually have better temporal resolution, but worse frequency resolution. On the other hand, longer wavelets usually have worse temporal resolution, but they provide better frequency resolution. Better temporal resolution means that we can study shorter time intervals. On the other hand, a better frequency resolution means better "frequency discrimination". That is, shorter wavelets will tend to fail when discriminating close frequencies.\- Bandtolerance: maximum error allowed when the wavelet-based analysis is performed \[12\], \[13\]. It can be specified as either an absolute or a relative error depending on the "relative" parameter value. Default value is 0.01.\- Relative: logic value specifying which type of band tolerance shall be used: relative (in percentage) or absolute (default value)\ Let \[fl, fu\] be any frequency band specified by the user and let \[f1, f2\] be a frequency interval associated with some node in the Maximal Overlap Discrete Wavelet Packet Transform (MODWPT) tree \[29\]. The relative error ϵr of fl over the \[f1, f2\] interval is computed as $$ ϵr ≡ \frac{\lvert fl - f1 \rvert}{\lvert fu - fl \rvert} \cdot 100\% $$ Similarly, we may define the error ϵr of the upper frequency fu as\ $$ ϵr ≡ \frac{ \lvert fu - f2 \rvert}{ \lvert fu - fl \rvert} \cdot 100\% $$ The relative error can be used to avoid introducing large errors at small frequency bands (usually both ULF and VLF bands).The absolute value ϵ is defined as usual: ϵ =\|f2 − fu\| for the upper frequency and ϵ = \|f1 − fl\| for the lower frequency.### Plotting Wevelet analysis@fig-PlotPowerBand Wevelet analysis ymax = 700, ymaxratio = 50```{r}#| fig-width: 9#| fig-height: 11#| echo: false#| message: false#| label: fig-PlotPowerBand#| fig.cap: "Plot obtained with the PlotPowerBand for the wavelet analysis."PlotPowerBand(hrv.data, indexFreqAnalysis =1, ymax =700, ymaxratio =50)```