-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcache_trajectories.m
More file actions
39 lines (35 loc) · 1.77 KB
/
Copy pathcache_trajectories.m
File metadata and controls
39 lines (35 loc) · 1.77 KB
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
function cache_trajectories
% CACHE_TRAJECTORIES
% Loads the trajectories if not already loaded
global g_config;
global g_trajectories;
% also load a bunch of other useful properties about the trajectories
global g_trajectories_group;
global g_trajectories_session;
global g_trajectories_trial;
global g_trajectories_length;
global g_trajectories_speed;
if isempty(g_trajectories)
% see if we have them cached
cache_dir = fullfile(fileparts(mfilename('fullpath')),'/cache');
if ~exist(cache_dir, 'dir')
mkdir(cache_dir);
end
id = g_config.hash();
fn = fullfile(cache_dir, ['trajetories_', num2str(id), '.mat']);
if exist(fn, 'file')
load(fn);
else
g_trajectories = g_config.load_data();
save(fn, 'g_trajectories');
end
% select only groups inside the range set in the config
g_trajectories_group = arrayfun( @(t) t.group, g_trajectories.items);
g_trajectories = trajectories(g_trajectories.items(g_trajectories_group >= 1 & g_trajectories_group <= g_config.GROUPS));
g_trajectories_group = arrayfun( @(t) t.group, g_trajectories.items);
g_trajectories_session = arrayfun( @(t) t.session, g_trajectories.items);
g_trajectories_trial = arrayfun( @(t) t.trial, g_trajectories.items);
g_trajectories_length = arrayfun( @(t) t.compute_feature(g_config.FEATURE_LENGTH), g_trajectories.items);
g_trajectories_speed = arrayfun( @(t) t.compute_feature(g_config.FEATURE_AVERAGE_SPEED), g_trajectories.items);
end
end