I hope all is well. I recently developed a code (with the help of the wonderful stack overflow community) to calculate time to first fixation, first fixation duration, and total visit duration to areas of interest. I now want to update this so it can adjust based on the stimuli being presented. Specifically the x and y coordinates vary ever so slightly between each stimuli. I have an example spreadsheet of the stimuli coordinates. It would be great if I could read those in. Match it to the Stimuli in the Final_Label data and be able to calculate and summarize these metrics across all trials. So I need something within the code that essentially says - if it is this stimuli (e.g., A1 use these coordinates etc).
Thank you for your help and please let me know if I can provide any further information at this time.
Take care and stay well,
Caroline
Face_AOI <- Final_Label %>%
mutate(AOI_face = (mean_x >= .100 & mean_x <= .500 & mean_y >= .100 & mean_y <= .800), #we ## need to adjust these coordinates to be trial specific see below ###) %>%
filter(AOI_face) %>%
group_by(SubjectID, Trial) %>%
summarize(Face_totalfixationduration = sum(Duration), Face_firstfixationduration = first(Duration), Face_timetofirstfixation = first(Start))
Mouth_AOI <- Final_Labels %>%
mutate(AOI_mouth = (mean_x >= .200 & mean_x <= .300 & mean_y >= .500 & mean_y <= .600)) %>%
filter(AOI_mouth) %>%
group_by(SubjectID, Trial) %>%
summarize(Mouth_totalfixationduration = sum(Duration), Mouth_firstfixationduration = first(Duration), Mouth_timetofirstfixation = first(Start))
Mouth_AOI$SubjectID <- NULL
Eyes_AOI <- Final_Labels %>%
mutate(
AOI_eyes = (mean_x >= .200 & mean_x <= .300 & mean_y >= .500 & mean_y <= .600)) %>%
filter(AOI_eyes) %>%
group_by(SubjectID, Trial) %>%
summarize(Eyes_totalfixationduration = sum(Duration), Eyes_firstfixationduration = first(Duration), Eyes_timetofirstfixation = first(Start))
Example of a list of stimuli with different coordinates to integrate into the above code.
Df2 <- data.frame(Stimuli = c("A1", "A1", "A1", "A2", "A2", "A2"), #there is the same column in #Final_Labels
AOI = C("Face", "Eyes", "Mouth", "Face", "Eyes", "Mouth"),
X1 = c("0", "300", "301", "0", "305", "306"),
X2 = c("1022", "600", "600", "0", "604", "604"),
Y1 = c("0", "30", "31", "0", "30", "38"),
Y2 = c("0", "300", "301", "6", "305", "306"))
Aucun commentaire:
Enregistrer un commentaire