Skip to content

Commit cc9db49

Browse files
committed
resize ALI mask in function of chosen options
1 parent f78c17a commit cc9db49

File tree

6 files changed

+80
-14
lines changed

6 files changed

+80
-14
lines changed

src/batches/lesion/setBatchLesionAbnormalitiesDetection.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
outliers_detection = opt.toolbox.ALI.outliers_detection;
2323

24+
outliers_detection.step3mask{1} = resizeAliMask(opt);
25+
2426
for i = 1:size(images, 1)
2527

2628
% 1. Define smoothed segmented tissue images of patients

src/defaults/ALI_my_defaults.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@
5454
% Specify lambda parameter
5555
defaults.toolbox.ALI.outliers_detection.step3tissue.step3Lambda = -4;
5656

57-
% specify lesion mask
58-
defaults.toolbox.ALI.outliers_detection.step3mask{1} = fullfile(spmDir, ...
59-
'toolbox', ...
60-
'ALI', ...
61-
'Mask_image', ...
62-
'mask_controls_vox2mm.nii');
63-
6457
% threshold for the mask
6558
defaults.toolbox.ALI.outliers_detection.step3mask_thr = 0;
6659
% binary lesion: threshold U

src/infra/resizeAliMask.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function aliMask = resizeAliMask(opt)
2+
%
3+
% USAGE::
4+
%
5+
% aliMask = resizeAliMask(opt)
6+
%
7+
%
8+
% (C) Copyright 2022 CPP_SPM developers
9+
aliMask = fullfile(spm('dir'), 'toolbox', 'ALI', 'Mask_image', 'mask_controls_vox2mm.nii');
10+
11+
if opt.toolbox.ALI.unified_segmentation.step1vox ~= 2
12+
13+
voxdim = repmat(opt.toolbox.ALI.unified_segmentation.step1vox, [3, 1]);
14+
bb = nan(2, 3);
15+
ismask = true;
16+
resize_img(aliMask, voxdim, bb, ismask);
17+
18+
aliMask = fullfile(spm('dir'), ...
19+
'toolbox', ...
20+
'ALI', ...
21+
'Mask_image', ...
22+
['mask_controls_vox' num2str(voxdim(1)) 'mm.nii']);
23+
24+
movefile(fullfile(spm('dir'), 'toolbox', 'ALI', 'Mask_image', 'rmask_controls_vox2mm.nii'), ...
25+
aliMask);
26+
end
27+
28+
end

src/workflows/lesion/bidsLesionAbnormalitiesDetection.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ function bidsLesionAbnormalitiesDetection(opt)
5050
filter = anatImage.entities;
5151
filter.modality = 'anat';
5252
filter.suffix = 'probseg';
53-
filter.desc = 'smth8';
53+
54+
fwhm = opt.toolbox.ALI.unified_segmentation.step1fwhm;
55+
filter.desc = ['smth' num2str(fwhm)];
5456

5557
for i = 1:numel(labels)
5658

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function test_suite = test_resizeAliMask %#ok<*STOUT>
2+
% (C) Copyright 2021 CPP_SPM developers
3+
4+
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
5+
test_functions = localfunctions(); %#ok<*NASGU>
6+
catch % no problem; early Matlab versions can use initTestSuite fine
7+
end
8+
initTestSuite;
9+
end
10+
11+
function test_resizeAliMask_basic()
12+
13+
subLabel = '01';
14+
opt = setOptions('MoAE', subLabel, 'useRaw', true);
15+
16+
if isGithubCi
17+
return
18+
else
19+
opt = setFields(opt, ALI_my_defaults());
20+
end
21+
22+
opt.toolbox.ALI.unified_segmentation.step1vox = 1.2;
23+
aliMask = resizeAliMask(opt);
24+
25+
expected = fullfile(spm('dir'), ...
26+
'toolbox', ...
27+
'ALI', ...
28+
'Mask_image', ...
29+
'mask_controls_vox1.2mm.nii');
30+
31+
assertEqual(aliMask, expected);
32+
assertEqual(exist(expected, 'file'), 2);
33+
34+
delete(aliMask);
35+
36+
end

tests/tests_batches/preproc/test_setBatchLesionSegmentation.m renamed to tests/tests_batches/lesion/test_setBatchLesionSegmentation.m

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
% (C) Copyright 2021 CPP_SPM developers
2-
31
function test_suite = test_setBatchLesionSegmentation %#ok<*STOUT>
2+
% (C) Copyright 2021 CPP_SPM developers
3+
44
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
55
test_functions = localfunctions(); %#ok<*NASGU>
66
catch % no problem; early Matlab versions can use initTestSuite fine
@@ -14,29 +14,34 @@ function test_setBatchLesionSegmentation_basic()
1414

1515
opt = setOptions('MoAE', subLabel, 'useRaw', true);
1616

17-
if not(isfield(opt.toolbox, 'ALI'))
17+
if isGithubCi
1818
return
19+
else
20+
opt = setFields(opt, ALI_my_defaults());
1921
end
2022

2123
[BIDS, opt] = getData(opt, opt.dir.input);
2224

2325
matlabbatch = {};
2426
matlabbatch = setBatchLesionSegmentation(matlabbatch, BIDS, opt, subLabel);
2527

26-
unified_segmentation.step1data{1} = fullfile(getMoaeDir(), 'inputs', 'raw', ...
28+
unified_segmentation.step1data{1} = fullfile(getMoaeDir(), ...
29+
'inputs', ...
30+
'raw', ...
2731
['sub-' subLabel], ...
2832
'anat', ...
2933
'sub-01_T1w.nii');
3034
unified_segmentation.step1prior = {fullfile(spm('dir'), ...
31-
'toolbox', 'ALI', ...
35+
'toolbox', ...
36+
'ALI', ...
3237
'Priors_extraClass', ...
3338
'wc4prior0.nii')};
3439
unified_segmentation.step1niti = 2;
3540
unified_segmentation.step1thr_prob = 0.3330;
3641
unified_segmentation.step1thr_size = 0.8000;
3742
unified_segmentation.step1coregister = 1;
3843
unified_segmentation.step1mask = {''};
39-
unified_segmentation.step1vox = 1;
44+
unified_segmentation.step1vox = 2;
4045
unified_segmentation.step1fwhm = [8 8 8];
4146

4247
assertEqual(matlabbatch{1}.spm.tools.ali.unified_segmentation, ...

0 commit comments

Comments
 (0)