Skip to content

Commit

Permalink
Minor fix on preprocess functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeyeongYang committed Sep 11, 2020
1 parent a6b0ee0 commit 1bdaad8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/R/preprocess_funcs.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @noRd
#' @keywords internal

alt_preprocess_func <- function(raw-data, general_info) {
alt_preprocess_func <- function(raw_data, general_info) {
# Currently class(raw_data) == "data.table"

# Use general_info of raw_data
Expand Down Expand Up @@ -760,29 +760,29 @@ rdt_preprocess_func <- function(raw_data, general_info) {

task2AFC_preprocess_func <- function(raw_data, general_info) {
# Currently class(raw_data) == "data.table"

# Use general_info of raw_data
subjs <- general_info$subjs
n_subj <- general_info$n_subj

# Initialize (model-specific) data arrays
signal <- array(0, c(n_subj))
noise <- array(0, c(n_subj))
h <- array(0, c(n_subj))
f <- array(0, c(n_subj))


# Write from raw_data to the data arrays
for (i in 1:n_subj) {
subj <- subjs[i]
subj_data <- subset(raw_data, raw_data$subjid == subj)

signal[i] = nrow(subset(subj_data, subj_data$stimulus == 1))
noise[i] = nrow(subset(subj_data, subj_data$stimulus == 0))
h[i] = nrow(subset(subj_data, subj_data$stimulus ==1 & subj_data$response ==1))
f[i] = nrow(subset(subj_data, subj_data$stimulus ==0 & subj_data$response ==1))
}

# Wrap into a list for Stan
data_list <- list(
N = n_subj,
Expand All @@ -791,7 +791,7 @@ task2AFC_preprocess_func <- function(raw_data, general_info) {
h = h,
f = f
)

# Returned data_list will directly be passed to Stan
return(data_list)
}
Expand Down

0 comments on commit 1bdaad8

Please sign in to comment.