Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mzettersten committed Aug 30, 2024
2 parents 6381779 + 2750c9f commit f19fa2b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
24 changes: 13 additions & 11 deletions data/yoon_simpimp_2015/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 10 additions & 9 deletions data/yoon_simpimp_2015/simpimp_preprocess.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)}

Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -61,22 +63,21 @@ preprocess.data <- function(file.name, x.max = 1680, y.max = 1050,
x=ifelse(0<x & x < x.max, x, NA),
y=ifelse(0<y & y < y.max, y, NA),
y=y.max-y, # move to cartesian origin
t=t/1000, #into milliseconds
subid=file.name)

return(d)
}

raw.data.path = "../raw_data/new_data/"
raw.data.path = "raw_data/eyetracking/new_data/"

stuff <- list.files(raw.data.path) |> # 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")



0 comments on commit f19fa2b

Please sign in to comment.