-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstich_data.R
89 lines (61 loc) · 1.98 KB
/
stich_data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
library(tidyverse)
library(eyetools)
# this bit reads in the files and uses part of the filename to make a new "subj" variable
fnams <- list.files("CSV Data", "ids", full.names = TRUE) # needed for reading data
subjs <- list.files("CSV Data", "ids") # needed for identifying subject numbers
data <- NULL
for (subj in 1:length(fnams)) {
print(fnams[subj])
pData <- read_csv(fnams[subj], col_types = cols(), col_names = FALSE) # read the data from csv
pData <-
pData %>%
mutate(pNum = substr(subjs[subj],1,3)) %>%
select(pNum, everything())
data <- rbind(data, pData) # combine data array with existing data
}
id_data <- data %>% rename(trial_ID = X1)
# Process eye data
for (p in 1:2){
if (p == 1){
file_key = "fix"
}
else{
file_key = "stim"
}
fnams <- list.files("CSV Data", file_key, full.names = TRUE) # needed for reading data
subjs <- list.files("CSV Data", file_key) # needed for identifying subject numbers
data <- NULL
for (subj in 1:length(fnams)) {
print(fnams[subj])
print(p)
pData <- read_csv(fnams[subj], col_types = cols(), col_names = FALSE) # read the data from csv
pData[pData==-1] <- NA
pData <-
pData %>%
select(time = X6, left_x = X1, left_y = X2,
right_x = X3, right_y = X4, trial = X5)
# combine eyes
pData <- combine_eyes(pData, "average")
# interpolate
pData <- interpolate(pData)
# mutate x/y to screen res
pData <-
pData %>%
mutate(x = x*1920, y = y*1080,
time = round(time/1000)) %>%
group_by(trial) %>%
mutate(time = time - time[1])
fix_d <- fix_dispersion(pData)
fix_d <- fix_d %>%
mutate(pNum = substr(subjs[subj],1,3), .before = trial)
data <- rbind(data, fix_d) # combine data array with existing data
}
if (p == 1){
eg_fix <- data
} else{
eg_stim <- data
}
}
save(id_data, eg_fix, eg_stim, file = "inj_unsw_data.RData")
save(data, file = "AGP_5R_data.RData")
# spatial_plot(AOIs = AOI_AGP)