Skip to content

Commit

Permalink
Use words from encoding phase only for memorability
Browse files Browse the repository at this point in the history
  • Loading branch information
psychelzh committed Nov 15, 2024
1 parent d27a245 commit 6ed8d70
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
17 changes: 16 additions & 1 deletion R/behav.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,22 @@ calc_simil_mem <- function(mem_perf) {

calc_memorability <- function(data) {
data |>
summarise(pc = mean(score == 1), .by = trial_id)
summarise(
pc = mean(score == 1),
.by = c(trial_id, word_id)
)
}

calc_mem_content <- function(events, memorability) {
events |>
left_join(memorability, by = c("trial_id", "word_id")) |>
# we should use old words only
filter(word_id <= 150) |>
mutate(resp = -resp) |>
summarise(
r = psych::polyserial(pick(pc), pick(resp))[, 1],
.by = subj
)
}

calc_mem_perf_precise <- function(data) {
Expand Down
4 changes: 2 additions & 2 deletions _freeze/index/execute-results/html.json

Large diffs are not rendered by default.

Binary file modified _freeze/index/figure-html/behav-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 1 addition & 9 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,7 @@ list(
),
tar_target(simil_mem, calc_simil_mem(mem_perf)),
tar_target(memorability, calc_memorability(events_retrieval)),
tar_target(
memorability_content,
events_retrieval |>
left_join(memorability, by = "trial_id") |>
summarise(
r = psych::polyserial(pick(pc), pick(resp))[, 1],
.by = subj
)
),
tar_target(memorability_content, calc_mem_content(events_retrieval, memorability)),

# stimuli patterns ----
tar_target(file_seq, "config/sem_sequence.mat", format = "file"),
Expand Down
12 changes: 8 additions & 4 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,14 @@ p_smc <- targets::tar_read(smc) |>
theme(axis.line = element_line(linewidth = 1))
p_memorability <- targets::tar_read(memorability) |>
ggplot(aes(pc)) +
geom_histogram(fill = "grey") +
scale_x_continuous(name = "Memorability") +
scale_y_continuous(name = "Count") +
filter(word_id <= 150) |>
mutate(
trial_id_new = as.integer(fct_reorder(factor(trial_id), desc(pc)))
) |>
ggplot(aes(trial_id_new, pc)) +
geom_col(fill = "grey", width = 0.8) +
scale_x_continuous(name = "Order of Words", expand = c(0, 0)) +
scale_y_continuous(name = "Memorability", expand = c(0, 0)) +
theme(axis.line = element_line(linewidth = 1))
p_memorability_content <- targets::tar_read(memorability_content) |>
Expand Down

0 comments on commit 6ed8d70

Please sign in to comment.