diff --git a/.Rbuildignore b/.Rbuildignore index b5e1da3..4e9a5a2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ -^psyr\.Rproj$ +^psyphr\.Rproj$ ^\.Rproj\.user$ ^LICENSE\.md$ +^README\.Rmd$ diff --git a/NAMESPACE b/NAMESPACE index 62802ba..2cc3cd8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ # Generated by roxygen2: do not edit by hand -export(rename_hrv_editing_columns) -export(transform_editing_sheet) -export(transform_hrv_sheet) -export(transform_settings_sheet) +export(bare_name) +export(read_MW_EDA) +export(read_MW_workbook) +export(rename_hrv_stats_columns) +export(tidy_MW_EDA) diff --git a/R/editing.R b/R/editing.R deleted file mode 100644 index 0a6f378..0000000 --- a/R/editing.R +++ /dev/null @@ -1,30 +0,0 @@ - -#' Process "Editing Stats" sheet -#' -#' The transform_editing_sheet function transforms the raw Editing Stats sheet to use the Segment Names as -#' column names, make all values numeric, and add the name of the file as a column, so the data includes -#' the source designation. -#' -#' @param file_name -#' @param sheet -#' -#' @return a dataframe of segment data with a column containing the file name -#' @export -#' -#' @examples -#' transform_editing_sheet(name_of_file, sheet_data) -#' -transform_editing_sheet <- function(file_name, sheet){ - sheet <- sheet %>% - tidyr::gather(-`Segment Number`, - key = "segment", - value = "value") %>% - tidyr::spread(key = `Segment Number`, - value = value) %>% - dplyr::mutate_all(as.numeric) %>% - dplyr::mutate(file_name = file_name) - - sheet - -} - diff --git a/R/example_file_grab.R b/R/example_file_grab.R deleted file mode 100644 index f1748f5..0000000 --- a/R/example_file_grab.R +++ /dev/null @@ -1,17 +0,0 @@ -#Make a list of dataframes from workbook sheets - -path_name <- "tests/testthat/test_data/eda" -extension <- ".xlsx" - -list_of_sheets <- workbook_sheets(path_name, extension) - -#Subset the list of dataframes for a particular sheet name, eg "EDA_Stats" - -sheet_name <- "EDA_Stats" -subset_for_sheets(list_of_sheets = list_of_sheets, sheet_name = sheet_name) - -#Subset for list of dataframes for a particular file name, eg. "01-1-1" - -file_name <- "01-1-1" -subset_for_files(list_of_sheets = list_of_sheets, file_name = file_name) - diff --git a/R/files.R b/R/files.R deleted file mode 100644 index 40107f7..0000000 --- a/R/files.R +++ /dev/null @@ -1,47 +0,0 @@ -library("readxl") - -workbook_sheets <- function(pathname, extension){ - - # Find files in directory - - files_full_path <- list.files(path = path_name, - pattern = extension, - full.names = TRUE) - file_names <- list.files(path = path_name, - pattern = extension, - full.names = FALSE) - file_names <- gsub(pattern = extension, - replacement = "", x = file_names) - - # Make names for dataframes - - df_names <- list() - for(i in 1:length(files_full_path)){ - sheet_names <- excel_sheets(files_full_path[i]) - df_names[[i]] <- paste(file_names[i], - sheet_names, sep = "_") - df_names[[i]] <- gsub(pattern = " ", - replacement = "_", - x = df_names[[i]]) - } - df_names <- unlist(df_names) - - # Read files - - list_of_wkbk_sheets <- list() - list_item <- 1 - for(i in 1:length(files_full_path)){ - sheet_names <- excel_sheets(files_full_path[i]) - - for(j in 1:length(sheet_names)){ - list_of_wkbk_sheets[[list_item]] <- as.data.frame(read_excel(files_full_path[i], - sheet = sheet_names[j])) - list_item <- list_item + 1 - } - } - - names(list_of_wkbk_sheets) <- df_names - - list_of_wkbk_sheets - -} diff --git a/R/grab_files.R b/R/grab_files.R deleted file mode 100644 index 982b34a..0000000 --- a/R/grab_files.R +++ /dev/null @@ -1,10 +0,0 @@ -#See example for how this works - -subset_for_files <- function(list_of_sheets, file_name){ - my_dfs <- grep(pattern = file_name, x = names(list_of_sheets)) - - for(i in my_dfs){ - assign(names(list_of_sheets)[i], list_of_sheets[[i]], envir=globalenv()) - } - -} diff --git a/R/grab_sheets.R b/R/grab_sheets.R deleted file mode 100644 index 8e730b9..0000000 --- a/R/grab_sheets.R +++ /dev/null @@ -1,10 +0,0 @@ -#See example for how this works - -subset_for_sheets <- function(list_of_sheets, sheet_name){ - my_dfs <- grep(pattern = sheet_name, x = names(list_of_sheets)) - - for(i in my_dfs){ - assign(names(list_of_sheets)[i], list_of_sheets[[i]], envir=globalenv()) - } - -} diff --git a/R/rename.R b/R/rename.R index 49d30ad..397cd37 100644 --- a/R/rename.R +++ b/R/rename.R @@ -1,12 +1,13 @@ #' Rename sheet columns after the sheet has been transformed. #' -#' Functions to change the column names to be easier to use by later analysis scripts. +#' Functions to change the column names to be easier to use by later analysis +#' scripts. #' They should only be called after transform_* has already been used. #' -#' TODO: add error handling in case this is run before transform_* has been run, -#' and the column names are not as expected. I.e., detect whether the second -#' column name is a number, and if so, -#' exit out gracefully with a message to run transform_* function first. +#' TODO: Add error handling in case this is run before transform_* has been run, +#' and the column names are not as expected - i.e., detect whether the second +#' column name is a number, and if so, exit out gracefully with a message +#' to run transform_* function first. #' #' @param sheet #' @@ -19,94 +20,79 @@ #' rename_eda_stats_columns(sheet_data) #' rename_hrv_editing_columns(sheet_data) #' -#' -#' - - - rename_hrv_stats_columns <- function(sheet){ - sheet <- sheet %>% - dplyr::rename(segment = segment, - start_time = `Start Time`, - end_time = `End Time`, - seg_length = `Segment Duration`, - mean_hr = `Mean Heart Rate`, - rsa = RSA, - mean_ibi = `Mean IBI`, - r_peaks = `# of R's Found`, - resp_rate = `Respiration Rate`, - resp_amp = `Respiration Amplitude`, - resp_peak_freq = `Respiration Peak Frequency`, - resp_power = `Respiration Power`, - first_r_time = `First ECG R Time`, - last_r_time = `Last ECG R Time`, - r_r_duration = `First R to Last R Duration`, - sdnn = SDNN, - avnn = AVNN, - rmssd = RMSSD, - nn50 = NN50, - pnn50 = pNN50) - - sheet - + sheet %>% + dplyr::rename(segment = `Segment Number`, + start_time = `Start Time`, + end_time = `End Time`, + seg_length = `Segment Duration`, + mean_hr = `Mean Heart Rate`, + rsa = RSA, + mean_ibi = `Mean IBI`, + r_peaks = `# of R's Found`, + resp_rate = `Respiration Rate`, + resp_amp = `Respiration Amplitude`, + resp_peak_freq = `Respiration Peak Frequency`, + resp_power = `Respiration Power`, + first_r_time = `First ECG R Time`, + last_r_time = `Last ECG R Time`, + r_r_duration = `First R to Last R Duration`, + sdnn = SDNN, + avnn = AVNN, + rmssd = RMSSD, + nn50 = NN50, + pnn50 = pNN50) } rename_hrv_editing_columns <- function(sheet) { - sheet <- sheet %>% - dplyr::rename(segment = segment, - ecg_sec_cut = `ECG : Seconds Removed`, - ecg_perc_cut = `ECG : Percentage Removed`, - ecg_sec_est = `ECG : Seconds Estimated`, - ecg_perc_est = `ECG : Percentage Estimated`, - resp_sec_cut = `Resp : Seconds Removed`, - resp_perc_cut = `Resp : Percentage Removed`, - resp_sec_est = `Resp : Seconds Estimated`, - resp_perc_est = `Resp : Percentage Estimated`, - total_r_peaks = `Total Peaks`, - norm_r_peaks = `Normal Peaks`, - norm_r_perc = `% Normal Peaks`, - est_r_peaks = `Estimated Peaks`, - est_r_peaks_perc = `% Estimated Peaks`, - art_r_peaks = `Artifact Peaks`, - art_r_peaks_perc = `% Artifact Peaks`, - dur_est_r_r = `Duration of Estimated R-R Intervals`, - est_r_r_perc = `% of Estimated R-R Intervals`) - - sheet - + sheet %>% + dplyr::rename(segment = `Segment Number`, + ecg_sec_cut = `ECG : Seconds Removed`, + ecg_perc_cut = `ECG : Percentage Removed`, + ecg_sec_est = `ECG : Seconds Estimated`, + ecg_perc_est = `ECG : Percentage Estimated`, + resp_sec_cut = `Resp : Seconds Removed`, + resp_perc_cut = `Resp : Percentage Removed`, + resp_sec_est = `Resp : Seconds Estimated`, + resp_perc_est = `Resp : Percentage Estimated`, + total_r_peaks = `Total Peaks`, + norm_r_peaks = `Normal Peaks`, + norm_r_perc = `% Normal Peaks`, + est_r_peaks = `Estimated Peaks`, + est_r_peaks_perc = `% Estimated Peaks`, + art_r_peaks = `Artifact Peaks`, + art_r_peaks_perc = `% Artifact Peaks`, + dur_est_r_r = `Duration of Estimated R-R Intervals`, + est_r_r_perc = `% of Estimated R-R Intervals`) } rename_eda_stats_columns <- function(sheet){ - sheet <- sheet %>% - dpylr::rename(segment = segment, - start_time = `Start Time`, - end_time = `End Time`, - seg_length = `Segment Duration`, - total_scr = `Total SCRs`, - er_scr = `ER-SCRs`, - ns_scrs = `NS-SCRs`, - tonic_scl = `Tonic SCL`, - mean_sc = `Mean SC`, - tonic_period = `Tonic Period`) - - sheet - + sheet %>% + dplyr::rename(segment = `Segment Number`, + start_time = `Start Time`, + end_time = `End Time`, + seg_length = `Segment Duration`, + total_scr = `Total SCRs`, + er_scr = `ER-SCRs`, + ns_scrs = `NS-SCRs`, + tonic_scl = `Tonic SCL`, + mean_sc = `Mean SC`, + tonic_period = `Tonic Period`) } - rename_eda_editing_columns <- function(sheet){ - sheet <- sheet %>% - dplyr::rename(segment = segment, - eda_sec_cut = `EDA : Seconds Removed`, - eda_perc_cut = `EDA : Percentage Removed`, - eda_sec_est = `EDA : Seconds Estimated`, - eda_perc_est = `EDA : Percentage Estimated`, - resp_sec_cut = `Resp : Seconds Removed`, - resp_perc_cut = `Resp : Percentage Removed`, - resp_sec_est = `Resp : Seconds Estimated`, - resp_perc_est = `Resp : Percentage Estimated`) + sheet %>% + dplyr::rename(segment = `Segment Number`, + eda_sec_cut = `EDA : Seconds Removed`, + eda_perc_cut = `EDA : Percentage Removed`, + eda_sec_est = `EDA : Seconds Estimated`, + eda_perc_est = `EDA : Percentage Estimated`, + resp_sec_cut = `Resp : Seconds Removed`, + resp_perc_cut = `Resp : Percentage Removed`, + resp_sec_est = `Resp : Seconds Estimated`, + resp_perc_est = `Resp : Percentage Estimated`) } diff --git a/R/settings.R b/R/settings.R deleted file mode 100644 index 4552aba..0000000 --- a/R/settings.R +++ /dev/null @@ -1,23 +0,0 @@ -#' Process "Settings" sheet -#' -#' The transform_settings_sheet function transforms the raw Settings sheet to "flip it on its side" so -#' variables are columns and values are rows -#' -#' IMPORTANT NOTE: This needs to be tested -#' -#' @param file_name -#' @param sheet -#' -#' @return -#' @export -#' -#' @examples -#' -#' -transform_settings_sheet <- function(file_name, sheet){ - colnames(sheet) <- c("Setting", "Value") - sheet <- sheet %>% - tidyr::spread(key = "Setting", - value = "Value") %>% - dplyr::mutate(file_name = file_name) -} diff --git a/R/stats.R b/R/stats.R deleted file mode 100644 index 2f4a121..0000000 --- a/R/stats.R +++ /dev/null @@ -1,29 +0,0 @@ -#' Process "* Stats" sheet -#' -#' The transform_stats_sheet function transforms the raw HRV or EDA Stats sheet -#' (sheet #1) to use the Segment Names as column names, make all values numeric, -#' and add the name of the file as a column, so the data includes the -#' source designation. -#' -#' @param file_name -#' @param sheet -#' -#' @return a dataframe of segment data with a column containing file name -#' @export -#' -#' @examples -#' transform_stats_sheet(name_of_file, sheet_data) -#' -transform_stats_sheet <- function(file_name, sheet){ - sheet <- sheet %>% - tidyr::gather(-`Segment Number`, - key = "segment", - value = "value") %>% - tidyr::spread(key = `Segment Number`, - value = value) %>% - dplyr::mutate_all(as.numeric) %>% - dplyr::mutate(file_name = file_name) - - sheet - -} diff --git a/R/workbook_read_parse.R b/R/workbook_read_parse.R new file mode 100644 index 0000000..5c6491a --- /dev/null +++ b/R/workbook_read_parse.R @@ -0,0 +1,120 @@ +#' Read a MindWare EDA Workbook +#' +#' @param path +#' +#' @return +#' @export +#' +#' @examples +read_MW_EDA <- function(path) { + read_MW_workbook(path, device_vendor = "MindWare") %>% + tidy_MW_EDA() +} + + +#' Read a MindWare Workbook in Excel format +#' +#' @param path +#' @param device_vendor +#' +#' @return +#' @export +#' +#' +#' @examples +read_MW_workbook <- function(path, device_vendor = NULL){ + # Check if file type is Excel + `if`(is.na(readxl::excel_format(path)), stop("The input is not an Excel file")) + + sheet_names <- readxl::excel_sheets(path) + + # Read each sheet from workbook + suppressMessages({ + workbook <- purrr::map(sheet_names, + ~ readxl::read_excel(path = path, + sheet = ., + na = c("", "N/A"), + col_names = FALSE, + col_types = "text") + ) %>% magrittr::set_names(sheet_names) + + }) + + structure( + workbook, + class = c("psyphr_wb", class(workbook)), + device_vendor = device_vendor, + origin_path = path, + origin_mtime = file.mtime(path) + ) +} + + + +#' Parsing and tidying a Mindware EDA workbook +#' +#' @param workbook +#' +#' @return +#' @export +#' +#' @examples +tidy_MW_EDA <- function(workbook){ + # EDA Stats + workbook[[1]] <- workbook[[1]] %>% + transpose_convert_colnames() + + # SCR Stats + workbook[[2]] <- workbook[[2]] %>% + first_row_to_colnames() + + # Editing Stats + workbook[[3]] <- workbook[[3]] %>% + transpose_convert_colnames() + + # Settings + workbook[[4]] <- workbook[[4]] %>% + df_to_vector() + + return(workbook) +} + + +#' Turn a data frame into vector +#' +#' Use a data frame's first column to a vectors's names, the second column to its values. +#' +#' @param .data +#' +#' @return +#' +df_to_vector <- function(.data){ + res <- .data[[2]] + names(res) <- .data[[1]] + res +} + +transpose_convert_colnames <- function(.data) { + .data %>% + t() %>% + first_row_to_colnames() %>% + tibble::as_tibble() +} + +first_row_to_colnames <- function(.data){ + colnames(.data) <- .data[1,] + .data[-1,] +} + + +#' Bare Name of a File, w.o. Path or Extension +#' +#' @param path +#' +#' @return string +#' @export +#' +#' @examples +bare_name <- function(path){ + gsub("(\\.+)(?!.*\\1).*$", "", basename(path), perl = TRUE) +} diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..b2c2626 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,52 @@ +--- +output: github_document +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "figures/README-", + out.width = "100%" +) +``` +# psyphr + + +[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) + + +The `psyphr` R package tranforms [psychophysiological](https://en.wikipedia.org/wiki/Psychophysiology) data from +proprietary data collection and processing systems into a [tidy](http://vita.had.co.nz/papers/tidy-data.pdf) form for downstream analysis +and visualization. + +The package is currently under active development. Currently, only [Electrodermal Activity](https://support.mindwaretech.com/manuals/software/eda/3-2/) and [Heart Rate Variability](https://support.mindwaretech.com/manuals/software/hrv/3-2/) output data from [MindWare Technologies](https://www.mindwaretech.com/) are supported. + + +## TODO + +The development team considers the following for the package's future: + +- Submit `psyphr` to [rOpenSci](https://ropensci.org/) for peer review and publication +- Customizable data QA utilities with meaningful defaults +- Common, publication-grade visualization schemes +- Study compilation utility +- Compatibility on data feeds from other popular data collection and processing systems (e.g., [BIOPAC](https://www.biopac.com/)) + + +## Installation + +Install the released version of `psyphr` from [CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("psyphr") +``` + +Install the development version from [GitHub](https://github.com/) with: + +``` r +# install.packages("devtools") +devtools::install_github("wendtke/psyphr") +``` diff --git a/README.md b/README.md new file mode 100644 index 0000000..bbc9edf --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ + + + +# psyphr + + + +[![Lifecycle: +experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) + + +The `psyphr` R package turns +[psychophysiological](https://en.wikipedia.org/wiki/Psychophysiology) +data from proprietary data collection and processing systems into a +[tidy](http://vita.had.co.nz/papers/tidy-data.pdf) form for downstream +analysis and visualization. + +The package is currently under active development. Currently, only +[Electrodermal +Activity](https://support.mindwaretech.com/manuals/software/eda/3-2/) +and [Heart Rate +Variability](https://support.mindwaretech.com/manuals/software/hrv/3-2/) +output data from [MindWare Technologies](https://www.mindwaretech.com/) +are supported. + +## TODO + +The development team considers the following for the package’s future: + + - Customizable data QA utilities, with meaningful defaults + - Common visualization schemes + - Study compilation utility + - Compatibility on data feeds from other popular data collection and + processing systems (e.g., [BIOPAC](https://www.biopac.com/)) + +## Installation + +You can install the released version of psyphr from +[CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("psyphr") +``` + +And the development version from [GitHub](https://github.com/) with: + +``` r +# install.packages("devtools") +devtools::install_github("wendtke/psyphr") +``` diff --git a/man/bare_name.Rd b/man/bare_name.Rd new file mode 100644 index 0000000..b4dbc3f --- /dev/null +++ b/man/bare_name.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/workbook_read_parse.R +\name{bare_name} +\alias{bare_name} +\title{Bare Name of a File, w.o. Path or Extension} +\usage{ +bare_name(path) +} +\arguments{ +\item{path}{} +} +\value{ +string +} +\description{ +Bare Name of a File, w.o. Path or Extension +} diff --git a/man/df_to_vector.Rd b/man/df_to_vector.Rd new file mode 100644 index 0000000..c72e020 --- /dev/null +++ b/man/df_to_vector.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/workbook_read_parse.R +\name{df_to_vector} +\alias{df_to_vector} +\title{Turn a data frame into vector} +\usage{ +df_to_vector(.data) +} +\arguments{ +\item{.data}{} +} +\description{ +Use a data frame's first column to a vectors's names, the second column to its values. +} diff --git a/man/read_MW_EDA.Rd b/man/read_MW_EDA.Rd new file mode 100644 index 0000000..fd88fab --- /dev/null +++ b/man/read_MW_EDA.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/workbook_read_parse.R +\name{read_MW_EDA} +\alias{read_MW_EDA} +\title{Read a MindWare EDA Workbook} +\usage{ +read_MW_EDA(path) +} +\arguments{ +\item{path}{} +} +\description{ +Read a MindWare EDA Workbook +} diff --git a/man/read_MW_workbook.Rd b/man/read_MW_workbook.Rd new file mode 100644 index 0000000..b8f62d4 --- /dev/null +++ b/man/read_MW_workbook.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/workbook_read_parse.R +\name{read_MW_workbook} +\alias{read_MW_workbook} +\title{Read a MindWare Workbook in Excel format} +\usage{ +read_MW_workbook(path, device_vendor = NULL) +} +\arguments{ +\item{device_vendor}{} +} +\description{ +Read a MindWare Workbook in Excel format +} diff --git a/man/rename_hrv_editing_columns.Rd b/man/rename_hrv_editing_columns.Rd deleted file mode 100644 index b61e66f..0000000 --- a/man/rename_hrv_editing_columns.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rename.R -\name{rename_hrv_editing_columns} -\alias{rename_hrv_editing_columns} -\title{Rename sheet columns after the sheet has been transformed.} -\usage{ -rename_hrv_editing_columns(sheet) -} -\arguments{ -\item{sheet}{} -} -\value{ -a dataframe with renamed columns -} -\description{ -Functions to change the column names to be easier to use by later analysis scripts. -They should only be called after transform_editing_sheet has already been used. -} -\details{ -TODO: add error handling in case this is run before transform_editing_sheet has been run, and the -column names are not as expected. I.e., detect whether the second calumn name is a number, and if so, -exit out gracefully with a message to run transform_*_sheet function first. -} -\examples{ -rename_hrv_editing_columns(sheet_data) - -} diff --git a/man/rename_hrv_stats_columns.Rd b/man/rename_hrv_stats_columns.Rd new file mode 100644 index 0000000..fb6ff7e --- /dev/null +++ b/man/rename_hrv_stats_columns.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rename.R +\name{rename_hrv_stats_columns} +\alias{rename_hrv_stats_columns} +\title{Rename sheet columns after the sheet has been transformed.} +\usage{ +rename_hrv_stats_columns(sheet) +} +\arguments{ +\item{sheet}{} +} +\value{ +a dataframe with renamed columns +} +\description{ +Functions to change the column names to be easier to use by later analysis scripts. +They should only be called after transform_* has already been used. +} +\details{ +TODO: add error handling in case this is run before transform_* has been run, +and the column names are not as expected. I.e., detect whether the second +column name is a number, and if so, +exit out gracefully with a message to run transform_* function first. +} +\examples{ +rename_hrv_stats_columns(sheet_data) +rename_hrv_editing_columns(sheet_data) +rename_eda_stats_columns(sheet_data) +rename_hrv_editing_columns(sheet_data) + +} diff --git a/man/tidy_MW_EDA.Rd b/man/tidy_MW_EDA.Rd new file mode 100644 index 0000000..69f4e7a --- /dev/null +++ b/man/tidy_MW_EDA.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/workbook_read_parse.R +\name{tidy_MW_EDA} +\alias{tidy_MW_EDA} +\title{Parsing and tidying a Mindware EDA workbook} +\usage{ +tidy_MW_EDA(workbook) +} +\arguments{ +\item{workbook}{} +} +\description{ +Parsing and tidying a Mindware EDA workbook +} diff --git a/man/transform_editing_sheet.Rd b/man/transform_editing_sheet.Rd deleted file mode 100644 index 27e98bd..0000000 --- a/man/transform_editing_sheet.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/editing.R -\name{transform_editing_sheet} -\alias{transform_editing_sheet} -\title{Process "Editing Stats" sheet} -\usage{ -transform_editing_sheet(file_name, sheet) -} -\arguments{ -\item{sheet}{} -} -\value{ -a dataframe of segment data with a column containing the file name -} -\description{ -The transform_editing_sheet function transforms the raw Editing Stats sheet to use the Segment Names as -column names, make all values numeric, and add the name of the file as a column, so the data includes -the source designation. -} -\examples{ -transform_editing_sheet(name_of_file, sheet_data) - -} diff --git a/man/transform_hrv_sheet.Rd b/man/transform_hrv_sheet.Rd deleted file mode 100644 index fe14fa5..0000000 --- a/man/transform_hrv_sheet.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/transform_hrv_stats.R -\name{transform_hrv_sheet} -\alias{transform_hrv_sheet} -\title{Process "HRV Stats" sheet} -\usage{ -transform_hrv_sheet(file_name, sheet, rename_columns = TRUE) -} -\arguments{ -\item{rename_columns}{} -} -\description{ -The transform_hrv_sheet function ... -} -\examples{ - -} diff --git a/man/transform_settings_sheet.Rd b/man/transform_settings_sheet.Rd deleted file mode 100644 index 0ce9664..0000000 --- a/man/transform_settings_sheet.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/settings.R -\name{transform_settings_sheet} -\alias{transform_settings_sheet} -\title{Process "Settings" sheet} -\usage{ -transform_settings_sheet(file_name, sheet) -} -\arguments{ -\item{sheet}{} -} -\description{ -The transform_settings_sheet function transforms the raw Settings sheet to "flip it on its side" so -variables are columns and values are rows -} -\details{ -IMPORTANT NOTE: This needs to be tested -} diff --git a/tests/testthat/test-editing.R b/tests/testthat/test-editing.R deleted file mode 100644 index b090756..0000000 --- a/tests/testthat/test-editing.R +++ /dev/null @@ -1,44 +0,0 @@ -context("Test the Editing Stats sheet processing") - -test_that("editing works for Editing Stats from HRV workbook", { - workbook_file_path <- "test_data/hrv/01_1_1.xlsx" - sheet <- readxl::read_xlsx(workbook_file_path, sheet = 8) - t_sheet <- transform_editing_sheet("01_1_1", sheet) - exp_names <- c("segment", - "% Artifact Peaks", - "% Estimated Peaks", - "% Normal Peaks", - "% of Estimated R-R Intervals", - "Artifact Peaks", - "Duration of Estimated R-R Intervals", - "ECG : Percentage Estimated", - "ECG : Percentage Removed", - "ECG : Seconds Estimated", - "ECG : Seconds Removed", - "Estimated Peaks", - "Normal Peaks", - "Resp : Percentage Estimated", - "Resp : Percentage Removed", - "Resp : Seconds Estimated", - "Resp : Seconds Removed", - "Total Peaks", - "file_name") - expect_equal(names(t_sheet), exp_names) -}) - -test_that("editing works for Editing Stats from EDA workbook", { - workbook_file_path <- "test_data/eda/01-1-1.xlsx" - sheet <- readxl::read_xlsx(workbook_file_path, sheet = 3) - t_sheet <- transform_editing_sheet("01-1-1", sheet) - exp_names <- c("segment", - "EDA : Percentage Estimated", - "EDA : Percentage Removed", - "EDA : Seconds Estimated", - "EDA : Seconds Removed", - "Resp : Percentage Estimated", - "Resp : Percentage Removed", - "Resp : Seconds Estimated", - "Resp : Seconds Removed", - "file_name") - expect_equal(names(t_sheet), exp_names) -}) diff --git a/tests/testthat/test-settings.R b/tests/testthat/test-settings.R deleted file mode 100644 index bb00e28..0000000 --- a/tests/testthat/test-settings.R +++ /dev/null @@ -1,71 +0,0 @@ -context("Test the Settings sheet processing") - -test_that("editing works for Settings from HRV workbook", { - workbook_file_path <- "test_data/hrv/01_1_1.xlsx" - sheet <- readxl::read_xlsx(workbook_file_path, sheet = 9, col_names = FALSE) - t_sheet <- transform_settings_sheet("01_1_1", sheet) - exp_names <- c("50/60 hz Notch Filter", - "Baseline/Muscle Noise Filter", - "BioLab Filter", - "Calculation Method", - "Date", - "ECG Inverted", - "Edit File Name", - "Edit File Used?", - "End Time", - "File Name", - "HF/RSA Frequency Band", - "IBI Min/Max Check", - "Interval Period", - "LF Frequency Band", - "MAD MED Check", - "Maximum Heart Rate (BPM)", - "Minimum Heart Rate (BPM)", - "Mode", - "Respiration Max", - "Respiration Min", - "Respiration Signal Used", - "Sampling Frequency", - "Segment Time", - "Show Events", - "Start Time", - "Time", - "Use HF/RSA Band for Resp Rate", - "Version", - "VLF Frequency Band", - "Windowing", - "file_name") - expect_equal(names(t_sheet), exp_names) -}) - -test_that("editing works for settings from EDA workbook", { - workbook_file_path <- "test_data/eda/01-1-1.xlsx" - sheet <- readxl::read_xlsx(workbook_file_path, sheet = 4, col_names = FALSE) - t_sheet <- transform_settings_sheet("01-1-1", sheet) - exp_names <- c("BioLab Filter", - "Block Size", - "Calculation Method", - "Date", - "Edit File Name", - "Edit File Used?", - "End Time", - "ER-SCR Latency Max", - "ER-SCR Latency Min", - "File Name", - "Interval Period", - "Mode", - "Override Gain Settings", - "Respiration Signal Used", - "Rolling Filter On/Off", - "Sampling Frequency", - "Segment Time", - "Show Events", - "Start Time", - "Time", - "uS Threshold", - "uS/Volt", - "Use All Events", - "Version", - "file_name") - expect_equal(names(t_sheet), exp_names) -}) diff --git a/tests/testthat/test-stats.R b/tests/testthat/test-stats.R deleted file mode 100644 index 65b12e7..0000000 --- a/tests/testthat/test-stats.R +++ /dev/null @@ -1,55 +0,0 @@ -context("Test the HRV or EDA Stats sheet processing") - -test_that("editing works for Stats from HRV workwork", { - workbook_file_path <- "test_data/hrv/01_1_1.xlsx" - sheet <- readxl::read_xlsx(workbook_file_path, sheet = 1) - t_sheet <- transform_stats_sheet("01_1_1", sheet) - exp_names <- c( "segment", - "# of R's Found", - "AVNN", - "End Event", - "End Time", - "First ECG R Time", - "First R to Last R Duration", - "Last ECG R Time", - "Manual Override", - "Mean Heart Rate", - "Mean IBI", - "NN50", - "pNN50", - "Respiration Amplitude", - "Respiration Peak Frequency", - "Respiration Power", - "Respiration Rate", - "RMSSD", - "RSA", - "SDNN", - "Segment Duration", - "Start Event", - "Start Time", - "Threshold (volts)", - "file_name") - expect_equal(names(t_sheet), exp_names) - -}) - - -test_that("editing works for Stats from EDA workbook", { - workbook_file_path <- "test_data/eda/01-1-1.xlsx" - sheet <- readxl::read_xlsx(workbook_file_path, sheet = 1) - t_sheet <- transform_stats_sheet("01-1-1", sheet) - exp_names <- c("segment", - "End Event", - "End Time", - "ER-SCRs", - "Mean SC", - "NS-SCRs", - "Segment Duration", - "Start Event", - "Start Time", - "Tonic Period", - "Tonic SCL", - "Total SCRs", - "file_name") - expect_equal(names(t_sheet), exp_names) -})