-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhrv_tutorial.Rmd
91 lines (61 loc) · 2.59 KB
/
hrv_tutorial.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
title: "Analyzing HRV Data in R"
author: "Daniel N. Albohn"
date: "11/08/2017"
output:
html_document:
theme: cosmo
css: style.css
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE, error = FALSE, eval=FALSE)
```
# Background
Please see the [brief presentation](ext/hrv_intro.html)
on heart rate variability, QRS complex, and why HRV is important.
# Preperation
This tutorial will use the [`RHRV`](http://rhrv.r-forge.r-project.org) package for the
majority of analyses and graphing.
In addition, it will supplement these with custom functions (which can be found on the GitHub),
and scripts from [`PhysioScript`](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3767411/).
In general, this tutorial also attempts to follow the principles of tidy data,
and will utilize various functions and ideas from the `tidyverse` group of packages.
If you would like to follow along, first either clone or download the
[repository](https://github.com/d-bohn/tutorials).
Then, load all of the necessary packages into your session.
```{r}
check <- require(pacman)
if(check==FALSE) {install.packages('pacman')} else(rm(check))
pacman::p_load(RHRV, reticulate, here)
```
Next, you can load the `PhysioScript` functions by using `load()`.
```{r}
## Check to see where your root directory is
## Make sure it is inside of the project folder
here()
load(here('R/hrv_tutorial/PhysioScript.RData'))
```
You can then examine what each of these functions do by clicking on them. If you
have the desire to clean your Global Environment you can remove all of the functions
by running the command `rm(list=ls())`, or all of them except specific ones by naming them
explicitly to keep like so:
```{r}
rm(list= ls()[!(ls() %in% c('process.ecg','extract.ibi', 'read.vars', 'read.data'))])
```
Lastly, we will be using some python code to read in the raw AcqKnowledge files. If you are familiar
with python, and have `pip` installed on your system, you can execute the following command to get
the necessary package.
```{bash}
pip install bioread
```
## Tutorial Overview
This brief tutorial will consist of the following topics:
1). [Extracting electrophysiology data from raw files](extract_ecg.html)
2). [Prepare files and compute interbeat interval (IBI)](compute_ibi.html)
3). [Check for outliers and graph](ecg_outliers.html)
4). [Dealing with triggers](hrv_triggers.html)
5). [Obtain statistics](hrv_stats.html)
You can navigate to the appropriate section by clicking the links above or using
the dropdown menu at the top of the page.