From e61fba2ee230145ce5ee68c98d9f7cfe0fffd1c3 Mon Sep 17 00:00:00 2001 From: Juan Carlos Farah Date: Sat, 7 Aug 2021 18:31:05 +0200 Subject: [PATCH] feat: add subtract volume operation --- src/matlab/operations/SubtractVolume.m | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/matlab/operations/SubtractVolume.m diff --git a/src/matlab/operations/SubtractVolume.m b/src/matlab/operations/SubtractVolume.m new file mode 100644 index 0000000..8a82da8 --- /dev/null +++ b/src/matlab/operations/SubtractVolume.m @@ -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