Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

highspeed-analysis-setup.R 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # find the path to the root of this project:
  2. if (!requireNamespace("here")) install.packages("here")
  3. if ( basename(here::here()) == "highspeed" ) {
  4. path_root = here::here("highspeed-analysis")
  5. } else {
  6. path_root = here::here()
  7. }
  8. source(file.path(path_root, "code", "highspeed-analysis-source.R"))
  9. # reverting to ggplot2 version 3.2.1 for lemon compatibility
  10. # cf. https://github.com/stefanedwards/lemon/issues/20
  11. #devtools::install_version("ggplot2", version = "3.3.0", repos = "http://cran.us.r-project.org")
  12. # create an array with all required packages:
  13. packages <- c("R.matlab", "ggplot2", "dplyr", "ggpubr", "psyphy", "ggm",
  14. "corrplot", "reshape2", "afex", "polycor", "tinytex", "extrafont",
  15. "viridis", "rjson", "jsonlite", "tidyr", "combinat", "rlist",
  16. "lemon", "doMC", "plyr", "styler", "gridExtra", "grid",
  17. "data.table", "NameNeedle", "textreuse", "stringdist", "emmeans",
  18. "RColorBrewer", "tidyverse", "gtools", "cowplot",
  19. "assertr", "lavaan", "rmarkdown", "readr", "caTools", "bitops",
  20. "broom", "ggridges", "nloptr", "devtools", "bookdown", "rstatix",
  21. "lomb")
  22. # load packages using the load_packages function:
  23. load_packages(packages_list = packages)
  24. # specify paths:
  25. source(file.path(path_root, "code", "highspeed-cluster-permutation.R"))
  26. source(file.path(path_root, "code", "raincloud-plots", "tutorial_R", "R_rainclouds.R"))
  27. source(file.path(path_root, "code", "raincloud-plots", "tutorial_R", "summarySE.R"))
  28. # path to figures created by the analysis code:
  29. path_figures <- here::here("figures")
  30. # path to the participants.tsv file (according to BIDS):
  31. # datalad get data/bids/participants.tsv
  32. path_participants <- file.path(path_root, "data", "bids", "participants.tsv")
  33. # path to the events.tsv files (according to BIDS):
  34. path_events <- file.path(path_root, "data", "bids", "*", "*", "func", "*events.tsv")
  35. # path to data from the decoding analysis:
  36. path_pred <- file.path(path_root, "data", "decoding", "decoding", "*", "data", "*decoding.csv")
  37. # path to the data from the mask thresholding:
  38. path_thresh <- file.path(path_root, "data", "decoding", "decoding", "*", "data", "*thresholding.csv")
  39. # path to the data of the voxel patterns:
  40. path_patterns <- file.path(path_root, "data", "decoding", "decoding", "*", "data", "*voxel_patterns_union*.csv")
  41. # Load all [BIDS](http://bids.neuroimaging.io/) events files:
  42. # read all events files and concatenate them in a data table:
  43. # datalad get data/bids/sub-*/ses-*/func/*events.tsv
  44. dt_events <- do.call(rbind, lapply(Sys.glob(path_events), fread))
  45. # add the cue of the current trial and the response accuracy on a given trial:
  46. dt_events[, by = .(subject, condition, trial), ":=" (
  47. trial_cue = stim_label[!is.na(target) & target != 0],
  48. trial_accuracy = accuracy[!is.na(accuracy)]
  49. )]
  50. # read all decoding data files and concatenate them in a data table:
  51. # datalad get data/decoding/decoding/sub-*/data/*_decoding.csv
  52. dt_pred <- do.call(rbind, lapply(Sys.glob(path_pred), data.table::fread))
  53. # prepare data (add additional variables like a speed trial counter etc.)
  54. dt_pred <- prepare_data(dt_pred)
  55. # read all data from the mask thresholding:
  56. # datalad get data/decoding/decoding/*/data/*thresholding.csv
  57. dt_thresh = do.call(rbind, lapply(Sys.glob(path_thresh), data.table::fread))
  58. # read all data from the mask thresholding:
  59. # datalad get data/decoding/decoding/*/data/*voxel_patterns_union*.csv
  60. files_patterns = Sys.glob(path_patterns)
  61. files_patterns = files_patterns[!stringr::str_detect(files_patterns, "hpc")]
  62. #dt_patterns = lapply(files_patterns, data.table::fread)
  63. # create color list for probabilities of individual sequence events:
  64. color_events <- rev(hcl.colors(5, "Zissou 1"))
  65. # define global lmer settings used in all mixed effects lmer models:
  66. lcctrl <- lmerControl(
  67. optimizer = c("bobyqa"), optCtrl = list(maxfun = 500000),
  68. calc.derivs = FALSE)