Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
interactive plot of fNIRS data
devtools::install_github("erzk/fnirsr")
library(dygraphs)
library(fnirsr)
file_path <- system.file("extdata", "Hitachi_ETG4000_24Ch_Total.csv", package = "fnirsr")
ETG_header <- load_ETG4000_header(file_path)
rawData <- load_ETG4000_data(file_path, ETG_header)
# prepare the events
event_lines <- rawData %>% dplyr::filter(Mark > 0) %>% .[[1]]
trigger_codes <- rawData %>% dplyr::filter(Mark > 0) %>% .[["Mark"]]
# the first column needs to provide indices (x-axis)
# the remaining columns hold the data to display (y-axis)
df_dg <- rawData[, 1:25]
dygraph(df_dg,
main = "fNIRS data",
xlab = "Samples",
ylab = "Intensity") %>%
dyEvent(event_lines, trigger_codes, labelLoc = "bottom") %>%
dyHighlight(highlightSeriesOpts = list(strokeWidth = 3)) %>%
dyLegend(width = 650)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment