forked from tkkarjal/magia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magia_check_envs.m
40 lines (37 loc) · 1.79 KB
/
magia_check_envs.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
function magia_check_envs()
% Checks that the required environmental variables have been specified. If
% they have not been specified, Magia throws an error message.
%
% The necessary environmental variables are:
%
% DATA_DIR: The directory where the PET data are stored under, and where Magia will operate before archiving the results
% MRI_DIR: The directory where the MRI data are stored under
% SPM_DIR: The directory where SPM is installed in
% FREESURFER_HOME: The directory where FreeSurfer has been installed in
% MAGIA_PATH: The directory containing this file as well as other Magia-code
% MAGIA_ARCHIVE: The directory under which the Magia outputs will be stored
% FS_FINAL_DIR: The directory under which the FreeSurfer results will be stored
% FS_TEMP_DIR: The directory under which FreeSurfer will operate
magia_envs = {'DATA_DIR' 'MRI_DIR' 'SPM_DIR' 'FREESURFER_HOME' 'MAGIA_PATH' 'MAGIA_ARCHIVE' 'FS_FINAL_DIR' 'FS_TEMP_DIR'};
N = length(magia_envs);
env_found = true(N,1);
for i = 1:N
env = magia_envs{i};
if(isempty(getenv(env)))
env_found(i) = false;
end
end
if(any(~env_found))
env_not_found = magia_envs(~env_found);
M = length(env_not_found);
if(M == 1)
error('Magia was terminated because the environmental variable %s has not been specified. Please specify it in either startup.m or matlabrc.m using setenv, restart MATLAB, and try again.',env_not_found{1});
else
msg = 'Magia was terminated because the following environmental variables have not been specified:';
for i = 1:M
msg = sprintf('%s %s',msg,env_not_found{i});
end
error('%s\nPlease specify the environmental variables in either startup.m or matlabrc.m using setenv, restart MATLAB, and try again.',msg);
end
end
end