forked from BUNPC/Homer3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Homer3.m
83 lines (68 loc) · 1.88 KB
/
Homer3.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
function unitTest = Homer3(groupDirs, inputFileFormat, unitTest)
% Syntax:
% unitTest = Homer3(groupDirs, inputFileFormat)
%
% Examples:
%
% Homer3({'.'}, '.snirf')
% Homer3({'.'}, '.nirs')
%
global logger
global cfg
setNamespace('Homer3');
if ~exist('groupDirs','var') || isempty(groupDirs)
groupDirs = pwd;
end
if ~exist('inputFileFormat','var') || isempty(inputFileFormat)
inputFileFormat = '.snirf';
end
if ~exist('unitTest','var')
unitTest = [];
end
if ~iscell(groupDirs)
groupDirs = {groupDirs};
end
for ii = 1:length(groupDirs)
groupDirs{ii} = filesepStandard(groupDirs{ii});
end
if isempty(unitTest)
logger = Logger('Homer3');
elseif unitTest.IsEmpty()
logger = InitLogger(logger, 'UnitTestsAll');
else
return;
end
logger.CurrTime();
cfg = ConfigFileClass();
if strcmp(cfg.GetValue('Logging'), 'off')
logger.SetDebugLevel(logger.Null());
end
PrintSystemInfo(logger, 'Homer3', getArgs(groupDirs, inputFileFormat, unitTest, nargin));
checkForHomerUpdates();
gdir = cfg.GetValue('Last Group Folder');
if isempty(gdir)
if isdeployed()
groupDirs = {[getAppDir(), 'SubjDataSample']};
end
end
try
unitTest = MainGUI(groupDirs, inputFileFormat, unitTest, 'userargs');
catch ME
% Clean up in case of error make sure all open file handles are closed
% so we don't leave the application in a bad state
cfg.Close();
printStack(ME);
logger.Close();
rethrow(ME);
end
% ------------------------------------------------------------------------
function args = getArgs(groupDirs, inputFileFormat, unitTest, nargin)
if nargin == 0
args = {};
elseif nargin == 1
args = {groupDirs};
elseif nargin == 2
args = {groupDirs, inputFileFormat};
elseif nargin == 3
args = {groupDirs, inputFileFormat, unitTest};
end