put each circle drawn on a seperate row
#number of label is number of comma +1
count_label <- function(s){
return(str_count(s, ",") + 1)
}
preprocessed_si_data <- merged_data%>%
filter(trial_type == "konva-draw-circle") %>%
select(subject, culture, locations, labels) %>%
toJSON() %>%
fromJSON() %>%
mutate(
num_labels = count_label(labels),
circle_drawn = map(locations, ~ fromJSON(.) %>% as.data.frame()))%>%
unnest(circle_drawn) %>%
mutate(
version = case_when(
# new version does not have log the label along
is.na(label) ~ "new",
!is.na(label) ~ "old"
))
check if participants are drawing same number of labels as they draw the circles
summary <- preprocessed_si_data %>%
group_by(subject) %>%
summarise(
num_circle_drawn = n()
)
## `summarise()` ungrouping output (override with `.groups` argument)
preprocessed_si_data <- left_join(preprocessed_si_data,
summary,
by = "subject") %>%
mutate(
same_num_label_circle = (num_circle_drawn == num_labels)
)
many participants do not draw the number of labels they created instructions, new version doesn’t seem to be doing much better
preprocessed_si_data %>%
distinct(subject, .keep_all = TRUE) %>%
count(same_num_label_circle, version)
## # A tibble: 5 x 3
## same_num_label_circle version n
## <lgl> <chr> <int>
## 1 FALSE new 25
## 2 FALSE old 16
## 3 TRUE new 27
## 4 TRUE old 18
## 5 NA new 7
let’s look at the same number ones (this chunk print circles in the folder data/to_be_annotated/Circle/label_circle_match
)
same_number_df <- preprocessed_si_data %>%
filter(same_num_label_circle == TRUE)
save_image <- function(subjects, df){
num_id <- subjects
for (id in num_id){
d_circle <- df %>%
filter(subject == id)
# if using the newer version, i.e. not keeping track of the label along with the circles
if ((d_circle %>% filter(!is.na(label)) %>% count()) == 0){
d_circle$labels <- as.list(strsplit(d_circle$labels, ",")[[1]])
d_circle <- d_circle %>%
select(-label) %>%
unnest(labels) %>%
mutate(label = labels)
}
id <- as.character(id)
f_name <- paste(here("data/to_be_annotated/Circle/label_circle_match/"), id, ".png", sep="")
showtext_auto()
plot <- d_circle %>%
ggplot() +
geom_circle(aes(x0 = x, y0 = y, r = radius)) +
geom_text(aes(x = x, y = y, label = label)) +
coord_fixed(xlim = c(0,1024), ylim = c(0, 800)) +
scale_y_reverse()+
ggsave(f_name, plot)
#cairo_pdf(f_name)
#print(plot)
#dev.off()
}
}
save_image(same_number_df$subject, same_number_df)
and to look at the ones even worse data/to_be_annotated/Circle/label_circle_not_match
)
diff_number_df <- preprocessed_si_data %>%
filter(same_num_label_circle == FALSE)
save_image_bad <- function(subjects, df){
num_id <- subjects
for (id in num_id){
d_circle <- df %>%
filter(subject == id)
# if using the newer version, i.e. not keeping track of the label along with the circles
id <- as.character(id)
f_name <- paste(here("data/to_be_annotated/Circle/label_circle_not_match/"), id, ".png", sep="")
showtext_auto()
plot <- d_circle %>%
ggplot() +
geom_circle(aes(x0 = x, y0 = y, r = radius)) +
#geom_text(aes(x = x, y = y, label = label)) +
coord_fixed(xlim = c(0,1024), ylim = c(0, 800)) +
scale_y_reverse()+
ggsave(f_name, plot)
#cairo_pdf(f_name)
#print(plot)
#dev.off()
}
}
save_image_bad(diff_number_df$subject, diff_number_df)