Skip to content

Commit 32aa8ef

Browse files
committed
refactor
1 parent 108fac4 commit 32aa8ef

File tree

4 files changed

+87
-89
lines changed

4 files changed

+87
-89
lines changed

demos/MoAE/moae_03_slice_display.m

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,25 @@
3131

3232
opt.model.file = fullfile(this_dir, 'models', 'model-MoAE_smdl.json');
3333

34+
opt.subjects = [subLabel];
35+
3436
% read the model
3537
opt = checkOptions(opt);
3638

37-
opt.results = opt.model.bm.Nodes{1}.Model.Software.bidspm.Results{1};
39+
iRes = 1;
40+
41+
opt.results = opt.model.bm.Nodes{iRes}.Model.Software.bidspm.Results{1};
42+
43+
node = opt.model.bm.Nodes{iRes};
44+
[opt, BIDS] = checkMontage(opt, iRes, node, struct([]), subLabel);
3845

3946
opt = checkOptions(opt);
4047

48+
opt.results(iRes).montage = setMontage(opt.results(iRes));
49+
4150
% we get the con image to extract data
4251
ffxDir = getFFXdir(subLabel, opt);
52+
4353
maskImage = spm_select('FPList', ffxDir, '^.*_mask.nii$');
4454
bf = bids.File(spm_file(maskImage, 'filename'));
4555
conImage = spm_select('FPList', ffxDir, ['^con_' bf.entities.label '.nii$']);
@@ -48,9 +58,12 @@
4858
layers = sd_config_layers('init', {'truecolor', 'dual', 'contour'});
4959

5060
% Layer 1: Anatomical map
51-
[anat_normalized_file, anatRange] = return_normalized_anat_file(opt, subLabel);
52-
layers(1).color.file = anat_normalized_file;
53-
layers(1).color.range = [0 anatRange(2)];
61+
layers(1).color.file = opt.results(iRes).montage.background{1};
62+
63+
hdr = spm_vol(layers(1).color.file);
64+
[max_val, min_val] = slover('volmaxmin', hdr);
65+
layers(1).color.range = [0 max_val];
66+
5467
layers(1).color.map = gray(256);
5568

5669
%% Layer 2: Dual-coded layer

demos/MoAE/return_normalized_anat_file.m

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/stats/results/checkMontage.m

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
function [opt, BIDS] = checkMontage(opt, iRes, node, BIDS, subLabel)
2+
%
3+
% Check values for create a slice montage.
4+
%
5+
% Set default values if they are missing.
6+
%
7+
% USAGE::
8+
%
9+
% [opt, BIDS] = checkMontage(opt, iRes, node, BIDS, subLabel)
10+
%
11+
%
12+
13+
% (C) Copyright 2019 bidspm developers
14+
15+
if nargin < 4
16+
BIDS = '';
17+
subLabel = '';
18+
end
19+
20+
if isfield(opt.results(iRes), 'montage') && any(opt.results(iRes).montage.do)
21+
22+
background = opt.results(iRes).montage.background;
23+
24+
% TODO refactor with getInclusiveMask
25+
if isstruct(background)
26+
27+
if ismember(lower(node.Level), {'run', 'session', 'subject'})
28+
29+
if isempty(BIDS)
30+
BIDS = bids.layout(opt.dir.preproc, ...
31+
'use_schema', false, ...
32+
'index_dependencies', false, ...
33+
'filter', struct('sub', {opt.subjects}));
34+
end
35+
36+
background.sub = subLabel;
37+
background.space = opt.space;
38+
file = bids.query(BIDS, 'data', background);
39+
40+
if iscell(file)
41+
if isempty(file)
42+
% let checkMaskOrUnderlay figure it out
43+
file = '';
44+
45+
elseif numel(file) == 1
46+
file = file{1};
47+
48+
elseif numel(file) > 1
49+
file = file{1};
50+
51+
msg = sprintf('More than 1 overlay image found for %s.\n Taking the first one.', ...
52+
bids.internal.create_unordered_list(background));
53+
id = 'tooManyMontageBackground';
54+
logger('WARNING', msg, 'id', id, 'options', opt, 'filename', mfilename());
55+
end
56+
57+
end
58+
59+
background = file;
60+
61+
end
62+
63+
end
64+
65+
background = checkMaskOrUnderlay(background, opt, 'background');
66+
opt.results(iRes).montage.background = background;
67+
68+
end
69+
70+
end

src/workflows/stats/bidsResults.m

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -547,62 +547,3 @@
547547
matlabbatch{end}.result = result;
548548

549549
end
550-
551-
function [opt, BIDS] = checkMontage(opt, iRes, node, BIDS, subLabel)
552-
553-
if nargin < 4
554-
BIDS = '';
555-
subLabel = '';
556-
end
557-
558-
if isfield(opt.results(iRes), 'montage') && any(opt.results(iRes).montage.do)
559-
560-
background = opt.results(iRes).montage.background;
561-
562-
% TODO refactor with getInclusiveMask
563-
if isstruct(background)
564-
565-
if ismember(lower(node.Level), {'run', 'session', 'subject'})
566-
567-
if isempty(BIDS)
568-
BIDS = bids.layout(opt.dir.preproc, ...
569-
'use_schema', false, ...
570-
'index_dependencies', false, ...
571-
'filter', struct('sub', {opt.subjects}));
572-
end
573-
574-
background.sub = subLabel;
575-
background.space = opt.space;
576-
file = bids.query(BIDS, 'data', background);
577-
578-
if iscell(file)
579-
if isempty(file)
580-
% let checkMaskOrUnderlay figure it out
581-
file = '';
582-
583-
elseif numel(file) == 1
584-
file = file{1};
585-
586-
elseif numel(file) > 1
587-
file = file{1};
588-
589-
msg = sprintf('More than 1 overlay image found for %s.\n Taking the first one.', ...
590-
bids.internal.create_unordered_list(background));
591-
id = 'tooManyMontageBackground';
592-
logger('WARNING', msg, 'id', id, 'options', opt, 'filename', mfilename());
593-
end
594-
595-
end
596-
597-
background = file;
598-
599-
end
600-
601-
end
602-
603-
background = checkMaskOrUnderlay(background, opt, 'background');
604-
opt.results(iRes).montage.background = background;
605-
606-
end
607-
608-
end

0 commit comments

Comments
 (0)