From b02b5bcfa50267f934b33f906c7f8753b8b0ed8b Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sun, 22 Sep 2024 12:21:43 +0800 Subject: [PATCH] Add word shapes pattern --- _targets.R | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/_targets.R b/_targets.R index d0c3054..5306eb1 100644 --- a/_targets.R +++ b/_targets.R @@ -85,12 +85,16 @@ list( pattern = map(subj_id_loop) ), tar_target(file_seq, "config/sem_sequence.mat", format = "file"), + tar_target( + mapping_word_trial, + raveio::read_mat(file_seq)$SM[, 1:2] |> + as_tibble(.name_repair = ~ c("trial_id", "word_id")) + ), tar_target(file_w2v, "data/stimuli/words_w2v.txt", format = "file"), tar_target( pattern_semantics, - raveio::read_mat(file_seq)$SM[, 1:2] |> - as_tibble(.name_repair = ~ c("trial_id", "word_id")) |> - left_join( + mapping_word_trial |> + inner_join( read_table(file_w2v, show_col_types = FALSE, col_names = FALSE), by = c("word_id" = "X1") ) |> @@ -99,6 +103,19 @@ list( column_to_rownames("trial_id") |> proxy::simil(method = "cosine") ), + tar_target( + file_word_shape, + "data/stimuli/words_shape_similarity.tsv", + format = "file" + ), + tar_target( + pattern_shapes, { + order <- with(mapping_word_trial, word_id[trial_id > 0]) + x <- read_tsv(file_word_shape, show_col_types = FALSE)$similarity |> + pracma::squareform() + as.dist(x[order, order]) + } + ), tar_target(data_iss_dynamic, calc_iss(patterns_indiv_dynamic, pattern_semantics)), tar_target(stats_iss_dynamic, calc_iss_stats(data_iss_dynamic)), tarchetypes::tar_rep(