|
| 1 | +function conImageFile = returnContrastImageFile(varargin) |
| 2 | + % |
| 3 | + % Return the contrast image file for the contrast name the user asked |
| 4 | + % |
| 5 | + % The search is regex based and any string (like 'foo') will be by default |
| 6 | + % regexified (into '^foo$'). |
| 7 | + % |
| 8 | + % USAGE:: |
| 9 | + % |
| 10 | + % conImageFile = returnContrastImageFile(SPM, name, opt) |
| 11 | + % |
| 12 | + % :param SPM: fullpath to SPM.mat file or content of SPM.mat file |
| 13 | + % :type SPM: structure or path |
| 14 | + % |
| 15 | + % :param name: name of the contrast of interest |
| 16 | + % :type name: char |
| 17 | + % |
| 18 | + % :param opt: Options chosen. |
| 19 | + % :type opt: structure |
| 20 | + % |
| 21 | + % See also: printAvailableContrasts, getContrastNb |
| 22 | + % |
| 23 | + |
| 24 | + % (C) Copyright 2022 bidspm developers |
| 25 | + |
| 26 | + defaultOpt = struct('verbosity', 2); |
| 27 | + |
| 28 | + isStructOrFile = @(x) isstruct(x) || exist(x, 'file') == 2; |
| 29 | + |
| 30 | + args = inputParser; |
| 31 | + |
| 32 | + addRequired(args, 'SPM', isStructOrFile); |
| 33 | + addRequired(args, 'name', @ischar); |
| 34 | + addOptional(args, 'opt', defaultOpt, @istruct); |
| 35 | + |
| 36 | + parse(args, varargin{:}); |
| 37 | + |
| 38 | + SPM = args.Results.SPM; |
| 39 | + if ~isstruct(SPM) |
| 40 | + SPM = load(SPM, 'SPM'); |
| 41 | + end |
| 42 | + |
| 43 | + result.name = args.Results.name; |
| 44 | + opt = args.Results.opt; |
| 45 | + |
| 46 | + contrastNb = getContrastNb(result, opt, SPM); |
| 47 | + |
| 48 | + conImageFile = fullfile(SPM.swd, sprintf('con_%04.0f.nii', contrastNb)); |
| 49 | + |
| 50 | +end |
0 commit comments