-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from juancarlosfarah/22/addProcessAnatomicalIm…
…ageTest feat: add test for processanatomicalimage
- Loading branch information
Showing
2 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
%% main function to generate tests | ||
|
||
function tests = ProcessAnatomicalImageTest | ||
tests = functiontests(localfunctions); | ||
end | ||
|
||
%% test functions | ||
|
||
function TestDefaultCommand(testCase) | ||
|
||
% specify (arbitrary) input files | ||
pathToWorkspace = '.'; | ||
inputFile = 'sample.nii'; | ||
outputFolder = 'outputdir'; | ||
|
||
% these two steps allow us to pass a struct to the operation | ||
config = struct('inputFile', inputFile, ... | ||
'outputFolder', outputFolder, ... | ||
'clobber', true, ... | ||
'noReg', true, ... | ||
'noNonLinReg', true, ... | ||
'noSeg', true, ... | ||
'weakBias', true, ... | ||
'noReorient', true, ... | ||
'noCrop', true, ... | ||
'verbose', false); | ||
configCell = namedargs2cell(config); | ||
|
||
% run the operation to get the actual command | ||
[~, ~, actualCommand] = ProcessAnatomicalImage(pathToWorkspace, configCell{:}); | ||
|
||
% this is the expected default command | ||
inputfile = fullfile(pathToWorkspace, inputFile); | ||
outputdirectory = fullfile(pathToWorkspace, outputFolder); | ||
expectedCommand = ... | ||
sprintf('fsl_anat --clobber --noreg --nononlinreg --noseg --weakbias --noreorient --nocrop -i %s -o %s', ... | ||
inputfile, outputdirectory); | ||
|
||
% verify equality | ||
verifyEqual(testCase, actualCommand, expectedCommand); | ||
|
||
end | ||
|
||
function TestSpecifyingAllOptions(testCase) | ||
|
||
% specify (arbitrary) input files | ||
pathToWorkspace = '.'; | ||
inputFile = 'sample.nii'; | ||
outputFolder = 'outputdir'; | ||
|
||
% these two steps allow us to pass a struct to the operation | ||
config = struct('inputFile', inputFile, ... | ||
'outputFolder', outputFolder, ... | ||
'clobber', false, ... | ||
'noReg', false, ... | ||
'noNonLinReg', false, ... | ||
'noSeg', false, ... | ||
'weakBias', false, ... | ||
'noReorient', false, ... | ||
'noCrop', false, ... | ||
'verbose', true); | ||
configCell = namedargs2cell(config); | ||
|
||
% run the operation to get the actual command | ||
[~, ~, actualCommand] = ProcessAnatomicalImage(pathToWorkspace, configCell{:}); | ||
|
||
% this is the expected default command | ||
inputfile = fullfile(pathToWorkspace, inputFile); | ||
outputdirectory = fullfile(pathToWorkspace, outputFolder); | ||
expectedCommand = sprintf('fsl_anat -i %s -o %s', inputfile, outputdirectory); | ||
|
||
% verify equality | ||
verifyEqual(testCase, actualCommand, expectedCommand); | ||
|
||
end | ||
|
||
%% optional file fixtures | ||
|
||
function setupOnce(testCase) | ||
% do not change function name | ||
% use to set a new path, for example | ||
end | ||
|
||
function teardownOnce(testCase) | ||
% do not change function name | ||
% use to change back to original path, for example | ||
end | ||
|
||
%% optional fresh fixtures | ||
|
||
function setup(testCase) | ||
% do not change function name | ||
% use to open a figure, for example | ||
end | ||
|
||
function teardown(testCase) | ||
% do not change function name | ||
% use to close a figure, for example | ||
end |