Skip to content

Commit

Permalink
ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Sep 19, 2024
1 parent b0ffa52 commit 8ee871b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 36 deletions.
6 changes: 3 additions & 3 deletions miss_hit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ copyright_entity: "Wellcome Trust Centre for Neuroimaging"
tab_width: 2

# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
metric "cnest": limit 7
metric "cnest": limit 4
metric "file_length": limit 1000
metric "cyc": limit 22
metric "parameters": limit 9
metric "cyc": limit 20
metric "parameters": limit 6
28 changes: 5 additions & 23 deletions createMontage.m → src/plotting/createMontage.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
% 'cxs', [0 255])
%
%
% Simple function to create a montage / mosaic of multiple slices from a single 3D
% Simple function to create a montage /
% mosaic of multiple slices from a single 3D
% image matrix.
%
% INPUT:
% img - 3D (x,y,z) image matrix
% columns - number of columns in montage (rows are calculated accordingly)
% columns - number of columns in montage
% (rows are calculated accordingly)
% rotate - rotate images 90 deg clockwise? yes = 1; no = 0.
% cmap - figure colormap
% visibility - show figure?
Expand Down Expand Up @@ -116,27 +118,7 @@
montage.whole_img = whole;

Check warning on line 118 in src/plotting/createMontage.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/createMontage.m#L118

Added line #L118 was not covered by tests
end

% Get screen size for plotting - [1 1 w h]
scr_size = get(0, 'ScreenSize');
dist = scr_size(4);
if scr_size(3) < dist
dist = scr_size(3);
end

% Create figure - outerposition = [left bottom width height]
if strcmp(shape, 'max')
f = figure('visible', visibility, ...
'units', 'normalized', ...
'outerposition', [0 0 1 1]);
elseif strcmp(shape, 'square')
f = figure('visible', visibility, ...
'units', 'pixels', ...
'outerposition', [0 0 dist dist]);
else
f = figure('visible', visibility, ...
'units', 'pixels', ...
'outerposition', [0 0 dist dist]);
end
f = initMontageFigure(shape, visibility);

Check warning on line 121 in src/plotting/createMontage.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/createMontage.m#L121

Added line #L121 was not covered by tests

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

Check warning on line 124 in src/plotting/createMontage.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/createMontage.m#L123-L124

Added lines #L123 - L124 were not covered by tests
Expand Down
15 changes: 8 additions & 7 deletions createOverlayMontage.m → src/plotting/createOverlayMontage.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function output = createOverlayMontage(varargin)

% (C) Copyright 2022 bidspm developers
% (C) Copyright 2024 bidspm developers

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

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

if iscell(overlayImg)
for i = 1:numel(overlayImg)
montage_overlay{i} = createMontage(overlayImg{i}, 'columns', columns, ...
montage_overlay{i} = createMontage(overlayImg{i}, ...

Check warning on line 78 in src/plotting/createOverlayMontage.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/createOverlayMontage.m#L76-L78

Added lines #L76 - L78 were not covered by tests
'columns', columns, ...
'rotate', rotate, ...
'cmap', cmap, ...
'visibility', 'off', ...
Expand All @@ -86,7 +85,8 @@
end
else
montage_overlay = {};
montage_overlay{1} = createMontage(overlayImg, 'columns', columns, ...
montage_overlay{1} = createMontage(overlayImg, ...

Check warning on line 88 in src/plotting/createOverlayMontage.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/createOverlayMontage.m#L87-L88

Added lines #L87 - L88 were not covered by tests
'columns', columns, ...
'rotate', rotate, ...
'cmap', cmap, ...
'visibility', 'off', ...
Expand All @@ -103,7 +103,8 @@
bound_whole_bin = bwboundaries(montage_overlay{i}.whole_img);
Nblobs_bin = numel(bound_whole_bin);
for b = 1:Nblobs_bin
p = plot(ax, bound_whole_bin{b, 1}(:, 2), bound_whole_bin{b, 1}(:, 1), 'color', rbgclr, 'LineWidth', 1);
p = plot(ax, bound_whole_bin{b, 1}(:, 2), bound_whole_bin{b, 1}(:, 1), ...

Check warning on line 106 in src/plotting/createOverlayMontage.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/createOverlayMontage.m#L97-L106

Added lines #L97 - L106 were not covered by tests
'color', rbgclr, 'LineWidth', 1);
end
end
end
Expand Down
24 changes: 24 additions & 0 deletions src/plotting/initMontageFigure.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function f = initMontageFigure(shape, visibility)
% (C) Copyright 2024 bidspm developers

scr_size = get(0, 'ScreenSize');
dist = scr_size(4);
if scr_size(3) < dist
dist = scr_size(3);

Check warning on line 7 in src/plotting/initMontageFigure.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/initMontageFigure.m#L4-L7

Added lines #L4 - L7 were not covered by tests
end
% Create figure - outerposition = [left bottom width height]

if strcmp(shape, 'max')
f = figure('visible', visibility, ...

Check warning on line 12 in src/plotting/initMontageFigure.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/initMontageFigure.m#L11-L12

Added lines #L11 - L12 were not covered by tests
'units', 'normalized', ...
'outerposition', [0 0 1 1]);
elseif strcmp(shape, 'square')
f = figure('visible', visibility, ...

Check warning on line 16 in src/plotting/initMontageFigure.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/initMontageFigure.m#L16

Added line #L16 was not covered by tests
'units', 'pixels', ...
'outerposition', [0 0 dist dist]);
else
f = figure('visible', visibility, ...

Check warning on line 20 in src/plotting/initMontageFigure.m

View check run for this annotation

Codecov / codecov/patch

src/plotting/initMontageFigure.m#L20

Added line #L20 was not covered by tests
'units', 'pixels', ...
'outerposition', [0 0 dist dist]);
end
end
13 changes: 10 additions & 3 deletions untitled.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

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

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

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

template_img = fullfile( ...
demos_dir, ...
'bidspm-preproc', 'sub-01', 'func', ...
'sub-01_task-auditory_space-MNI152NLin6Asym_desc-smth8_bold.nii');

template_hdr = spm_vol(template_img);
template = spm_read_vols(template_hdr(1));
Expand All @@ -14,4 +20,5 @@
mask = spm_read_vols(mask_hdr);

% createMontage(template, 'shape', 'square');
createOverlayMontage(template, mask, 'rgbcolors', [255, 0, 0], 'shape', 'square');
createOverlayMontage(template, mask, 'rgbcolors', [255, 0, 0], ...
'shape', 'square');

0 comments on commit 8ee871b

Please sign in to comment.