|
1 | | -function [mask, outputFile] = createRoi(type, specification, volumeDefiningImage, outputDir, saveImg) |
| 1 | +function [mask, outputFile] = createRoi(varargin) |
2 | 2 | % |
3 | 3 | % Returns a mask to be used as a ROI by ``spm_summarize``. |
4 | 4 | % Can also save the ROI as binary image. |
|
20 | 20 | % |
21 | 21 | % :param type: ``'mask'``, ``'sphere'``, ``'intersection'``, ``'expand'`` |
22 | 22 | % :type type: string |
| 23 | + % |
23 | 24 | % :param volumeDefiningImage: fullpath of the image that will define the space |
24 | 25 | % (resolution, ...) if the ROI is to be saved. |
25 | 26 | % :type volumeDefiningImage: string |
| 27 | + % |
26 | 28 | % :param saveImg: Will save the resulting image as binary mask if set to |
27 | 29 | % ``true`` |
28 | 30 | % :type saveImg: boolean |
| 31 | + % |
29 | 32 | % :param specification: depending on the chosen ``type`` this can be: |
30 | 33 | % |
31 | 34 | % :roiImage: - :string: fullpath of the roi image for ``'mask'`` |
| 35 | + % |
32 | 36 | % :sphere: - :structure: defines the charateristic for ``'sphere'`` |
33 | 37 | % - ``sphere.location``: X Y Z coordinates in millimeters |
34 | 38 | % - ``spehere.radius``: radius in millimeters |
| 39 | + % |
35 | 40 | % :specification: - :structure: defines the charateristic for ``'intersection'`` and ``'expand'`` |
36 | 41 | % - ``sphere.location``: X Y Z coordinates in millimeters |
37 | 42 | % - ``sphere.radius``: radius in millimeters |
|
64 | 69 | % |
65 | 70 | % (C) Copyright 2021 CPP ROI developers |
66 | 71 |
|
67 | | - if nargin < 5 |
68 | | - saveImg = false; |
69 | | - end |
| 72 | + args = inputParser; |
70 | 73 |
|
71 | | - if nargin < 4 |
72 | | - outputDir = pwd; |
73 | | - end |
| 74 | + allowedTypes = @(x) ismember(x, {'mask', 'sphere', 'intersection', 'expand'}); |
74 | 75 |
|
75 | | - if nargin < 3 |
76 | | - volumeDefiningImage = ''; |
77 | | - end |
| 76 | + args.addRequired('type', allowedTypes); |
| 77 | + args.addRequired('specification'); |
| 78 | + args.addOptional('volumeDefiningImage', '', @ischar); |
| 79 | + args.addOptional('outputDir', pwd, @isdir); |
| 80 | + args.addOptional('saveImg', false, @islogical); |
| 81 | + |
| 82 | + args.parse(varargin{:}); |
| 83 | + |
| 84 | + type = args.Results.type; |
| 85 | + specification = args.Results.specification; |
| 86 | + volumeDefiningImage = args.Results.volumeDefiningImage; |
| 87 | + outputDir = args.Results.outputDir; |
| 88 | + saveImg = args.Results.saveImg; |
78 | 89 |
|
79 | 90 | switch type |
80 | 91 |
|
|
0 commit comments