Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .Rhistory
Empty file.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.DS_Store
/Manifest.toml
/docs/Manifest.toml
/dev/
/docs/build/
.Rhistory
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "HeartRateVariability"
uuid = "0047d930-76bf-11ea-1377-bb3cda807e9f"
authors = ["Jasmin Walter <jasmin.walter@mni.thm.de>"]
version = "1.0"
version = "1.0.0"

[deps]
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
Expand All @@ -12,10 +12,10 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Trapz = "592b5752-818d-11e9-1e9a-2b8ca4a44cd1"

[compat]
Images = "0.22"
LombScargle = "0.5"
StatsBase = "0.33"
Images = "0.22, 0.23"
LombScargle = "0.5, 1.0"
Plots = "1.4"
StatsBase = "0.33, 0.34"
Trapz = "2.0"
julia = "1"

Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
HeartRateVariability = "0047d930-76bf-11ea-1377-bb3cda807e9f"

[compat]
Documenter = "0.24"
4 changes: 3 additions & 1 deletion docs/src/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ for i=2...n
rr _{i} := \frac{2*(RR_{i}-RR_{i-1})}{RR_{i}+RR_{i-1}}
```
where n is the number of RR intervals.\
The HRV is measured by the median of the euclidean distances of the relative RR intervals to the average of the relative RR intervals. [Read more](https://marcusvollmer.github.io/HRV/files/paper_method.pdf)
The HRV is measured by the median of the euclidean distances of the relative RR intervals to the average of the relative RR intervals. [Read more](https://marcusvollmer.github.io/HRV/files/paper_method.pdf) [^1]

[^1]: Vollmer, M. (2015). A robust, simple and reliable measure of heart rate variability using relative RR intervals. 2015 Computing in Cardiology Conference (CinC), 609–612. https://doi.org/10.1109/CIC.2015.7410984

# Frequency-Domain Analysis

Expand Down
4 changes: 2 additions & 2 deletions src/Frequency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Trapz

#=
This function calculates a lomb scargle transformation
:param n: is the array that contains the NN-inetrvals
:param n: is the array that contains the NN-intervals
:return: the result of the lomb scargle transformation
=#
function lomb_scargle(n)
Expand All @@ -16,7 +16,7 @@ function lomb_scargle(n)
end # lomb_scargle

#=
This function calculates the power of a frequency band between two given frequencys
This function calculates the power of a frequency band between two given frequencies
:param freq: The frequency of a lomb scargle transformation
:param power: The power of a lomb scargle transformation
:param min: The minimum value of the frequency band to be calculated
Expand Down
6 changes: 3 additions & 3 deletions src/Geometric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Images

#=
This function creates a Poincaré plot
:param n: is the array that contains the NN-inetrvals
:param n: is the array that contains the NN-intervals
:return: a plot object
=#
function poincare(n)
Expand All @@ -21,8 +21,8 @@ end # poincare

#=
This function creates a recurrence plot
:param n: is the array that contains the NN-inetrvals
:param e: the maximum distance between two intervals, default="mean" == the mean value of succsessive differences
:param n: is the array that contains the NN-intervals
:param e: the maximum distance between two intervals, default="mean" == the mean value of successive differences
:return: a plot object
=#
function recurrence(n,e)
Expand Down
12 changes: 6 additions & 6 deletions src/HeartRateVariability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ include("Geometric.jl")
geometric(n,e="mean")

Arguments:
- n: the array that contains the NN-inetrvals
- e: the maximum distance between two intervals, default="mean" (the mean value of the succsessive differences), has to be "mean" or a number
- n: the array that contains the NN-intervals
- e: the maximum distance between two intervals, default="mean" (the mean value of the successive differences), has to be "mean" or a number

Results:
- poincare: the Poincaré plot
Expand All @@ -28,7 +28,7 @@ end # geometric
nonlinear(n,m=2,r=6)

Arguments:
- n: the array that contains the NN-inetrvals
- n: the array that contains the NN-intervals
- m: the embedding dimension, default=2
- r: the tolerance, default=6

Expand All @@ -51,7 +51,7 @@ end # nonlinear
frequency(n)

Arguments:
- n: the array that contains the NN-inetrvals
- n: the array that contains the NN-intervals

Results:
- vlf: the very low-frequency power
Expand All @@ -73,7 +73,7 @@ end # frequency
time_domain(n)

Arguments:
- n: the array that contains the NN-inetrvals
- n: the array that contains the NN-intervals

Results:
- mean: the mean value
Expand Down Expand Up @@ -118,7 +118,7 @@ Arguments:
- annotator: is the annotator of the record

!!! note
In order to use the infile function for wfdb files, the WFDB Software Package from
In order to use the `infile` function for wfdb files, the WFDB Software Package from
Pysionet is required. See [Installation](installation) for more information.
"""
function infile(record::String,annotator::String)
Expand Down
16 changes: 8 additions & 8 deletions src/Nonlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Statistics

#=
This function calculates the approximate entropy
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:param m: the embedding dimension, default=2
:param r: the tolerance, default=6
:return: the approximate entropy
Expand All @@ -18,7 +18,7 @@ end # apen

#=
This function calculates the sample entropy
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:param m: the embedding dimension, default=2
:param r: the tolerance, default=6
:return: the sample entropy
Expand All @@ -31,7 +31,7 @@ end # sampen

#=
This function creates a template of a given array over an embedding dimension
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:param m: the embedding dimension, default=2
:return template: the created template
=#
Expand All @@ -45,7 +45,7 @@ end # get_template

#=
This function calculates the distances for the approximate entropy
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:param m: the embedding dimension, default=2
:param r: the tolerance, default=6
:return: the distance for the approximate entropy
Expand All @@ -66,7 +66,7 @@ end # get_apen_dist

#=
This function calculates the distances for the sample entropy
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:param m: the embedding dimension, default=2
:param r: the tolerance, default=6
:param l: a value to limit the for-loops
Expand All @@ -91,7 +91,7 @@ end # get_sampen_dist

#=
This function calculates the renyi entropy of a given order
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:param a: the order of the renyi entropy
:return: the calculated renyi entropy
=#
Expand All @@ -102,7 +102,7 @@ end # renyi
#=
This function calculates the hurst coefficient
It was inspired by the python hurst package by Dmitry A. Mottl (https://github.com/Mottl/hurst)
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:return H: the hurst coefficient
=#
function hurst(n)
Expand Down Expand Up @@ -145,7 +145,7 @@ end # hurst
#=
This function calculates the rescaled range of a time series
It was inspired by the python hurst package by Dmitry A. Mottl (https://github.com/Mottl/hurst)
:param n: the array that contains the NN-inetrvals
:param n: the array that contains the NN-intervals
:return: the rescaled range
=#
function get_rs(n)
Expand Down
8 changes: 4 additions & 4 deletions src/TimeDomain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Statistics

#=
This function calculates the differences between the NN intervals
:param n: is the array that contains the NN-inetrvals
:param n: is the array that contains the NN-intervals
:return diff: is an array containing the differences
=#
function nn_diff(n)
Expand All @@ -17,7 +17,7 @@ end #nn_diff

#=
This function calculates the standard deviation of the NN intervals
:param n: is the array that contains the NN-inetrvals
:param n: is the array that contains the NN-intervals
:return: the standard deviation
=#
function sdnn(n)
Expand Down Expand Up @@ -72,7 +72,7 @@ end # nn

#=
This function calculates the mean of the NN intervals
:param n: is the array that contains the NN-inetrvals
:param n: is the array that contains the NN-intervals
:return: the mean value
=#
function mean_nn(n)
Expand All @@ -81,7 +81,7 @@ end # mean_nn

#=
This function calculates the relative RR
:param n: is the array that contains the NN-inetrvals
:param n: is the array that contains the NN-intervals
:return: the relative RR
=#
function rRR(n)
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ g=HeartRateVariability.geometric(n)
@testset "HeartRateVariability.frequency" begin
@test fd.vlf≈1317.96 atol=0.01*fd.vlf
@test fd.lf≈90.36 atol=0.01*fd.lf
@test fd.hf≈176.05 atol=0.01*fd.hf
@test fd.lfhf_ratio≈0.51 atol=0.01*fd.lfhf_ratio
@test fd.hf≈186.93 atol=0.01*fd.hf
@test fd.lfhf_ratio≈0.48 atol=0.01*fd.lfhf_ratio
@test fd.tp≈1584.35 atol=0.01*fd.tp
end

Expand All @@ -44,7 +44,7 @@ g=HeartRateVariability.geometric(n)
#testing if get_rs from module Nonlinear returns 0 when S or R is 0
@test HeartRateVariability.Nonlinear.get_rs(ones(100))==0

#testing if warning is thwown
#testing if warning is thrown
@test_logs (:warn,"To obtain a valid value for the hurst coefficient, the length of the data series must be greater than or equal to 100.") HeartRateVariability.nonlinear([1.0,2.0,1.0,2.0,1.0,2.0,1.0,2.0,1.0,2.0])
end

Expand Down