|
| 1 | +function test_suite = test_isBinaryMask %#ok<*STOUT> |
| 2 | + % (C) Copyright 2022 CPP ROI 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_isBinaryMask_true() |
| 11 | + |
| 12 | + roiFilename = prepareRoiAndVolumeDefiningImage(); |
| 13 | + isBinaryMask(roiFilename); |
| 14 | + |
| 15 | +end |
| 16 | + |
| 17 | +function test_isBinaryMask_false() |
| 18 | + |
| 19 | + [~, zMap] = prepareRoiAndVolumeDefiningImage(); |
| 20 | + assertExceptionThrown(@()isBinaryMask(zMap), 'isBinaryMask:notBinaryImage'); |
| 21 | + |
| 22 | +end |
| 23 | + |
| 24 | +function value = thisDir() |
| 25 | + value = fullfile(fileparts(mfilename('fullpath'))); |
| 26 | +end |
| 27 | + |
| 28 | +function value = demoDir() |
| 29 | + |
| 30 | + value = fullfile(thisDir(), '..', 'demos', 'roi', 'inputs'); |
| 31 | + |
| 32 | + if exist(fullfile(value, 'TStatistic.nii'), 'file') == 0 |
| 33 | + gunzip(fullfile(value, '*.gz')); |
| 34 | + end |
| 35 | + |
| 36 | +end |
| 37 | + |
| 38 | +function [roiFilename, zMap] = prepareRoiAndVolumeDefiningImage() |
| 39 | + |
| 40 | + zMap = fullfile(demoDir(), 'space-MNI_atlas-neurosynth_label-visualMotion_probseg.nii'); |
| 41 | + |
| 42 | + roiFilename = fullfile(demoDir(), ... |
| 43 | + 'space-MNI_atlas-neurosynth_label-visualMotion_desc-p10pt00_mask.nii'); |
| 44 | + |
| 45 | + if exist(roiFilename, 'file') == 2 |
| 46 | + |
| 47 | + else |
| 48 | + |
| 49 | + zMap = renameNeuroSynth(zMap); |
| 50 | + threshold = 10; |
| 51 | + roiFilename = thresholdToMask(zMap, threshold); |
| 52 | + |
| 53 | + end |
| 54 | + |
| 55 | +end |
0 commit comments