diff --git a/data/yoon_simpimp_2015/import.R b/data/yoon_simpimp_2015/import.R index e13b370..facfa41 100644 --- a/data/yoon_simpimp_2015/import.R +++ b/data/yoon_simpimp_2015/import.R @@ -28,24 +28,26 @@ generate_aois <- function(x, y, target_side, } # eyetracking_path <- here(data_path, "eyetracking") -data_ex_1<- read_csv(here(eyetracking_path, "eyetrack_expt1.csv")) |> mutate(expt="0") -data_ex_2 <- read_csv(here(eyetracking_path, "eyetrack_expt2.csv")) |> mutate(expt="scale") +data_ex_1<- read_csv(here(eyetracking_path, "eyetrack_expt1.csv")) |> + mutate(expt="0") + +data_ex_2 <- read_csv(here(eyetracking_path, "eyetrack_expt2.csv")) |> + mutate(expt="scale") exclusion_data <- read_csv(here(eyetracking_path, "simpimp_et_log.csv")) |> filter(age!="adult") order_data <- read_csv(here(eyetracking_path, "simpimp_et_order.csv")) -draft_data <- data_ex_1 |> bind_rows(data_ex_2) |> left_join(order_data) |> - mutate(time=ifelse(is.na(order), NA, time), #this is janky - VB - stimulus=ifelse(is.na(order), NA, stimulus)) |> - group_by(subid) |> - fill(order:targetOnset) |> - fill(time:stimulus) |> +draft_data <- data_ex_1 |> bind_rows(data_ex_2) |> inner_join(order_data) |> + #mutate(time=ifelse(is.na(order), NA, time), #this is janky - VB + # stimulus=ifelse(is.na(order), NA, stimulus)) |> + #group_by(subid) |> + # fill(order:targetOnset) |> + # fill(time:stimulus) |> ungroup() |> filter(!is.na(time)) |> - mutate(time=time/1000, - t=t-time-1000*targetOnset, - point_of_disambiguation=time+1000*targetOnset) |> + mutate(t=t-time, + point_of_disambiguation=1000*targetOnset) |> select(-lx, -ly, -rx, -ry) |> inner_join(exclusion_data) |> mutate(target_side=ifelse(targetPos=="R","right", "left"), condition=case_when( diff --git a/data/yoon_simpimp_2015/simpimp_preprocess.R b/data/yoon_simpimp_2015/simpimp_preprocess.R index db1640e..6f4014d 100644 --- a/data/yoon_simpimp_2015/simpimp_preprocess.R +++ b/data/yoon_simpimp_2015/simpimp_preprocess.R @@ -8,7 +8,7 @@ library(janitor) source("useful.R") select_msg <- function(df){ - if (raw.data.path=="../raw_data/new_data/") + if (raw.data.path=="raw_data/eyetracking/new_data/") {df |> select(time, message=l_raw_x_px)} else {df |> select(time, message=l_por_x_px)} @@ -31,9 +31,10 @@ preprocess.data <- function(file.name, x.max = 1680, y.max = 1050, lx = to.n(l_por_x_px), rx = to.n(r_por_x_px), ly = to.n(l_por_y_px), - ry = to.n(r_por_y_px) + ry = to.n(r_por_y_px), + t=time/1000 #convert ms ) |> - select(t = time, lx, ly, rx, ry) + select(t = t, lx, ly, rx, ry) print(file.name) @@ -42,7 +43,8 @@ preprocess.data <- function(file.name, x.max = 1680, y.max = 1050, msgs <- all.d |> filter(str_detect(type,"MSG")) |> select_msg() |> - mutate(stimulus = as.character(message) |> + mutate(time=time/1000, #to ms + stimulus = as.character(message) |> str_replace("# Message: ", "") |> str_replace(".jpg","")) |> select(-message) @@ -61,22 +63,21 @@ preprocess.data <- function(file.name, x.max = 1680, y.max = 1050, x=ifelse(0 # big issues - map(preprocess.data) |> bind_rows() |> mutate(expt="expt2") |> write_csv("eyetrack_expt2.csv") + map(preprocess.data) |> bind_rows() |> mutate(expt="expt2") |> write_csv("raw_data/eyetracking/eyetrack_expt2.csv") -raw.data.path = "../raw_data/old_data/" +raw.data.path = "raw_data/eyetracking/old_data/" #foo <- preprocess.data("140217-02-L1.txt") stuff2 <- list.files(raw.data.path) |> - map(preprocess.data) |> bind_rows() |> mutate(expt="expt1") |> write_csv("eyetrack_expt1.csv") + map(preprocess.data) |> bind_rows() |> mutate(expt="expt1") |> write_csv("raw_data/eyetracking/eyetrack_expt1.csv")