11function transparentMontage(opt )
22 %
3- % Generate montage with transparent plotting
3+ % Generate montage with transparent plotting using slice_display toolbox.
44 %
55 % USAGE::
66 %
77 % transparentMontage(opt)
88 %
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);
922 %
1023
1124 % (C) Copyright 2025 bidspm developers
1225
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
1432
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());
1656
1757 if any(strcmp(node .Level , {' Run' , ' Subject' }))
1858
@@ -23,24 +63,15 @@ function transparentMontage(opt)
2363 ffxDir = getFFXdir(subLabel , opt );
2464 load(fullfile(ffxDir , ' SPM.mat' ));
2565
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 ));
4071
41- plotTransparentMontage( opt , SPM , subLabel , iRes , iName );
72+ for iName = 1 : numel( optThisSubject .results( iRes ).name)
4273
43- end
74+ plotTransparentMontage( optThisSubject , SPM , subLabel , iRes , iName );
4475
4576 end
4677
@@ -53,13 +84,12 @@ function transparentMontage(opt)
5384end
5485
5586function plotTransparentMontage(opt , SPM , subLabel , iRes , iName )
56-
87+ % Generate a single transparent plot.
88+ %
5789 overwrite = true ;
5890
5991 color_map_folder = fullfile(returnRootDir(), ' lib' , ' brain_colours' , ' mat_maps' );
6092
61- ffxDir = getFFXdir(subLabel , opt );
62-
6393 if opt .results(iRes ).binary
6494 layers = sd_config_layers(' init' , {' truecolor' , ' dual' , ' contour' });
6595 else
@@ -80,14 +110,15 @@ function plotTransparentMontage(opt, SPM, subLabel, iRes, iName)
80110 % - contrast estimates color-coded;
81111 layers(2 ) = setFields(layers(2 ), opt .results(iRes ).sdConfig.layers{2 }, overwrite );
82112
83- name = opt.results.name{iName };
113+ name = opt .results( iRes ) .name{iName };
84114 tmp = struct(' name' , name );
85115 contrastNb = getContrastNb(tmp , opt , SPM );
86116 % keep track if this is a t test or F test
87117 stat = SPM .xCon(contrastNb ).STAT;
88118 contrastNb = sprintf(' %04.0f ' , contrastNb );
89119
90120 % - statistics opacity-coded
121+ ffxDir = getFFXdir(subLabel , opt );
91122 if strcmp(stat , ' T' )
92123 colorFile = spm_select(' FPList' , ffxDir , [' ^con_' contrastNb ' .nii$' ]);
93124 opacityFile = spm_select(' FPList' , ffxDir , [' ^spmT_' contrastNb ' .nii$' ]);
@@ -96,6 +127,7 @@ function plotTransparentMontage(opt, SPM, subLabel, iRes, iName)
96127
97128 load(fullfile(color_map_folder , ' diverging_bwr_iso.mat' )); % #ok<*LOAD>
98129 layers(2 ).color.map = diverging_bwr ;
130+
99131 else
100132 colorFile = spm_select(' FPList' , ffxDir , [' ^ess_' contrastNb ' .nii$' ]);
101133 opacityFile = spm_select(' FPList' , ffxDir , [' ^spmF_' contrastNb ' .nii$' ]);
@@ -134,6 +166,7 @@ function plotTransparentMontage(opt, SPM, subLabel, iRes, iName)
134166 settings.fig_specs.title = title ;
135167
136168 %% Display the layers
169+ settings .slice .zmm ;
137170 [~ , ~ , h_figure ] = sd_display(layers , settings );
138171
139172 outputFile = fullfile(ffxDir , [contrastNb ' _' name ' .png' ]);
0 commit comments