Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/atlas/extractRoiByLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
%
% :param sourceImage: discrete segmentation source image fullpath
% :type sourceImage: string
%
% :param labelStruct: 1x1 structure with fields ``ROI`` for the ROI name
% and ``label`` for the corresponding label
% :type labelStruct: structure
Expand Down
37 changes: 30 additions & 7 deletions src/atlas/extractRoiFromAtlas.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function roiImage = extractRoiFromAtlas(outputDir, atlasName, roiName, hemisphere)
function roiImage = extractRoiFromAtlas(varargin)
%
% Outputs a ROI image and side car json for a given atlas, roi name (as
% defined in the look up table of that atlas) and a hemisphere
Expand All @@ -8,22 +8,45 @@
% roiImage = extractRoiFromAtlas(outputDir, atlasName, roiName, hemisphere)
%
% :param outputDir:
% :param atlasName: ``'wang'``, ``'visfatlas'``, ``'neuromorphometrics'``, ``'hcpex'``
% :param roiName: run ``getLookUpTable(atlasName)`` to get a list of ROI names to choose from
% :param hemisphere: ``L`` or ``R``
% :type outputDir: string
%
% :param atlasName: ``'wang'``, ``'visfatlas'``, ``'neuromorphometrics'``, ``'hcpex'``
% :type atlasName: string
%
% :param roiName: run ``getLookUpTable(atlasName)`` to get a list of ROI names to choose from
% :type roiName: string
%
% :param hemisphere: ``L`` or ``R``
% :type hemisphere: string
%
%
% EXAMPLE::
%
% outputDir = pwd;
% atlasName = 'neuromorphometrics';
% roiName = 'PCu precuneus';
% hemisphere = 'R';
%
% extractRoiFromAtlas(outputDir, atlasName, roiName, hemisphere)
%

% (C) Copyright 2021 CPP ROI developers

if ~ismember(hemisphere, {'L', 'R'})
isChar = @(x) ischar(x);

error('\n Hemisphere label %s not valid, try "L" or "R"', hemisphere);
args = inputParser;

end
addRequired(args, 'outputDir', isChar);
addRequired(args, 'atlasName', @isAKnownAtlas);
addRequired(args, 'roiName', isChar);
addRequired(args, 'hemisphere', @(x) ismember(x, {'L', 'R'}));

parse(args, varargin{:});

outputDir = args.Results.outputDir;
atlasName = args.Results.atlasName;
roiName = args.Results.roiName;
hemisphere = args.Results.hemisphere;

[atlasFile, lut] = getAtlasAndLut(atlasName);

Expand Down