Skip to content

Commit

Permalink
fix 1206 (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau authored Jul 3, 2024
1 parent 1f7220d commit c29610e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/IO/getData.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@
indexDependencies = false;
end

if isfield(opt, 'taskName')
anatOnly = false;
if isfield(opt, 'anatOnly')
anatOnly = opt.anatOnly;
end

if ~anatOnly && isfield(opt, 'taskName')
msg = sprintf('FOR TASK(s): %s', strjoin(opt.taskName, ' '));
logger('INFO', msg, 'options', opt, 'filename', mfilename());
end
Expand All @@ -72,6 +77,10 @@
layout_filter = struct('sub', {opt.subjects});
end

if anatOnly
layout_filter(1).modality = {'anat'};
end

BIDS = bids.layout(bidsDir, ...
'use_schema', opt.useBidsSchema, ...
'verbose', opt.verbosity > 1, ...
Expand Down Expand Up @@ -100,7 +109,8 @@
end

% make sure that the required tasks exist in the data set
if isfield(opt, 'taskName') && ~any(ismember(opt.taskName, bids.query(BIDS, 'tasks')))
if ~anatOnly && isfield(opt, 'taskName') && ...
~any(ismember(opt.taskName, bids.query(BIDS, 'tasks')))

msg = sprintf(['The task %s that you have asked for ', ...
'does not exist in this dataset.\n', ...
Expand Down
12 changes: 12 additions & 0 deletions tests/tests_bids/test_getData.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ function test_getData_get_also_raw_data_for_stats_pipeline()
assert(~isempty(bids.query(BIDS.raw, 'data', 'suffix', 'events')));

end

function test_getData_anat_only()
% https://github.com/bids-standard/bids-matlab/issues/1206

opt = setOptions('vismotion');
opt.anatOnly = true;

[BIDS, ~] = getData(opt, opt.dir.input);

assert(isempty(bids.query(BIDS, 'data', 'modality', 'func')));

end

0 comments on commit c29610e

Please sign in to comment.