From bf448d294882b9fdfa98971f0440b1cfd4dbb98c Mon Sep 17 00:00:00 2001 From: shawn schwartz Date: Sat, 23 Nov 2024 17:32:33 -0800 Subject: [PATCH 1/4] fix #74 and fix #105: replace example data with blinks and enhance organization of pkgdown docs website --- DESCRIPTION | 2 +- Makefile | 14 +- NEWS.md | 11 + R/bidsify.R | 2 +- R/deblink.R | 14 +- R/detransient.R | 19 +- R/detrend.R | 9 +- R/epoch.R | 83 +- R/glassbox.R | 21 +- R/interpolate.R | 16 +- R/load.R | 4 +- R/lpfilt.R | 10 +- R/plot.R | 8 +- R/sticker.data.R | 2 +- R/zscore.R | 22 +- README.Rmd | 26 +- README.md | 111 +- _pkgdown.yml | 58 +- docs/404.html | 7 +- docs/LICENSE-text.html | 7 +- docs/LICENSE.html | 7 +- docs/articles/index.html | 9 +- docs/articles/preproc-workflow.html | 7 +- docs/authors.html | 13 +- docs/index.html | 110 +- docs/news/index.html | 78 + docs/pkgdown.yml | 4 +- docs/reference/Rplot001.png | Bin 1011 -> 13418 bytes docs/reference/Rplot002.png | Bin 0 -> 18255 bytes docs/reference/Rplot003.png | Bin 0 -> 20749 bytes docs/reference/Rplot004.png | Bin 0 -> 24005 bytes docs/reference/Rplot005.png | Bin 0 -> 23641 bytes docs/reference/Rplot006.png | Bin 0 -> 26291 bytes docs/reference/Rplot007.png | Bin 0 -> 26342 bytes docs/reference/Rplot008.png | Bin 0 -> 26583 bytes docs/reference/Rplot009.png | Bin 0 -> 26593 bytes docs/reference/bidsify.html | 19 +- docs/reference/deblink-1.png | Bin 0 -> 70073 bytes docs/reference/deblink-2.png | Bin 0 -> 76560 bytes docs/reference/deblink-3.png | Bin 0 -> 70073 bytes docs/reference/deblink-4.png | Bin 0 -> 75886 bytes docs/reference/deblink.html | 77 +- docs/reference/detransient-1.png | Bin 0 -> 70073 bytes docs/reference/detransient-2.png | Bin 0 -> 76091 bytes docs/reference/detransient-3.png | Bin 0 -> 77148 bytes docs/reference/detransient.html | 19 +- docs/reference/{epoch-1.png => detrend-1.png} | Bin docs/reference/detrend-2.png | Bin 0 -> 70073 bytes docs/reference/detrend-3.png | Bin 0 -> 76091 bytes docs/reference/detrend-4.png | Bin 0 -> 83274 bytes docs/reference/detrend-5.png | Bin 0 -> 82887 bytes docs/reference/detrend-6.png | Bin 0 -> 88409 bytes docs/reference/detrend-7.png | Bin 0 -> 67042 bytes docs/reference/detrend-8.png | Bin 0 -> 83704 bytes docs/reference/detrend.html | 24 +- docs/reference/epoch.html | 243 +- docs/reference/eyeris-package.html | 9 +- .../figures/README-glassbox-plot-1.png | Bin 293534 -> 314499 bytes .../figures/README-glassbox-plot-2.png | Bin 298269 -> 351882 bytes .../figures/README-glassbox-plot-3.png | Bin 297141 -> 349352 bytes .../figures/README-glassbox-plot-4.png | Bin 260758 -> 350223 bytes .../figures/README-glassbox-plot-5.png | Bin 260706 -> 323718 bytes .../figures/README-glassbox-plot-6.png | Bin 0 -> 286168 bytes .../figures/README-timeseries-plot-1.png | Bin 210444 -> 196360 bytes .../figures/README-timeseries-plot-2.png | Bin 188920 -> 222070 bytes docs/reference/glassbox-1.png | Bin 0 -> 42487 bytes docs/reference/glassbox-2.png | Bin 0 -> 45436 bytes docs/reference/glassbox-3.png | Bin 0 -> 70056 bytes docs/reference/glassbox-4.png | Bin 0 -> 70073 bytes docs/reference/glassbox-5.png | Bin 0 -> 76560 bytes docs/reference/glassbox-6.png | Bin 0 -> 83489 bytes docs/reference/glassbox-7.png | Bin 0 -> 83324 bytes docs/reference/glassbox-8.png | Bin 0 -> 89096 bytes docs/reference/glassbox-9.png | Bin 0 -> 79872 bytes docs/reference/glassbox.html | 51 +- docs/reference/index.html | 104 +- docs/reference/interpolate-1.png | Bin 0 -> 70073 bytes docs/reference/interpolate-2.png | Bin 0 -> 76091 bytes docs/reference/interpolate-3.png | Bin 0 -> 76600 bytes docs/reference/interpolate-4.png | Bin 0 -> 76760 bytes docs/reference/interpolate.html | 20 +- docs/reference/load_asc.html | 65 +- docs/reference/lpfilt-1.png | Bin 0 -> 42487 bytes docs/reference/lpfilt-2.png | Bin 0 -> 70073 bytes docs/reference/lpfilt-3.png | Bin 0 -> 76091 bytes docs/reference/lpfilt-4.png | Bin 0 -> 81058 bytes docs/reference/lpfilt-5.png | Bin 0 -> 77461 bytes docs/reference/lpfilt-6.png | Bin 0 -> 85509 bytes docs/reference/lpfilt.html | 23 +- docs/reference/plot.eyeris.html | 15 +- docs/reference/sticker.html | 7 +- docs/reference/zscore-1.png | Bin 0 -> 42487 bytes docs/reference/zscore-2.png | Bin 0 -> 70073 bytes docs/reference/zscore-3.png | Bin 0 -> 76091 bytes docs/reference/zscore-4.png | Bin 0 -> 83274 bytes docs/reference/zscore-5.png | Bin 0 -> 82887 bytes docs/reference/zscore-6.png | Bin 0 -> 88409 bytes docs/reference/zscore-7.png | Bin 0 -> 78984 bytes docs/reference/zscore.html | 53 +- docs/search.json | 2 +- docs/sitemap.xml | 1 + inst/extdata/assocret.asc | 22321 ---------------- inst/extdata/memory.asc | 20956 +++++++++++++++ man/bidsify.Rd | 2 +- man/deblink.Rd | 14 +- man/detransient.Rd | 9 +- man/detrend.Rd | 9 +- man/epoch.Rd | 83 +- man/eyeris-package.Rd | 2 +- man/figures/README-glassbox-plot-1.png | Bin 293534 -> 314499 bytes man/figures/README-glassbox-plot-2.png | Bin 298269 -> 351882 bytes man/figures/README-glassbox-plot-3.png | Bin 296339 -> 349352 bytes man/figures/README-glassbox-plot-4.png | Bin 298349 -> 350223 bytes man/figures/README-glassbox-plot-5.png | Bin 279747 -> 323718 bytes man/figures/README-glassbox-plot-6.png | Bin 261689 -> 286168 bytes man/figures/README-timeseries-plot-1.png | Bin 215368 -> 196360 bytes man/figures/README-timeseries-plot-2.png | Bin 217002 -> 222070 bytes man/glassbox.Rd | 21 +- man/interpolate.Rd | 9 +- man/load_asc.Rd | 4 +- man/lpfilt.Rd | 10 +- man/plot.eyeris.Rd | 8 +- man/sticker.Rd | 5 +- man/zscore.Rd | 21 +- 124 files changed, 21897 insertions(+), 22983 deletions(-) create mode 100644 NEWS.md create mode 100644 docs/news/index.html create mode 100644 docs/reference/Rplot002.png create mode 100644 docs/reference/Rplot003.png create mode 100644 docs/reference/Rplot004.png create mode 100644 docs/reference/Rplot005.png create mode 100644 docs/reference/Rplot006.png create mode 100644 docs/reference/Rplot007.png create mode 100644 docs/reference/Rplot008.png create mode 100644 docs/reference/Rplot009.png create mode 100644 docs/reference/deblink-1.png create mode 100644 docs/reference/deblink-2.png create mode 100644 docs/reference/deblink-3.png create mode 100644 docs/reference/deblink-4.png create mode 100644 docs/reference/detransient-1.png create mode 100644 docs/reference/detransient-2.png create mode 100644 docs/reference/detransient-3.png rename docs/reference/{epoch-1.png => detrend-1.png} (100%) create mode 100644 docs/reference/detrend-2.png create mode 100644 docs/reference/detrend-3.png create mode 100644 docs/reference/detrend-4.png create mode 100644 docs/reference/detrend-5.png create mode 100644 docs/reference/detrend-6.png create mode 100644 docs/reference/detrend-7.png create mode 100644 docs/reference/detrend-8.png create mode 100644 docs/reference/figures/README-glassbox-plot-6.png create mode 100644 docs/reference/glassbox-1.png create mode 100644 docs/reference/glassbox-2.png create mode 100644 docs/reference/glassbox-3.png create mode 100644 docs/reference/glassbox-4.png create mode 100644 docs/reference/glassbox-5.png create mode 100644 docs/reference/glassbox-6.png create mode 100644 docs/reference/glassbox-7.png create mode 100644 docs/reference/glassbox-8.png create mode 100644 docs/reference/glassbox-9.png create mode 100644 docs/reference/interpolate-1.png create mode 100644 docs/reference/interpolate-2.png create mode 100644 docs/reference/interpolate-3.png create mode 100644 docs/reference/interpolate-4.png create mode 100644 docs/reference/lpfilt-1.png create mode 100644 docs/reference/lpfilt-2.png create mode 100644 docs/reference/lpfilt-3.png create mode 100644 docs/reference/lpfilt-4.png create mode 100644 docs/reference/lpfilt-5.png create mode 100644 docs/reference/lpfilt-6.png create mode 100644 docs/reference/zscore-1.png create mode 100644 docs/reference/zscore-2.png create mode 100644 docs/reference/zscore-3.png create mode 100644 docs/reference/zscore-4.png create mode 100644 docs/reference/zscore-5.png create mode 100644 docs/reference/zscore-6.png create mode 100644 docs/reference/zscore-7.png delete mode 100644 inst/extdata/assocret.asc create mode 100644 inst/extdata/memory.asc diff --git a/DESCRIPTION b/DESCRIPTION index ce664a2..0486223 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,7 +4,7 @@ Title: eyeris Version: 0.0.0.9000 Authors@R: person( - given = c("Shawn", "T."), + given = "Shawn", family = "Schwartz", role = c("aut", "cre"), email = "stschwartz@stanford.edu", diff --git a/Makefile b/Makefile index 3e963e9..4a09a32 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # default target -all: uninstall getdeps build install roxygenize readme clean +all: uninstall getdeps build install roxygenize readme ghpages clean # debugging target debug: uninstall build install clean @@ -49,6 +49,18 @@ readme: Rscript -e "devtools::build_readme()" @echo "[ OK ] - README update completed!\n" +# pkgdown website preview +website: + @echo "[ INFO ] - building eyeris pkgdown docs website preview..." + Rscript -e "pkgdown::build_site()" + @echo "[ OK ] - pkgdown website preview build completed!\n" + +# pkgdown github pages website (jekyll) +ghpages: + @echo "[ INFO ] - building eyeris pkgdown docs website for github pages..." + Rscript -e "pkgdown::build_site_github_pages(clean = TRUE, install = FALSE, new_process = FALSE)" + @echo "[ OK ] - pkgdown website build for github pages completed!\n" + # clean build directory clean: @echo "[ INFO ] - cleaning eyeris package build directory..." diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..ae49a9e --- /dev/null +++ b/NEWS.md @@ -0,0 +1,11 @@ +# eyeris 0.0.0.9000 + +--- +`November 23rd, 2024` + +## Major Changes +- change one +- change two + +## Bug Fixes +- fix one diff --git a/R/bidsify.R b/R/bidsify.R index e59afab..3e1dc99 100644 --- a/R/bidsify.R +++ b/R/bidsify.R @@ -36,7 +36,7 @@ #' # Bleed around blink periods just long enough to remove majority of #' # deflections due to eyelid movements #' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> #' eyeris::deblink(extend = 50) |> #' eyeris::detransient() |> diff --git a/R/deblink.R b/R/deblink.R index a8cdd5a..75f3c61 100644 --- a/R/deblink.R +++ b/R/deblink.R @@ -13,18 +13,18 @@ #' indicating different numbers of milliseconds pad forward/backward around each #' missing sample, in the format `c(backward, forward)`. #' -#' @return An `eyeris` object with a new column: `pupil_deblink`. +#' @return An `eyeris` object with a new column: `pupil_raw_{...}_deblink`. #' #' @examples -#' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> -#' eyeris::deblink(extend = 40) # 40 ms in both directions -#' } +#' eyeris::deblink(extend = 40) |> # 40 ms in both directions +#' plot(seed = 0) #' -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> -#' eyeris::deblink(extend = c(40, 50)) # 40 ms backward, 50 ms forward +#' eyeris::deblink(extend = c(40, 50)) |> # 40 ms backward, 50 ms forward +#' plot(seed = 0) #' #' @export deblink <- function(eyeris, extend = 40) { diff --git a/R/detransient.R b/R/detransient.R index ed8b2c5..ffeb6f0 100644 --- a/R/detransient.R +++ b/R/detransient.R @@ -11,15 +11,14 @@ #' threshold. #' #' @return An `eyeris` object with a new column in `timeseries`: -#' `pupil_detransient`. +#' `pupil_raw_{...}_detransient`. #' #' @examples -#' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> #' eyeris::deblink(extend = 50) |> -#' eyeris::detransient() -#' } +#' eyeris::detransient() |> +#' plot(seed = 0) #' #' @export detransient <- function(eyeris, n = 16) { @@ -42,10 +41,14 @@ detransient_pupil <- function(x, prev_op, n) { speed <- function(x, y) { delta <- diff(x) / diff(y) - pupil <- abs(cbind(c(NA, delta), c(delta, NA))) - pupil <- apply(pupil, 1, max, na.rm = TRUE) - pupil <- ifelse(pupil == -Inf, NA, pupil) + pupil <- apply(pupil, 1, function(row) { + if (all(is.na(row))) { + return(NA) # return NA for all-NA rows + } else { + return(max(row, na.rm = TRUE)) # only compute max for valid rows + } + }) return(pupil) } diff --git a/R/detrend.R b/R/detrend.R index cbda42e..02ea51b 100644 --- a/R/detrend.R +++ b/R/detrend.R @@ -6,18 +6,17 @@ #' @param eyeris An object of class `eyeris` dervived from [eyeris::load()]. #' #' @return An `eyeris` object with two new columns in `timeseries`: -#' `detrend_fitted_betas`, and `pupil_detrend`. +#' `detrend_fitted_betas`, and `pupil_raw_{...}_detrend`. #' #' @examples -#' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> #' eyeris::deblink(extend = 50) |> #' eyeris::detransient() |> #' eyeris::interpolate() |> #' eyeris::lpfilt(plot_freqz = TRUE) |> -#' eyeris::detrend() -#' } +#' eyeris::detrend() |> +#' plot(seed = 0) #' #' @export detrend <- function(eyeris) { diff --git a/R/epoch.R b/R/epoch.R index 9b31284..336b276 100644 --- a/R/epoch.R +++ b/R/epoch.R @@ -80,7 +80,8 @@ #' (`epoch_`). #' #' @examples -#' eye_preproc <- system.file("extdata", "assocret.asc", package = "eyeris") |> +#' \dontrun{ +#' eye_preproc <- system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> #' eyeris::deblink(extend = 50) |> #' eyeris::detransient() |> @@ -88,11 +89,89 @@ #' eyeris::lpfilt(plot_freqz = TRUE) |> #' eyeris::zscore() #' +#' # example 1: select 1 second before/after matched event message "PROBE*" #' eye_preproc |> #' eyeris::epoch(events = "PROBE*", limits = c(-1, 1)) #' +#' # example 2: select all samples between each trial #' eye_preproc |> -#' eyeris::epoch(events = "TRIALID {trial}") # all samples between each trial +#' eyeris::epoch(events = "TRIALID {trial}") +#' +#' # example 3: grab the 1 second following probe onset +#' eye_preproc |> +#' eyeris::epoch( +#' events = "PROBE_START_{trial}", +#' limits = c(0, 1) +#' ) +#' +#' # example 4: 2 seconds prior to and 1 second after probe onset +#' eye_preproc |> +#' eyeris::epoch( +#' events = "PROBE_START_{trial}", +#' limits = c(-2, 1), +#' label = "prePostProbe" # custom epoch label name +#' ) +#' +#' # example 5: manual start/end event pairs +#' # note: here, the `msg` column of each data frame is optional +#' eye_prepoc |> +#' eyeris::epoch( +#' events = list( +#' data.frame(time = c(11243355), msg = c("TRIALID 0")), # start events +#' data.frame(time = c(11245956), msg = c("RESPONSE_0")) # end events +#' ) +#' ) +#' +#' # example 6: manual start/end event pairs +#' # note: set `msg` to NA if you only want to pass in start/end timestamps +#' eye_preproc |> +#' eyeris::epoch( +#' events = list( +#' data.frame(time = c(11243355), msg = NA), # start events +#' data.frame(time = c(11245956), msg = NA) # end events +#' ) +#' ) +#' +#' ## examples with baseline arguments enabled +#' +#' # example 7: use mean of 1-s preceding "PROBE_START" (i.e. "DELAY_STOP") +#' # to perform subtractive baselining of the 1-s PROBE epochs. +#' eye_preproc |> +#' eyeris::epoch( +#' events = "PROBE_START_{trial}", +#' limits = c(0, 1), # grab 0 seconds prior to and 1 second post PROBE event +#' label = "prePostProbe", # custom epoch label name +#' calc_baseline = TRUE, +#' apply_baseline = TRUE, +#' baseline_type = "sub", # "sub"tractive baseline calculation is default +#' baseline_events = "DELAY_STOP_*", +#' baseline_period = c(-1, 0) +#' ) +#' +#' # example 8: use mean of time period between set start/end event messages +#' # (i.e. between "DELAY_START" and "DELAY_STOP"). In this case, the +#' # `baseline_period` argument will be ignored since both a "start" and "end" +#' # message string are provided to the `baseline_events` argument. +#' eye_preproc |> +#' eyeris::epoch( +#' events = "PROBE_START_{trial}", +#' limits = c(0, 1), # grab 0 seconds prior to and 1 second post PROBE event +#' label = "prePostProbe", # custom epoch label name +#' calc_baseline = TRUE, +#' apply_baseline = TRUE, +#' baseline_type = "sub", # "sub"tractive baseline calculation is default +#' baseline_events = c("DELAY_START_*", +#' "DELAY_STOP_*") +#' ) +#' +#' # example 9: additional (potentially helpful) example +#' start_events <- data.frame(time = c(11243355, 11247588), +#' msg = c("TRIALID 0", "TRIALID 1")) +#' end_events <- data.frame(time = c(11245956, 11250506), +#' msg = c("RESPONSE_0", "RESPONSE_1")) +#' eye_prepoc |> +#' eyeris::epoch(events = list(start_events, end_events)) +#' } #' #' @export epoch <- function(eyeris, events, limits = NULL, label = NULL, diff --git a/R/glassbox.R b/R/glassbox.R index c6cee8a..599a278 100644 --- a/R/glassbox.R +++ b/R/glassbox.R @@ -55,23 +55,32 @@ #' @param ... Additional arguments to override the default, prescribed settings. #' #' @examples -#' \dontrun{ -#' demo_data <- system.file("extdata", "assocret.asc", package = "eyeris") +#' demo_data <- system.file("extdata", "memory.asc", package = "eyeris") #' #' # (1) examples using the default prescribed parameters and pipeline recipe +#' #' ## (a) run an automated pipeline with no real-time inspection of parameters #' output <- eyeris::glassbox(demo_data) +#' plot( +#' output, +#' steps = c(1, 5), +#' preview_window = c(0, nrow(output$timeseries)), +#' seed = 0 +#' ) #' #' ## (b) run a interactive workflow (with confirmation prompts after each step) -#' output <- eyeris::glassbox(demo_data, confirm = TRUE) +#' # output <- eyeris::glassbox(demo_data, confirm = TRUE, seed = 0) +#' #' #' # (2) examples overriding the default parameters -#' output <- eyeris::glassbox(demo_data, -#' confirm = TRUE, +#' output <- eyeris::glassbox( +#' demo_data, +#' confirm = FALSE, # TRUE if you want to visualize each step in real-time #' deblink = list(extend = 40), #' lpfilt = list(plot_freqz = FALSE) #' ) -#' } +#' +#' plot(output, seed = 0) #' #' @export glassbox <- function(file, confirm = FALSE, detrend_data = FALSE, diff --git a/R/interpolate.R b/R/interpolate.R index d94b0cd..0dd5def 100644 --- a/R/interpolate.R +++ b/R/interpolate.R @@ -8,20 +8,18 @@ #' values on either end, respectively, using the "rule = 2" argument in the #' `approx()` function. #' -#' #' @param eyeris An object of class `eyeris` dervived from [eyeris::load()]. #' #' @return An `eyeris` object with a new column in `timeseries`: -#' `pupil_interpolate`. +#' `pupil_raw_{...}_interpolate`. #' #' @examples -#' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> #' eyeris::deblink(extend = 50) |> #' eyeris::detransient() |> -#' eyeris::interpolate() -#' } +#' eyeris::interpolate() |> +#' plot(seed = 0) #' #' @export interpolate <- function(eyeris) { @@ -38,8 +36,10 @@ interpolate_pupil <- function(x, prev_op) { prev_pupil <- x[[prev_op]] } - interp_pupil <- zoo::na.approx(prev_pupil, - na.rm = FALSE, maxgap = Inf, + interp_pupil <- zoo::na.approx( + prev_pupil, + na.rm = FALSE, + maxgap = Inf, rule = 2 ) diff --git a/R/load.R b/R/load.R index fa4a966..f9dfd8d 100644 --- a/R/load.R +++ b/R/load.R @@ -21,10 +21,8 @@ #' @seealso [eyelinker::read.asc()] which this function wraps. #' #' @examples -#' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() -#' } #' #' @export load_asc <- function(file) { diff --git a/R/lpfilt.R b/R/lpfilt.R index c570608..6b84e94 100644 --- a/R/lpfilt.R +++ b/R/lpfilt.R @@ -11,17 +11,17 @@ #' @param rs Required minimal attenuation within stopband in dB. #' @param plot_freqz Boolean flag for displaying filter frequency response. #' -#' @return An `eyeris` object with a new column in `timeseries`: `pupil_lpfilt`. +#' @return An `eyeris` object with a new column in `timeseries`: +#' `pupil_raw_{...}_lpfilt`. #' #' @examples -#' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> #' eyeris::deblink(extend = 50) |> #' eyeris::detransient() |> #' eyeris::interpolate() |> -#' eyeris::lpfilt(plot_freqz = TRUE) -#' } +#' eyeris::lpfilt(plot_freqz = TRUE) |> +#' plot(seed = 0) #' #' @export lpfilt <- function(eyeris, wp = 4, ws = 8, diff --git a/R/plot.R b/R/plot.R index a7747a6..216c83d 100644 --- a/R/plot.R +++ b/R/plot.R @@ -37,11 +37,11 @@ #' #' @examples #' \dontrun{ -#' # using the default 10000 to 20000 ms time subset -#' plot(eyeris_data) +#' # example 1: using the default 10000 to 20000 ms time subset +#' plot(your_eyeris_data_output_here) #' -#' # using a custom time subset (i.e., 1 to 500 ms) -#' plot(eyeris_data, preview_window = c(1, 500)) +#' # example 2: using a custom time subset (i.e., 1 to 500 ms) +#' plot(your_eyeris_data_output_here, preview_window = c(1, 500)) #' } #' #' @rdname plot.eyeris diff --git a/R/sticker.data.R b/R/sticker.data.R index 1d89b13..454dfbc 100644 --- a/R/sticker.data.R +++ b/R/sticker.data.R @@ -2,5 +2,5 @@ #' #' @format A png image file that is rendered into the README and html reports. #' -#' @keywords eyeris, sticker, logo, hex +#' @keywords internal "sticker" diff --git a/R/zscore.R b/R/zscore.R index 7c25894..866e001 100644 --- a/R/zscore.R +++ b/R/zscore.R @@ -1,13 +1,13 @@ -#' Z-Score pupil timeseries data +#' z-score pupil timeseries data #' #' The intended use of this method is to scale the arbitrary units of the pupil #' size timeseries to have a mean of `0` and a standard deviation of `1`. This #' is accomplished by mean centering the data points and then dividing them by #' their standard deviation (i.e., z-scoring the data, similar to -#' [base::scale()]). Z-scoring the pupil data is helpful for trial-level and -#' between-subjects analyses where arbitrary units of pupil size recorded by the -#' tracker do not scale across participants, and therefore make analyses that -#' depend on data from more than one participant difficult to interpret. +#' [base::scale()]). Opting to z-score your pupil data helps with trial-level +#' and between-subjects analyses where arbitrary units of pupil size recorded by +#' the tracker do not scale across participants, and therefore make analyses +#' that depend on data from more than one participant difficult to interpret. #' #' @details #' In general, it is common to z-score pupil data within any given @@ -34,22 +34,20 @@ #' on the entire pupil timeseries (before epoching the data), and then split and #' take the mean of the z-scored timeseries as a function of condition variable. #' -#' #' @param eyeris An object of class `eyeris` dervived from [eyeris::load()]. #' -#' @return A numeric vector giving number of characters (code points) in each -#' element of the character vector. Missing string have missing length. +#' @return An `eyeris` object with a new column in `timeseries`: +#' `pupil_raw_{...}_z`. #' #' @examples -#' \dontrun{ -#' system.file("extdata", "assocret.asc", package = "eyeris") |> +#' system.file("extdata", "memory.asc", package = "eyeris") |> #' eyeris::load_asc() |> #' eyeris::deblink(extend = 50) |> #' eyeris::detransient() |> #' eyeris::interpolate() |> #' eyeris::lpfilt(plot_freqz = TRUE) |> -#' eyeris::zscore() -#' } +#' eyeris::zscore() |> +#' plot(seed = 0) #' #' @export zscore <- function(eyeris) { diff --git a/README.Rmd b/README.Rmd index 42a06ab..a6327ee 100644 --- a/README.Rmd +++ b/README.Rmd @@ -9,17 +9,16 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", - out.width = "100%", - fig.cap = "README FIGURE" + out.width = "100%" ) ``` -# `eyeris`: create and run flexible and reproducible pupillometry preprocessing pipelines in R eyeris website +# `eyeris`: flexible reproducible pupil preprocessing pipelines in R eyeris website MIT License Badge -Package Build Status Badge -Package Linter Status Badge +Package Build Status Badge +Package Linter Status Badge @@ -55,29 +54,32 @@ to flexibly construct and compare different pipelines. We hope you enjoy! -shawn ```{r glassbox-example, fig.dpi=300} -set.seed(1) +set.seed(32) library(eyeris) -demo_data <- system.file("extdata", "assocret.asc", package = "eyeris") +demo_data <- system.file("extdata", "memory.asc", package = "eyeris") -eyeris_preproc <- glassbox(demo_data, detrend_data = F, lpfilt = list(plot_freqz = T)) +eyeris_preproc <- glassbox( + demo_data, + detrend_data = F, + lpfilt = list(plot_freqz = T) +) ``` ### step-wise correction of pupillary signal - ```{r glassbox-plot, echo=TRUE, fig.width=12, fig.height=5, fig.dpi=300} plot(eyeris_preproc) ``` -### final pre-post correction of pupillary signal (raw -> preprocessed) - +### final pre-post correction of pupillary signal (raw ➡ preprocessed) ```{r timeseries-plot, echo=TRUE, fig.width=8, fig.height=5, fig.dpi=300} plot(eyeris_preproc, steps = c(1, 5), preview_window = c(0, nrow(eyeris_preproc$timeseries))) ``` -# Comments, suggestions, questions, issues +--- +# Comments, suggestions, questions, issues? Please use the issues tab (https://github.com/shawntz/eyeris/issues) to make note of any bugs, comments, suggestions, feedback, etc... all are welcomed and appreciated, thanks! diff --git a/README.md b/README.md index 27df0cb..7443e8b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# `eyeris`: create and run flexible and reproducible pupillometry preprocessing pipelines in R eyeris website +# `eyeris`: flexible reproducible pupil preprocessing pipelines in R eyeris website MIT License Badge -Package Build Status Badge -Package Linter Status Badge +Package Build Status Badge +Package Linter Status Badge @@ -45,32 +45,27 @@ compare different pipelines. We hope you enjoy! -shawn ``` r -set.seed(1) +set.seed(32) library(eyeris) -demo_data <- system.file("extdata", "assocret.asc", package = "eyeris") +demo_data <- system.file("extdata", "memory.asc", package = "eyeris") -eyeris_preproc <- glassbox(demo_data, detrend_data = F, lpfilt = list(plot_freqz = T)) +eyeris_preproc <- glassbox( + demo_data, + detrend_data = F, + lpfilt = list(plot_freqz = T) +) #> ✔ [ OK ] - Running eyeris::load_asc() #> ✔ [ OK ] - Running eyeris::deblink() #> ✔ [ OK ] - Running eyeris::detransient() #> ✔ [ OK ] - Running eyeris::interpolate() -#> ! [ INFO ] - No NAs detected in pupil data for interpolation... Skipping! #> ✔ [ OK ] - Running eyeris::lpfilt() #> ✔ [ OK ] - Skipping eyeris::detrend() #> ✔ [ OK ] - Running eyeris::zscore() ``` -
- -README FIGURE -

- -README FIGURE -

- -
+ ### step-wise correction of pupillary signal @@ -78,67 +73,9 @@ README FIGURE plot(eyeris_preproc) ``` -
- -README FIGURE -

- -README FIGURE -

- -
- -
- -README FIGURE -

- -README FIGURE -

- -
- -
- -README FIGURE -

- -README FIGURE -

- -
- -
- -README FIGURE -

+ -README FIGURE -

- -
- -
- -README FIGURE -

- -README FIGURE -

- -
- -
- -README FIGURE -

- -README FIGURE -

- -
- -### final pre-post correction of pupillary signal (raw -\> preprocessed) +### final pre-post correction of pupillary signal (raw ➡ preprocessed) ``` r plot(eyeris_preproc, @@ -146,27 +83,11 @@ plot(eyeris_preproc, preview_window = c(0, nrow(eyeris_preproc$timeseries))) ``` -
- -README FIGURE -

- -README FIGURE -

- -
- -
- -README FIGURE -

- -README FIGURE -

+ -
+------------------------------------------------------------------------ -# Comments, suggestions, questions, issues +# Comments, suggestions, questions, issues? Please use the issues tab () to make note of any bugs, comments, suggestions, feedback, etc… all are diff --git a/_pkgdown.yml b/_pkgdown.yml index 61b53ee..183a5f8 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,24 +1,60 @@ url: http://shawnschwartz.com/eyeris/ + +home: + sidebar: + structure: [authors, citation, links, license, dev] + navbar: structure: - left: [intro, reference, articles, tutorials, news] - right: [search, version, github, lightswitch] + left: [intro, reference, articles, news] + right: [search, github, lightswitch] + template: bootstrap: 5 light-switch: true bslib: bootswatch: pulse pkgdown-nav-height: 100px + footer: structure: left: developed_by right: built_with -components: - version: "v0.0.0.9000" - menu: - - text: "v1.0.0 (current)" - href: "#" - - text: "v0.9.0" - href: "https://shawnschwartz.com/eyeris/v0.9.0" - - text: "v0.8.0" - href: "https://shawnschwartz.com/eyeris/v0.8.0" + +authors: + Shawn Schwartz: + href: "http://shawnschwartz.com" + footer: + roles: [cre, fnd] + text: "Made with ♥ in Palo Alto, CA by" + sidebar: + roles: [aut, ctb] + +reference: + - title: "`eyeris` \"glassbox\" all-in-one wrapper" + contents: + - glassbox + - title: "load eyelink `.asc` file" + contents: + - load_asc + - title: core preprocessing operations + contents: + - deblink + - detransient + - interpolate + - lpfilt + - detrend + - zscore + - title: trial epoching and exporting of preprocessed data + contents: + - epoch + - bidsify + - title: data visualization + contents: + - plot.eyeris + +articles: + - title: template + navbar: template + contents: + - preproc-workflow diff --git a/docs/404.html b/docs/404.html index 824a30e..3ac2ed0 100644 --- a/docs/404.html +++ b/docs/404.html @@ -40,9 +40,12 @@ +