@@ -9,9 +9,9 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
9
9
% :param funcFWHM: smoothing (FWHM) applied to the the normalized EPI
10
10
% :type funcFWHM: (scalar)
11
11
% :param deleteIndBeta: decide to delete beta-maps
12
- % :type funcFWHM : (boolean)
12
+ % :type deleteIndBeta : (boolean)
13
13
% :param deleteIndTmaps: decide to delete t-maps
14
- % :type funcFWHM : (boolean)
14
+ % :type deleteIndTmaps : (boolean)
15
15
%
16
16
% When concatenating betamaps:
17
17
%
@@ -22,12 +22,21 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
22
22
%
23
23
% (C) Copyright 2019 CPP_SPM developers
24
24
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 ;
28
30
end
29
31
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
31
40
32
41
RT = 0 ;
33
42
@@ -41,21 +50,25 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
41
50
42
51
load(fullfile(ffxDir , ' SPM.mat' ));
43
52
44
- contrasts = specifyContrasts(ffxDir , opt .taskName , opt );
53
+ model = spm_jsonread(opt .model .file );
54
+
55
+ contrasts = specifyContrasts(SPM , opt .taskName , model );
45
56
46
57
beta_maps = cell(length(contrasts ), 1 );
47
58
t_maps = cell(length(contrasts ), 1 );
48
59
49
60
% path to beta and t-map files.
61
+ fprintf(1 , ' \n Concatenating the following contrasts:' );
50
62
for iContrast = 1 : length(beta_maps )
51
63
64
+ fprintf(1 , ' \n\t%s ' , contrasts(iContrast ).name);
52
65
betasIndices = find(contrasts(iContrast ).C);
53
66
54
67
if numel(betasIndices ) > 1
55
68
error(' Supposed to concatenate one beta image per contrast.' );
56
69
end
57
70
58
- % for this beta iamge we identify
71
+ % for this beta image we identify
59
72
% - which run it came from
60
73
% - the exact condition name stored in the SPM.mat
61
74
% 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)
70
83
fileName = validationInputFile(ffxDir , fileName );
71
84
beta_maps{iContrast , 1 } = [fileName , ' ,1' ];
72
85
73
- % while the contrastes (t-maps) are not from the index. They were created
74
86
fileName = sprintf(' spmT_%04d .nii' , iContrast );
75
87
fileName = validationInputFile(ffxDir , fileName );
76
88
t_maps{iContrast , 1 } = [fileName , ' ,1' ];
@@ -81,15 +93,17 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
81
93
nameStructure = struct( ...
82
94
' ext' , ' .tsv' , ...
83
95
' 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 ;
87
100
tsvName = bids .create_filename(nameStructure );
88
101
89
102
tsvContent = struct(' folds' , runs , ' labels' , {conditions });
90
103
91
104
spm_save(fullfile(ffxDir , tsvName ), tsvContent );
92
105
106
+ % TODO in the dev branch make those output filenames "BIDS derivatives" compliant
93
107
% beta maps
94
108
outputName = [' 4D_beta_' , num2str(funcFWHM ), ' .nii' ];
95
109
@@ -101,7 +115,10 @@ function bidsConcatBetaTmaps(opt, funcFWHM, deleteIndBeta, deleteIndTmaps)
101
115
102
116
matlabbatch = setBatch3Dto4D(matlabbatch , t_maps , RT , outputName );
103
117
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
105
122
106
123
removeBetaImgTmaps(t_maps , deleteIndBeta , deleteIndTmaps , ffxDir );
107
124
@@ -136,6 +153,7 @@ function removeBetaImgTmaps(t_maps, deleteIndBeta, deleteIndTmaps, ffxDir)
136
153
delete(t_maps{iTmap }(1 : end - 2 ));
137
154
end
138
155
fprintf(' Done. \n\n\n ' );
156
+
139
157
end
140
158
141
159
end
0 commit comments