|
| 1 | +function test_suite = test_getInclusiveMask %#ok<*STOUT> |
| 2 | + % (C) Copyright 2020 CPP_SPM developers |
| 3 | + try % assignment of 'localfunctions' is necessary in Matlab >= 2016 |
| 4 | + test_functions = localfunctions(); %#ok<*NASGU> |
| 5 | + catch % no problem; early Matlab versions can use initTestSuite fine |
| 6 | + end |
| 7 | + initTestSuite; |
| 8 | +end |
| 9 | + |
| 10 | +function test_getInclusiveMask_too_many() |
| 11 | + |
| 12 | + subLabel = '01'; |
| 13 | + nodeName = 'run_level'; |
| 14 | + |
| 15 | + opt = setOptions('vismotion', '01'); |
| 16 | + |
| 17 | + opt.verbosity = 2; |
| 18 | + |
| 19 | + opt.model.bm = BidsModel('file', opt.model.file); |
| 20 | + |
| 21 | + opt.model.bm.Nodes{1}.Model.Options.Mask.label{1} = 'brain'; |
| 22 | + opt.model.bm.Nodes{1}.Model.Options.Mask.desc{1} = ''; |
| 23 | + |
| 24 | + opt.space = opt.model.bm.Input.space; |
| 25 | + |
| 26 | + BIDS = getLayout(opt); |
| 27 | + |
| 28 | + assertWarning(@()getInclusiveMask(opt, nodeName, BIDS, subLabel), ... |
| 29 | + 'getInclusiveMask:tooManyMasks'); |
| 30 | + |
| 31 | +end |
| 32 | + |
| 33 | +function test_getInclusiveMask_basic() |
| 34 | + |
| 35 | + subLabel = '01'; |
| 36 | + nodeName = 'run_level'; |
| 37 | + |
| 38 | + opt = setOptions('vismotion', '01'); |
| 39 | + |
| 40 | + opt.model.bm = BidsModel('file', opt.model.file); |
| 41 | + |
| 42 | + opt.space = opt.model.bm.Input.space; |
| 43 | + |
| 44 | + BIDS = getLayout(opt); |
| 45 | + |
| 46 | + mask = getInclusiveMask(opt, nodeName, BIDS, subLabel); |
| 47 | + |
| 48 | + assertEqual(size(mask, 1), 1); |
| 49 | + assertEqual(spm_file(mask, 'filename'), 'sub-01_ses-01_space-IXI549Space_desc-brain_mask.nii'); |
| 50 | + |
| 51 | +end |
| 52 | + |
| 53 | +function test_getInclusiveMask_no_image() |
| 54 | + |
| 55 | + subLabel = '01'; |
| 56 | + nodeName = 'run_level'; |
| 57 | + |
| 58 | + opt = setOptions('vismotion', '01'); |
| 59 | + |
| 60 | + opt.verbosity = 2; |
| 61 | + |
| 62 | + opt.model.bm = BidsModel('file', opt.model.file); |
| 63 | + |
| 64 | + opt.model.bm.Nodes{1}.Model.Options.Mask.desc{1} = 'foo'; |
| 65 | + |
| 66 | + opt.space = opt.model.bm.Input.space; |
| 67 | + |
| 68 | + BIDS = getLayout(opt); |
| 69 | + |
| 70 | + assertWarning(@()getInclusiveMask(opt, nodeName, BIDS, subLabel), ... |
| 71 | + 'checkMaskOrUnderlay:missingMaskOrUnderlay'); |
| 72 | + |
| 73 | +end |
0 commit comments