-
Notifications
You must be signed in to change notification settings - Fork 0
/
configurations.m
90 lines (78 loc) · 4.01 KB
/
configurations.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
classdef configurations < handle
%CONFIGURATIONS Loads available experimental configurations
properties(GetAccess = 'public', SetAccess = 'protected')
descriptions = {};
class_names = {};
sub_configurations = {};
end
methods(Static)
% Singleton class - provides access to the object instance
function inst = instance()
persistent single_inst;
if isempty(single_inst) || ~isvalid(single_inst)
single_inst = configurations;
end
inst = single_inst;
end
end
methods
function config = get_configuration(inst, idx, sub_idx, desc)
%f = [inst.class_names{idx} '(''' desc ''', ' num2str(sub_idx) ')']
%config = eval([inst.class_names{idx} '(''' desc ''', ' num2str(sub_idx) ')']);
% HACK TODO: matlab crashing with the code above, need to
% investigate
switch idx
case 1
config = config_place_avoidance_silver(desc, sub_idx);
case 2
config = config_mwm_stress(desc, sub_idx);
case 3
config = config_place_avoidance_silver2(desc, sub_idx);
otherwise
error('Need to update the list of configurations');
end
end
end
methods(Access = 'private')
function inst = configurations()
% make sure that the WEKA library is initialized
addpath(fullfile(fileparts(mfilename('fullpath')),'/extern/weka'));
weka_init;
% add other needed folders to the path
addpath(fullfile(fileparts(mfilename('fullpath')),'/features'));
addpath(fullfile(fileparts(mfilename('fullpath')),'/data_representation'));
config_root = fullfile(fileparts(mfilename('fullpath')),'/config');
addpath(config_root);
% find all available configurations
files = dir(fullfile(config_root, '*'));
for fi = 1:length(files)
if files(fi).isdir
% add directory to the search folder list
addpath(fullfile(config_root, files(fi).name));
end
end
inst.class_names = {};
inst.descriptions = {};
inst.sub_configurations = {};
% hard coded configurations
conf_pat = config_place_avoidance_silver.CONFIGURATIONS;
conf_pat2 = config_place_avoidance_silver2.CONFIGURATIONS;
conf_mwm = config_mwm_stress.CONFIGURATIONS;
templates = { ...
'Place avoidance task (silver)', 'config_place_avoidance_silver', ...
arrayfun( @(idx) conf_pat{idx}{1}, ...
1:length(conf_pat), 'UniformOutput', 0), ...
'Morris water maze (peripubertal stress)', 'config_mwm_stress', ...
arrayfun( @(idx) conf_mwm{idx}{1}, ...
1:length(conf_mwm), 'UniformOutput', 0), ...
'Place avoidance task (silver) [new]', 'config_place_avoidance_silver2', ...
arrayfun( @(idx) conf_pat2{idx}{1}, ...
1:length(conf_pat2), 'UniformOutput', 0) ...
};
%, 'Place avoidance task (memantine)', config_place_avoidance_mem ...
inst.descriptions = arrayfun( @(idx) templates{idx}, 1:3:length(templates), 'UniformOutput', 0);
inst.class_names = arrayfun( @(idx) templates{idx}, 2:3:length(templates), 'UniformOutput', 0);
inst.sub_configurations = arrayfun( @(idx) templates{idx}, 3:3:length(templates), 'UniformOutput', 0);
end
end
end