1
1
function transparentMontage(opt )
2
2
%
3
- % Generate montage with transparent plotting
3
+ % Generate montage with transparent plotting using slice_display toolbox.
4
4
%
5
5
% USAGE::
6
6
%
7
7
% transparentMontage(opt)
8
8
%
9
+ % EXAMPLE::
10
+ %
11
+ % opt.pipeline.type = 'stats';
12
+ %
13
+ % opt.dir.derivatives = fullfile(this_dir, 'outputs', 'derivatives');
14
+ % opt.dir.preproc = fullfile(opt.dir.derivatives, 'bidspm-preproc');
15
+ % opt.model.file = fullfile(this_dir, 'models', 'model-MoAE_smdl.json');
16
+ %
17
+ % opt.subjects = {'01'};
18
+ %
19
+ % opt = checkOptions(opt);
20
+ %
21
+ % transparentMontage(opt);
9
22
%
10
23
11
24
% (C) Copyright 2025 bidspm developers
12
25
13
- for i_node = 1 : numel(opt .model .bm .Nodes )
26
+ bm = opt .model .bm ;
27
+
28
+ modelResults = bm .getResults();
29
+ if ~isempty(modelResults )
30
+ opt.results = modelResults ;
31
+ end
14
32
15
- node = opt.model.bm.Nodes{i_node };
33
+ % loop through the steps to compute for each contrast mentioned for each node
34
+ for iRes = 1 : length(opt .results )
35
+
36
+ node = bm .get_nodes(' Name' , opt .results(iRes ).nodeName);
37
+
38
+ if isempty(node )
39
+
40
+ id = ' unknownModelNode' ;
41
+ msg = sprintf(' no Node named %s in model\n %s .' , ...
42
+ opt .results(iRes ).nodeName, ...
43
+ opt .model .file );
44
+ logger(' WARNING' , msg , ' id' , id , ' filename' , mfilename(), ' options' , opt );
45
+ continue
46
+ end
47
+
48
+ opt .results(iRes );
49
+
50
+ if ~isfield(opt .results(iRes ), ' montage' ) || ~opt .results(iRes ).montage.do
51
+ continue
52
+ end
53
+
54
+ msg = sprintf(' \n PROCESSING NODE: %s\n ' , node .Name );
55
+ logger(' INFO' , msg , ' options' , opt , ' filename' , mfilename());
16
56
17
57
if any(strcmp(node .Level , {' Run' , ' Subject' }))
18
58
@@ -23,24 +63,15 @@ function transparentMontage(opt)
23
63
ffxDir = getFFXdir(subLabel , opt );
24
64
load(fullfile(ffxDir , ' SPM.mat' ));
25
65
26
- for iRes = 1 : numel(node .Model .Software .bidspm .Results )
27
-
28
- opt.results = node.Model.Software.bidspm.Results{iRes };
29
-
30
- if ~isfield(opt .results , ' montage' ) || ~opt .results .montage .do
31
- continue
32
- end
33
-
34
- % set defaults
35
- [opt , ~ ] = checkMontage(opt , iRes , node , struct([]), subLabel );
36
- opt = checkOptions(opt );
37
- opt .results(iRes ).montage = setMontage(opt .results(iRes ));
38
-
39
- for iName = 1 : numel(opt .results .name )
66
+ % set defaults
67
+ % TODO check plotting is done on the right background
68
+ [optThisSubject , ~ ] = checkMontage(opt , iRes , node , struct([]), subLabel );
69
+ optThisSubject = checkOptions(optThisSubject );
70
+ optThisSubject .results(iRes ).montage = setMontage(optThisSubject .results(iRes ));
40
71
41
- plotTransparentMontage( opt , SPM , subLabel , iRes , iName );
72
+ for iName = 1 : numel( optThisSubject .results( iRes ).name)
42
73
43
- end
74
+ plotTransparentMontage( optThisSubject , SPM , subLabel , iRes , iName );
44
75
45
76
end
46
77
@@ -53,13 +84,12 @@ function transparentMontage(opt)
53
84
end
54
85
55
86
function plotTransparentMontage(opt , SPM , subLabel , iRes , iName )
56
-
87
+ % Generate a single transparent plot.
88
+ %
57
89
overwrite = true ;
58
90
59
91
color_map_folder = fullfile(returnRootDir(), ' lib' , ' brain_colours' , ' mat_maps' );
60
92
61
- ffxDir = getFFXdir(subLabel , opt );
62
-
63
93
if opt .results(iRes ).binary
64
94
layers = sd_config_layers(' init' , {' truecolor' , ' dual' , ' contour' });
65
95
else
@@ -80,14 +110,15 @@ function plotTransparentMontage(opt, SPM, subLabel, iRes, iName)
80
110
% - contrast estimates color-coded;
81
111
layers(2 ) = setFields(layers(2 ), opt .results(iRes ).sdConfig.layers{2 }, overwrite );
82
112
83
- name = opt.results.name{iName };
113
+ name = opt .results( iRes ) .name{iName };
84
114
tmp = struct(' name' , name );
85
115
contrastNb = getContrastNb(tmp , opt , SPM );
86
116
% keep track if this is a t test or F test
87
117
stat = SPM .xCon(contrastNb ).STAT;
88
118
contrastNb = sprintf(' %04.0f ' , contrastNb );
89
119
90
120
% - statistics opacity-coded
121
+ ffxDir = getFFXdir(subLabel , opt );
91
122
if strcmp(stat , ' T' )
92
123
colorFile = spm_select(' FPList' , ffxDir , [' ^con_' contrastNb ' .nii$' ]);
93
124
opacityFile = spm_select(' FPList' , ffxDir , [' ^spmT_' contrastNb ' .nii$' ]);
@@ -96,6 +127,7 @@ function plotTransparentMontage(opt, SPM, subLabel, iRes, iName)
96
127
97
128
load(fullfile(color_map_folder , ' diverging_bwr_iso.mat' )); % #ok<*LOAD>
98
129
layers(2 ).color.map = diverging_bwr ;
130
+
99
131
else
100
132
colorFile = spm_select(' FPList' , ffxDir , [' ^ess_' contrastNb ' .nii$' ]);
101
133
opacityFile = spm_select(' FPList' , ffxDir , [' ^spmF_' contrastNb ' .nii$' ]);
@@ -134,6 +166,7 @@ function plotTransparentMontage(opt, SPM, subLabel, iRes, iName)
134
166
settings.fig_specs.title = title ;
135
167
136
168
%% Display the layers
169
+ settings .slice .zmm ;
137
170
[~ , ~ , h_figure ] = sd_display(layers , settings );
138
171
139
172
outputFile = fullfile(ffxDir , [contrastNb ' _' name ' .png' ]);
0 commit comments