1- function bidsLesionAbnormalitiesDetection(opt )
1+ function bidsLesionAbnormalitiesDetection(opt , extraOptions )
22 %
33 % Use the ALI toolbox to detect lesion abnormalities in anatomical image
44 % after segmentation of the image.
@@ -9,41 +9,87 @@ function bidsLesionAbnormalitiesDetection(opt)
99 %
1010 % bidsLesionAbnormalitiesDetection(opt)
1111 %
12- % :type opt: structure
1312 % :param opt: Options chosen for the analysis.
1413 % See also: checkOptions
1514 % ``checkOptions()`` and ``loadAndCheckOptions()``.
1615 % :type opt: structure
1716 %
17+ % :param extraOptions: Options chosen for analysis of another dataset
18+ % in case they need to be merged.
19+ % See also: checkOptions
20+ % ``checkOptions()`` and ``loadAndCheckOptions()``.
21+ % :type extraOptions: structure
22+ %
1823 % Lesion abnormalities detection will be performed using the information provided
1924 % from the lesion segmentation output in BIDS format.
2025 %
2126 %
2227 % (C) Copyright 2021 CPP_SPM developers
2328
29+ % TODO: do not use extraOptions but instead either opt(1) and opt(2) or
30+
31+ if nargin < 2
32+ extraOptions = [];
33+ end
34+
35+ % create a structure to collect image names
36+ labels = {' GM' , ' WM' };
37+ for i = 1 : numel(labels )
38+ images(i , 1 ) = struct(' controls' , [], ' patients' , []);
39+ end
40+
2441 opt.dir.input = opt .dir .preproc ;
2542
2643 if checkToolbox(' ALI' , ' verbose' , opt .verbosity > 0 )
2744 opt = setFields(opt , ALI_my_defaults());
2845 end
2946
30- [ BIDS , opt ] = setUpWorkflow (opt , ' abnormalities detection ' );
47+ images = collectImagesFromDataset (opt , images , labels );
3148
32- labels = {' GM' , ' WM' };
49+ if ~isempty(extraOptions )
50+ if checkToolbox(' ALI' , ' verbose' , extraOptions .verbosity > 0 )
51+ extraOptions = setFields(extraOptions , ALI_my_defaults());
52+ end
53+ extraOptions.dir.input = extraOptions .dir .preproc ;
54+ images = collectImagesFromDataset(extraOptions , images , labels );
55+ end
3356
34- % create a structure to collect image names
35- for i = 1 : numel(labels )
36- images(i , 1 ) = struct(' controls' , [], ' patients' , []);
57+ %%
58+ controlsImages = cat(1 , images .controls );
59+ patientsImages = cat(1 , images .patients );
60+
61+ if isempty(controlsImages ) || ...
62+ isempty(patientsImages ) || ...
63+ any(cellfun(' isempty' , controlsImages )) || ...
64+ any(cellfun(' isempty' , patientsImages ))
65+ msg = sprintf(' Must have segmentation output from patients AND control' );
66+ id = ' missingImages' ;
67+ errorHandling(mfilename(), id , msg , false );
3768 end
3869
70+ matlabbatch = {};
71+ matlabbatch = setBatchLesionAbnormalitiesDetection(matlabbatch , opt , images );
72+
73+ saveAndRunWorkflow(matlabbatch , ' LesionAbnormalitiesDetection' , opt );
74+
75+ end
76+
77+ function images = collectImagesFromDataset(opt , images , labels )
78+
79+ [BIDS , opt ] = setUpWorkflow(opt , ' abnormalities detection' );
80+
3981 for iSub = 1 : numel(opt .subjects )
4082
4183 subLabel = opt.subjects{iSub };
4284
4385 printProcessingSubject(iSub , subLabel , opt );
4486
4587 idx = strcmp(BIDS .participants .content .participant_id , [' sub-' subLabel ]);
46- participantsGroup = BIDS .participants .content .group(idx );
88+ if isfield(BIDS .participants .content , ' group' )
89+ participantsGroup = BIDS .participants .content .group(idx );
90+ elseif isfield(BIDS .participants .content , ' Group' )
91+ participantsGroup = BIDS .participants .content .Group(idx );
92+ end
4793
4894 anatImage = getAnatFilename(BIDS , opt , subLabel );
4995 anatImage = bids .File(anatImage );
@@ -79,9 +125,4 @@ function bidsLesionAbnormalitiesDetection(opt)
79125
80126 end
81127
82- matlabbatch = {};
83- matlabbatch = setBatchLesionAbnormalitiesDetection(matlabbatch , opt , images );
84-
85- saveAndRunWorkflow(matlabbatch , ' LesionAbnormalitiesDetection' , opt );
86-
87128end
0 commit comments