diff --git a/src/matlab/operations/ProcessAnatomicalImage.m b/src/matlab/operations/ProcessAnatomicalImage.m index 522f9d9..5dec67c 100644 --- a/src/matlab/operations/ProcessAnatomicalImage.m +++ b/src/matlab/operations/ProcessAnatomicalImage.m @@ -1,4 +1,4 @@ -function [status, result] = ProcessAnatomicalImage(pathToWorkspace, config) +function [status, result, sentence] = ProcessAnatomicalImage(pathToWorkspace, config) %PROCESSANATOMICALIMAGE Processes an anatomical image using `fsl_anat`. % Uses `fsl_anat` to process an anatomical image. % diff --git a/test/operations/ProcessAnatomicalImageTest.m b/test/operations/ProcessAnatomicalImageTest.m new file mode 100644 index 0000000..cff8cea --- /dev/null +++ b/test/operations/ProcessAnatomicalImageTest.m @@ -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