-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_game_for_each_TR.m
64 lines (50 loc) · 1.69 KB
/
get_game_for_each_TR.m
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
function [games, levels] = get_game_for_each_TR(subj_id, do_cache)
if ~exist('do_cache', 'var')
do_cache = false;
end
filename = fullfile(get_mat_dir(false), sprintf('get_game_for_each_TR_subj=%d.mat', subj_id));
filename
% optionally cache
if do_cache
if exist(filename, 'file')
load(filename);
return
end
end
mongo_connect;
nruns = 6;
nTRs = 1698;
initial_TRs = 7;
n_games_per_run = 3;
nTRs_per_game = (nTRs / nruns - initial_TRs) / n_games_per_run;
EXPT = vgdl_expt;
glmodel = 1;
subj_games = {};
% Get game order for subject
[ subjects, subjdirs, goodRuns, goodSubjects ] = vgdl_getSubjectsDirsAndRuns();
for run_id = 1:nruns
if ~goodRuns{subj_id}(run_id)
continue
end
run = get_run(subj_id, run_id);
[game_names, onsets, durs] = get_games(subj_id, run, conn);
subj_games = [subj_games, game_names'];
end
% Expand games and levels to each TR
games = {};
levels = [];
for r = 1:sum(goodRuns{subj_id})
games = [games; repmat({''}, [initial_TRs, 1])];
levels = [levels; repmat(nan, [initial_TRs, 1])];
p = partition_id_from_run_id(r);
for g = (r - 1) * n_games_per_run + 1 : r * n_games_per_run
games = [games; repmat(subj_games(g), [nTRs_per_game, 1])];
levels = [levels; (ceil((1:nTRs_per_game) / nTRs_per_game * 3) + (p - 1) * 3)'];
end
end
%assert(length(games) == nTRs);
%assert(length(levels) == nTRs);
assert(length(levels) == length(games));
if do_cache
save(filename, 'games', 'levels', '-v7.3');
end