Skip to content

Commit

Permalink
feat: add subtract volume operation
Browse files Browse the repository at this point in the history
  • Loading branch information
juancarlosfarah committed Aug 7, 2021
1 parent a4e4e60 commit e61fba2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/matlab/operations/SubtractVolume.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function [status, result] = SubtractVolume(pathToWorkspace, ...
params, ...
config)
%SUBTRACTVOLUME Subtract an input volume from another.
% Uses `fslmaths` with `sub` to subtract the second input volume from the
% first input volume.
%
% Input:
% - pathToWorkspace: Path to the workspace.
% - params: Parameters to be used in the operation.
% - config: Configuration to be used in the operation.
%
% Output:
% - status: Status returned by system call.
% - result: Result returned by system call.

arguments
pathToWorkspace char = '.'
% minuend volume
params.inputVolume1 char
% subtrahend volume
params.inputVolume2 char
% difference volume
params.outputVolume char
% switch on diagnostic messages
config.verbose logical = false
config.v logical = false
end

% normalize if multiple options mean the same thing
verbose = config.verbose || config.v;

fullInputVolume1 = fullfile(pathToWorkspace, params.inputVolume1);
fullInputVolume2 = fullfile(pathToWorkspace, params.inputVolume2);
fullOutputVolume = fullfile(pathToWorkspace, params.outputVolume);

command = 'fslmaths %s -sub %s %s';
sentence = sprintf(command, fullInputVolume1, fullInputVolume2, fullOutputVolume);
[status, result] = CallSystem(sentence, verbose);

end

0 comments on commit e61fba2

Please sign in to comment.