knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
If you do not already have an environment ready to run R code, we recommend installing it along with RStudio. For more information on this process, please see here.
Once you have RStudio up and running, we suggest creating a new R project and placing all ECG XML files in a sub-directory. The file structure may look something like this:
The RStudio file panel may look something like this:
You can run the following lines of code to install easyRecg
. Depending on what dependencies you already have in your compute environment, this could take several minutes:
install.packages("devtools") devtools::install_github("rickeycarter/easyRecg")
Once you have your environment configured, you can start using the package to extract your data. We recommend including all the code below in a single R script that can be saved and shared.
Load the easyRecg
package:
devtools::load_all(".")
library(easyRecg)
dir.create('ecg_files') from <- system.file("extdata", path = "muse", package = "easyRecg") to <- "ecg_files" files <- list.files(from, full.names = TRUE) file.copy(files, to, recursive = TRUE)
all_muse <- read_muse_xml_directory("ecg_files") save(all_muse, file = "ecg_lead_data.Rda")
For more info on whitelisting, blacklisting, or mixed filtering, please see the readme.
# Get list of files to read all_files <- list.files("ecg_files", full.names = TRUE) # Decide what meta data to share - this can be changes exclude <- list( patient_demographics = c("patient_last_name", "patient_first_name") ) meta_data <- read_muse_xml_meta(all_files, exclude = exclude) # Inspect data - ensure it only contains appropriate data meta_data # save data save(meta_data, file = "ecg_meta_data.Rda")
file.remove("ecg_meta_data.Rda") file.remove("ecg_lead_data.Rda") unlink("ecg_files", recursive=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.