Skip to content

Commit 8ee871b

Browse files
committed
ref
1 parent b0ffa52 commit 8ee871b

File tree

5 files changed

+50
-36
lines changed

5 files changed

+50
-36
lines changed

miss_hit.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ copyright_entity: "Wellcome Trust Centre for Neuroimaging"
3636
tab_width: 2
3737

3838
# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
39-
metric "cnest": limit 7
39+
metric "cnest": limit 4
4040
metric "file_length": limit 1000
41-
metric "cyc": limit 22
42-
metric "parameters": limit 9
41+
metric "cyc": limit 20
42+
metric "parameters": limit 6

createMontage.m renamed to src/plotting/createMontage.m

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
% 'cxs', [0 255])
1212
%
1313
%
14-
% Simple function to create a montage / mosaic of multiple slices from a single 3D
14+
% Simple function to create a montage /
15+
% mosaic of multiple slices from a single 3D
1516
% image matrix.
1617
%
1718
% INPUT:
1819
% img - 3D (x,y,z) image matrix
19-
% columns - number of columns in montage (rows are calculated accordingly)
20+
% columns - number of columns in montage
21+
% (rows are calculated accordingly)
2022
% rotate - rotate images 90 deg clockwise? yes = 1; no = 0.
2123
% cmap - figure colormap
2224
% visibility - show figure?
@@ -116,27 +118,7 @@
116118
montage.whole_img = whole;
117119
end
118120

119-
% Get screen size for plotting - [1 1 w h]
120-
scr_size = get(0, 'ScreenSize');
121-
dist = scr_size(4);
122-
if scr_size(3) < dist
123-
dist = scr_size(3);
124-
end
125-
126-
% Create figure - outerposition = [left bottom width height]
127-
if strcmp(shape, 'max')
128-
f = figure('visible', visibility, ...
129-
'units', 'normalized', ...
130-
'outerposition', [0 0 1 1]);
131-
elseif strcmp(shape, 'square')
132-
f = figure('visible', visibility, ...
133-
'units', 'pixels', ...
134-
'outerposition', [0 0 dist dist]);
135-
else
136-
f = figure('visible', visibility, ...
137-
'units', 'pixels', ...
138-
'outerposition', [0 0 dist dist]);
139-
end
121+
f = initMontageFigure(shape, visibility);
140122

141123
ax = subplot(1, 1, 1);
142124
im = imagesc(ax, montage.whole_img);

createOverlayMontage.m renamed to src/plotting/createOverlayMontage.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function output = createOverlayMontage(varargin)
22

3-
% (C) Copyright 2022 bidspm developers
3+
% (C) Copyright 2024 bidspm developers
44

55
% fmrwhy_util_createOverlayMontage(tsnr_img{i}, overlayImg, 9, 1, '', ...
66
% 'hot', 'off', 'max', [0 250], [33, 168, 10], tsnr_saveAss{i});
@@ -55,9 +55,7 @@
5555
'cxs', cxs);
5656

5757
% Create figures with background montage and overlaid masks
58-
f = figure('units', 'normalized', ...
59-
'outerposition', [0 0 1 1], ...
60-
'visible', visibility);
58+
f = initMontageFigure(shape, visibility);
6159
imagesc(montage_template.whole_img);
6260
colormap(cmap);
6361
if ~isempty(cxs)
@@ -77,7 +75,8 @@
7775

7876
if iscell(overlayImg)
7977
for i = 1:numel(overlayImg)
80-
montage_overlay{i} = createMontage(overlayImg{i}, 'columns', columns, ...
78+
montage_overlay{i} = createMontage(overlayImg{i}, ...
79+
'columns', columns, ...
8180
'rotate', rotate, ...
8281
'cmap', cmap, ...
8382
'visibility', 'off', ...
@@ -86,7 +85,8 @@
8685
end
8786
else
8887
montage_overlay = {};
89-
montage_overlay{1} = createMontage(overlayImg, 'columns', columns, ...
88+
montage_overlay{1} = createMontage(overlayImg, ...
89+
'columns', columns, ...
9090
'rotate', rotate, ...
9191
'cmap', cmap, ...
9292
'visibility', 'off', ...
@@ -103,7 +103,8 @@
103103
bound_whole_bin = bwboundaries(montage_overlay{i}.whole_img);
104104
Nblobs_bin = numel(bound_whole_bin);
105105
for b = 1:Nblobs_bin
106-
p = plot(ax, bound_whole_bin{b, 1}(:, 2), bound_whole_bin{b, 1}(:, 1), 'color', rbgclr, 'LineWidth', 1);
106+
p = plot(ax, bound_whole_bin{b, 1}(:, 2), bound_whole_bin{b, 1}(:, 1), ...
107+
'color', rbgclr, 'LineWidth', 1);
107108
end
108109
end
109110
end

src/plotting/initMontageFigure.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function f = initMontageFigure(shape, visibility)
2+
% (C) Copyright 2024 bidspm developers
3+
4+
scr_size = get(0, 'ScreenSize');
5+
dist = scr_size(4);
6+
if scr_size(3) < dist
7+
dist = scr_size(3);
8+
end
9+
% Create figure - outerposition = [left bottom width height]
10+
11+
if strcmp(shape, 'max')
12+
f = figure('visible', visibility, ...
13+
'units', 'normalized', ...
14+
'outerposition', [0 0 1 1]);
15+
elseif strcmp(shape, 'square')
16+
f = figure('visible', visibility, ...
17+
'units', 'pixels', ...
18+
'outerposition', [0 0 dist dist]);
19+
else
20+
f = figure('visible', visibility, ...
21+
'units', 'pixels', ...
22+
'outerposition', [0 0 dist dist]);
23+
end
24+
end

untitled.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33

44
bidspm_dir = '/home/remi/github/cpp-lln-lab/bidspm';
55

6-
overlay_img = fullfile(bidspm_dir, 'demos/MoAE/outputs/derivatives/bidspm-stats/sub-01/task-auditory_space-MNI152NLin6Asym_FWHM-8/mask.nii');
6+
demos_dir = fullfile(bidspm_dir, 'demos/MoAE/outputs/derivatives/');
77

8-
template_img = fullfile(bidspm_dir, 'demos/MoAE/outputs/derivatives/bidspm-preproc/sub-01/func/sub-01_task-auditory_space-MNI152NLin6Asym_desc-smth8_bold.nii');
8+
overlay_img = fullfile(demos_dir, ...
9+
'bidspm-stats/sub-01/task-auditory_space-MNI152NLin6Asym_FWHM-8/mask.nii');
10+
11+
template_img = fullfile( ...
12+
demos_dir, ...
13+
'bidspm-preproc', 'sub-01', 'func', ...
14+
'sub-01_task-auditory_space-MNI152NLin6Asym_desc-smth8_bold.nii');
915

1016
template_hdr = spm_vol(template_img);
1117
template = spm_read_vols(template_hdr(1));
@@ -14,4 +20,5 @@
1420
mask = spm_read_vols(mask_hdr);
1521

1622
% createMontage(template, 'shape', 'square');
17-
createOverlayMontage(template, mask, 'rgbcolors', [255, 0, 0], 'shape', 'square');
23+
createOverlayMontage(template, mask, 'rgbcolors', [255, 0, 0], ...
24+
'shape', 'square');

0 commit comments

Comments
 (0)