Skip to content

Commit 447caab

Browse files
committed
v1.80.1
-- If no data files were found in group folder because all the potential ones had errors display all the files not loaded in the error files listbox instead of displaying completely empty GUI. * DataTree, v1.15.1 -- Avoid loading snirf files from derived data folder such as derivatives/homer. -- Error check measurement list in DataClass. Make sure that for source/detector pair the number of channels is equal to number of data types that is number of wavelengths or for derived data number of Hb types * number of conditions. * Utils, v1.7.1 -- Avoid loading snirf files from derived data folder such as derivatives/homer. Extend excluded folders in findTypeFiles.m to check for files in derived folder
1 parent 72e3a8d commit 447caab

File tree

9 files changed

+119
-15
lines changed

9 files changed

+119
-15
lines changed

DataTree/AcquiredData/DataFiles/DataFilesClass.m

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
properties (Access = private)
1717
lookupTable
18+
excludedFolders
1819
end
1920

2021
methods
@@ -38,6 +39,7 @@
3839

3940
obj.logger = logger;
4041
obj.lookupTable = [];
42+
obj.excludedFolders = {};
4143

4244
skipconfigfile = false;
4345
askToFixNameConflicts = [];
@@ -74,7 +76,7 @@
7476
obj.rootdir = filesepStandard(obj.rootdir,'full');
7577

7678
% Configuration parameters
77-
obj.config = struct('RegressionTestActive','','AskToFixNameConflicts',1);
79+
obj.config = struct('RegressionTestActive','', 'AskToFixNameConflicts',1, 'DerivedDataDir','');
7880
if skipconfigfile==false
7981
str = cfg.GetValue('Regression Test Active');
8082
if strcmp(str,'true')
@@ -96,6 +98,18 @@
9698
obj.config.SuppressErrorChecking = true;
9799
end
98100

101+
[p, f] = fileparts(cfg.GetValue('Output Folder Name'));
102+
if isempty(p)
103+
obj.config.DerivedDataDir = f;
104+
else
105+
obj.config.DerivedDataDir = p;
106+
end
107+
obj.excludedFolders = {...
108+
[obj.rootdir, obj.config.DerivedDataDir];
109+
[obj.rootdir, 'fw'];
110+
[obj.rootdir, 'imagerecon'];
111+
[obj.rootdir, 'anatomical'];
112+
};
99113
if nargin==0
100114
return;
101115
end
@@ -222,6 +236,14 @@ function FindDataSet(obj, iFormat, iPattern, parentdir)
222236
return
223237
end
224238
parentdir = filesepStandard(parentdir);
239+
240+
% Check if folder is excluded, if yes don't search there
241+
for ii = 1:length(obj.excludedFolders)
242+
if includes(parentdir, obj.excludedFolders{ii})
243+
return;
244+
end
245+
end
246+
225247
pattern = obj.dirFormats.choices{iFormat}{iPattern};
226248

227249
dirs = mydir([parentdir, pattern], obj.rootdir);
@@ -307,9 +329,9 @@ function ErrorCheckFinal(obj)
307329
obj.ErrorCheckName();
308330

309331
% Find all acquisition files in group folder
310-
fileNames = findTypeFiles(obj.rootdir, ['.', obj.filetype]);
332+
fileNames = findTypeFiles(obj.rootdir, ['.', obj.filetype], obj.excludedFolders);
311333

312-
% Make alist of all files excluded from current data set
334+
% Make a list of all files excluded from current data set
313335
for ii = 1:length(fileNames)
314336
filefound = false;
315337

DataTree/AcquiredData/Snirf/DataClass.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@
289289
if ~exist('params','var')
290290
params = propnames(obj);
291291
end
292+
293+
% Check dataTimeSeries
292294
if ismember('dataTimeSeries',params)
293295
if obj.IsEmpty()
294296
err = -2;
@@ -304,6 +306,8 @@
304306
err = 5;
305307
end
306308
end
309+
310+
% Check time
307311
if ismember('time',params)
308312
if isempty(obj.time)
309313
err = -6;
@@ -313,6 +317,25 @@
313317
err = 7;
314318
end
315319
end
320+
321+
% Check measurement list
322+
if ismember('measurementList',params)
323+
ml = sortrows(obj.GetMeasurementList('matrix'));
324+
nDatatypes = length(unique(ml(:,4))) * length(unique(ml(:,3)));
325+
i = 1;
326+
while i <= size(ml,1)
327+
k = find(ml(:,1)==ml(i,1) & ml(:,2)==ml(i,2));
328+
if length(k) < nDatatypes
329+
err = -7;
330+
elseif length(k) > nDatatypes
331+
err = -8;
332+
end
333+
if err < 0
334+
break
335+
end
336+
i = i+length(k);
337+
end
338+
end
316339
end
317340

318341
end

DataTree/DataTreeClass.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ function FindAndLoadGroups(obj, groupDirs, fmt, procStreamCfgFile, options)
267267
while dataInit.GetError() < 0
268268
dataInit = FindFiles(obj.dirnameGroups{kk}, fmt, options);
269269
if isempty(dataInit) || dataInit.IsEmpty()
270+
obj.filesErr = dataInit.filesErr;
271+
ErrorCheckLoadedFiles(obj);
270272
return;
271273
end
272274
dataInitPrev(iter) = dataInit;
@@ -374,6 +376,7 @@ function LoadGroup(obj, iGroup, procStreamCfgFile, options)
374376
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375377
obj.AcqData2Group(iGroup);
376378
if isempty(obj.groups)
379+
obj.ErrorCheckLoadedFiles();
377380
return
378381
end
379382

DataTree/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.15.0
1+
1.15.1

MainGUI/MainGUI.m

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,17 @@ function MainGUI_EnableDisableGUI(handles, val)
8484

8585
% Processing element panel
8686
set(handles.listboxGroupTree, 'enable', val);
87-
set(handles.listboxFilesErr, 'enable', val);
87+
if strcmp(get(handles.listboxFilesErr, 'visible'), 'on')
88+
set(handles.listboxFilesErr, 'enable','on');
89+
else
90+
set(handles.listboxFilesErr, 'enable',val);
91+
end
8892
set(handles.pushbuttonHideErrors, 'enable',val);
8993
set(handles.radiobuttonProcTypeGroup, 'enable', val);
9094
set(handles.radiobuttonProcTypeSubj, 'enable', val);
9195
set(handles.radiobuttonProcTypeSess, 'enable', val);
9296
set(handles.radiobuttonProcTypeRun, 'enable', val);
93-
set(handles.textStatus, 'enable', val);
97+
set(handles.textStatus, 'enable','on');
9498

9599
% Data plot panel
96100
set(handles.textPanLeftRight, 'enable', val);
@@ -153,12 +157,17 @@ function MainGUI_EnableDisablePlotEditMode(handles, val)
153157

154158
% Processing element panel
155159
set(handles.listboxGroupTree, 'enable', val);
156-
set(handles.listboxFilesErr, 'enable', val);
160+
if strcmp(get(handles.listboxFilesErr, 'visible'), 'on')
161+
set(handles.listboxFilesErr, 'enable','on');
162+
else
163+
set(handles.listboxFilesErr, 'enable',val);
164+
end
165+
set(handles.textStatus, 'enable','on');
166+
set(handles.pushbuttonHideErrors, 'enable',val);
157167
set(handles.radiobuttonProcTypeGroup, 'enable', val);
158168
set(handles.radiobuttonProcTypeSubj, 'enable', val);
159169
set(handles.radiobuttonProcTypeSess, 'enable', val);
160170
set(handles.radiobuttonProcTypeRun, 'enable', val);
161-
set(handles.textStatus, 'enable', val);
162171

163172
% Control
164173
set(handles.pushbuttonCalcProcStream, 'enable', val);
@@ -246,6 +255,7 @@ function MainGUI_EnableDisablePlotEditMode(handles, val)
246255
% Load date files into group tree object
247256
maingui.dataTree = LoadDataTree(maingui.groupDirs, maingui.format, procStreamFile);
248257
if maingui.dataTree.IsEmpty()
258+
DisplayGroupTree(handles);
249259
return;
250260
end
251261
if ~isempty(maingui.unitTest)
@@ -367,7 +377,7 @@ function DisplayGroupTree(handles)
367377
% Initialize listboxGroupTree params struct
368378
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
369379
maingui.listboxGroupTreeParams = struct('listMaps',struct('names',{{}}, 'idxs', []), ...
370-
'views', struct('GROUP',1, 'SUBJS',2, 'SESS',3, 'NOSESS',4, 'RUNS',5), ...
380+
'views',struct('GROUP',1, 'SUBJS',2, 'SESS',3, 'NOSESS',4, 'RUNS',5), ...
371381
'viewSetting',0);
372382

373383
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -379,13 +389,16 @@ function DisplayGroupTree(handles)
379389
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380390
% Determine the best view for the data files
381391
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
382-
[viewSetting, views] = SetView(handles, nSubjs, nSess, nRuns);
392+
[viewSetting, ~] = SetView(handles, nSubjs, nSess, nRuns);
383393

384394
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
385395
% Set listbox used for displaying valid data
386396
% Get the GUI listboxGroupTree setting
387397
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388-
listboxGroup = maingui.listboxGroupTreeParams.listMaps(viewSetting).names;
398+
listboxGroup = {};
399+
if viewSetting <= length(maingui.listboxGroupTreeParams.listMaps)
400+
listboxGroup = maingui.listboxGroupTreeParams.listMaps(viewSetting).names;
401+
end
389402

390403
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
391404
% Set listbox used for displaying files that did not load correctly
@@ -417,8 +430,16 @@ function DisplayGroupTree(handles)
417430
if nFilesFailed > 0 || nFilesWarning > 0
418431
set(handles.textStatus, 'foregroundcolor',maingui.errcolor);
419432
if nFilesFailed > 0
420-
set(handles.listboxFilesErr, 'visible','on', 'value',1, 'string',listboxFilesErr)
433+
set(handles.listboxFilesErr, 'visible','on', 'enable','on','value',1, 'string',listboxFilesErr)
421434
set(handles.pushbuttonHideErrors, 'visible','on');
435+
if nFileSuccess==0
436+
set(handles.pushbuttonHideErrors, 'visible','off');
437+
p1 = get(handles.listboxGroupTree, 'position');
438+
p2 = get(handles.listboxFilesErr, 'position');
439+
offset_y = p1(4)/2;
440+
set(handles.listboxGroupTree, 'position',[p1(1), p1(2)+offset_y, p1(3), offset_y])
441+
set(handles.listboxFilesErr, 'position',[p2(1), p2(2), p2(3), p2(4)+offset_y])
442+
end
422443
else
423444
set(handles.listboxFilesErr, 'visible','off');
424445
set(handles.pushbuttonHideErrors, 'visible','off');
@@ -436,6 +457,9 @@ function DisplayGroupTree(handles)
436457
set(handles.listboxGroupTree, 'position', [pos1(1) pos2(2) pos1(3) .98-pos2(2)]);
437458
end
438459
end
460+
if nFileSuccess==0
461+
return
462+
end
439463

440464
% Select initial data tree processing element in the 'Current Processing Element' panel
441465
idx = [1,1,1,1];

MainGUI/MapGroupTree2List.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
% a linear index used to select a listbox entry
66

77
viewSetting = maingui.listboxGroupTreeParams.viewSetting;
8-
idxs = maingui.listboxGroupTreeParams.listMaps(viewSetting).idxs;
8+
idxs = [];
9+
if viewSetting <= length(maingui.listboxGroupTreeParams.listMaps)
10+
idxs = maingui.listboxGroupTreeParams.listMaps(viewSetting).idxs;
11+
end
912

1013
% Convert processing element tuple index to a scalar
1114
scalar0 = index2scalar(iGroup, iSubj, iSess, iRun);

Utils/Shared/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.0
1+
1.7.1

Utils/Shared/findTypeFiles.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
if strcmp(files(ii).name, exclList{kk})
3636
exclFlag = true;
3737
end
38+
if ~isempty(pathsubtract(files(ii).folder, exclList{kk}))
39+
exclFlag = true;
40+
end
3841
end
3942
if exclFlag==true
4043
continue;
@@ -137,3 +140,29 @@
137140

138141

139142

143+
% ----------------------------------------------------------------
144+
function diff = pathsubtract(p2_0, p1_0, options)
145+
if ~exist('options','var')
146+
options = '';
147+
end
148+
if optionExists(options, 'nochange')
149+
option = '';
150+
else
151+
option = 'full';
152+
end
153+
p1 = filesepStandard(p1_0, option);
154+
p2 = filesepStandard(p2_0, option);
155+
if isempty(p1)
156+
p1 = p1_0;
157+
end
158+
if isempty(p2)
159+
p2 = p2_0;
160+
end
161+
k = strfind(p2, p1);
162+
if ~isempty(k) && k(1)==1
163+
diff = p2(k(1)+length(p1):end);
164+
elseif ~isempty(k)
165+
diff = p2(1:k(1)-1);
166+
else
167+
diff = '';
168+
end

Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.80.0
1+
1.80.1

0 commit comments

Comments
 (0)