-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathgetAtlasDir.m
More file actions
77 lines (57 loc) · 1.93 KB
/
getAtlasDir.m
File metadata and controls
77 lines (57 loc) · 1.93 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
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
function dirname = getAtlasDir(arg)
global logger
logger = InitLogger(logger);
if ~exist('arg','var')
arg={};
end
dirname = '';
% First check argument for existence of atlas dir
if length(arg) > 2
dirname = arg{2};
end
% Set the components of the default atlas dir pathname
% <dirnameApp>/<dirnameRootAtlases>/<defaultAtlases{ii}>
% for both executable and matlab IDE
dirnameApp = getAppDir();
defaultAtlases = {'Colin','Colin_old'};
logger.Write('getAtlasDir: dirnameApp - %s\n', dirnameApp);
% No argument supplied or argument supplied but directory
% doesn't exist. In this case try finding defaults
if isempty(dirname) || ~exist(dirname,'file')
% Search for atlas in default locations
for ii = 1:length(defaultAtlases)
dirname = [dirnameApp, 'Data/', defaultAtlases{ii}];
if isAtlasDir(dirname)
break;
else
dirname = '';
end
end
% If we didn't find atlas in default locations,
% ask user to provide an atlas folder.
if isempty(dirname)
fprintf('Ask user for atlas dirname.\n');
dirname = selectAtlasDir(dirname);
end
% Argument supplied, dir exists but is not an atlas dir. It's an invitation
% for the user to pick the atlas from a list of atlases. Supposedly dirname contains
% a database of atlases.
elseif exist(dirname,'file') && ~isAtlasDir(dirname)
for ii = 1:length(defaultAtlases)
if isAtlasDir([dirname, '/', defaultAtlases])
dirname = [dirname, '/', defaultAtlases]; %#ok<AGROW>
else
dirname = '';
end
end
if isempty(dirname)
dirname = selectAtlasDir(dirname);
end
end
% Check if we still have no atlas dir and warn user if that's the case
if isempty(dirname)
MenuBox('Warning: Couldn''t find default atlas directory.','OK');
return;
end
logger.Write('Found atlas: %s\n', dirname);
dirname = filesepStandard(dirname);