@@ -9,9 +9,9 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
99 % :param funcFWHM: smoothing (FWHM) applied to the the normalized EPI
1010 % :type funcFWHM: (scalar)
1111 % :param deleteIndBeta: decide to delete beta-maps
12- % :type funcFWHM : (boolean)
12+ % :type deleteIndBeta : (boolean)
1313 % :param deleteIndTmaps: decide to delete t-maps
14- % :type funcFWHM : (boolean)
14+ % :type deleteIndTmaps : (boolean)
1515 %
1616 % When concatenating betamaps:
1717 %
@@ -22,12 +22,21 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
2222 %
2323 % (C) Copyright 2019 CPP_SPM developers
2424
25- if nargin < 3
26- deleteIndBeta = 1 ;
27- deleteIndTmaps = 1 ;
25+ [~ , opt ] = setUpWorkflow(opt , ' merge beta images and t-maps' );
26+
27+ % TODO temporary check: will be removed on the dev branch
28+ if ~isfield(opt , ' dryRun' )
29+ opt.dryRun = false ;
2830 end
2931
30- [~ , opt ] = setUpWorkflow(opt , ' merge beta images and t-maps' );
32+ if nargin < 3
33+ deleteIndBeta = true ;
34+ deleteIndTmaps = true ;
35+ end
36+ if opt .dryRun
37+ deleteIndBeta = false ;
38+ deleteIndTmaps = false ;
39+ end
3140
3241 RT = 0 ;
3342
@@ -41,21 +50,25 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
4150
4251 load(fullfile(ffxDir , ' SPM.mat' ));
4352
44- contrasts = specifyContrasts(ffxDir , opt .taskName , opt );
53+ model = spm_jsonread(opt .model .file );
54+
55+ contrasts = specifyContrasts(SPM , opt .taskName , model );
4556
4657 beta_maps = cell(length(contrasts ), 1 );
4758 t_maps = cell(length(contrasts ), 1 );
4859
4960 % path to beta and t-map files.
61+ fprintf(1 , ' \n Concatenating the following contrasts:' );
5062 for iContrast = 1 : length(beta_maps )
5163
64+ fprintf(1 , ' \n\t%s ' , contrasts(iContrast ).name);
5265 betasIndices = find(contrasts(iContrast ).C);
5366
5467 if numel(betasIndices ) > 1
5568 error(' Supposed to concatenate one beta image per contrast.' );
5669 end
5770
58- % for this beta iamge we identify
71+ % for this beta image we identify
5972 % - which run it came from
6073 % - the exact condition name stored in the SPM.mat
6174 % so they can be saved in a tsv for for "label" and "fold" for MVPA
@@ -70,7 +83,6 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
7083 fileName = validationInputFile(ffxDir , fileName );
7184 beta_maps{iContrast , 1 } = [fileName , ' ,1' ];
7285
73- % while the contrastes (t-maps) are not from the index. They were created
7486 fileName = sprintf(' spmT_%04d .nii' , iContrast );
7587 fileName = validationInputFile(ffxDir , fileName );
7688 t_maps{iContrast , 1 } = [fileName , ' ,1' ];
@@ -81,15 +93,17 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
8193 nameStructure = struct( ...
8294 ' ext' , ' .tsv' , ...
8395 ' suffix' , ' labelfold' , ...
84- ' entities' struct(' sub' , subLabel , ...
85- ' task' , opt .taskName , ...
86- ' space' , opt .space ));
96+ ' entities' , struct(' sub' , subLabel , ...
97+ ' task' , opt .taskName , ...
98+ ' space' , opt .space ));
99+ nameStructure.use_schema = false ;
87100 tsvName = bids .create_filename(nameStructure );
88101
89102 tsvContent = struct(' folds' , runs , ' labels' , {conditions });
90103
91104 spm_save(fullfile(ffxDir , tsvName ), tsvContent );
92105
106+ % TODO in the dev branch make those output filenames "BIDS derivatives" compliant
93107 % beta maps
94108 outputName = [' 4D_beta_' , num2str(funcFWHM ), ' .nii' ];
95109
@@ -101,7 +115,10 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
101115
102116 matlabbatch = setBatch3Dto4D(matlabbatch , t_maps , RT , outputName );
103117
104- saveAndRunWorkflow(matlabbatch , ' concat_betaImg_tMaps' , opt , subLabel );
118+ % TODO temporary: remove on dev branch
119+ if ~opt .dryRun
120+ saveAndRunWorkflow(matlabbatch , ' concat_betaImg_tMaps' , opt , subLabel );
121+ end
105122
106123 removeBetaImgTmaps(t_maps , deleteIndBeta , deleteIndTmaps , ffxDir );
107124
@@ -136,6 +153,7 @@ function removeBetaImgTmaps(t_maps, deleteIndBeta, deleteIndTmaps, ffxDir)
136153 delete(t_maps{iTmap }(1 : end - 2 ));
137154 end
138155 fprintf(' Done. \n\n\n ' );
156+
139157 end
140158
141159end
0 commit comments