Skip to content

Commit c29610e

Browse files
authored
fix 1206 (#1257)
1 parent 1f7220d commit c29610e

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/IO/getData.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@
6060
indexDependencies = false;
6161
end
6262

63-
if isfield(opt, 'taskName')
63+
anatOnly = false;
64+
if isfield(opt, 'anatOnly')
65+
anatOnly = opt.anatOnly;
66+
end
67+
68+
if ~anatOnly && isfield(opt, 'taskName')
6469
msg = sprintf('FOR TASK(s): %s', strjoin(opt.taskName, ' '));
6570
logger('INFO', msg, 'options', opt, 'filename', mfilename());
6671
end
@@ -72,6 +77,10 @@
7277
layout_filter = struct('sub', {opt.subjects});
7378
end
7479

80+
if anatOnly
81+
layout_filter(1).modality = {'anat'};
82+
end
83+
7584
BIDS = bids.layout(bidsDir, ...
7685
'use_schema', opt.useBidsSchema, ...
7786
'verbose', opt.verbosity > 1, ...
@@ -100,7 +109,8 @@
100109
end
101110

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

105115
msg = sprintf(['The task %s that you have asked for ', ...
106116
'does not exist in this dataset.\n', ...

tests/tests_bids/test_getData.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,15 @@ function test_getData_get_also_raw_data_for_stats_pipeline()
4545
assert(~isempty(bids.query(BIDS.raw, 'data', 'suffix', 'events')));
4646

4747
end
48+
49+
function test_getData_anat_only()
50+
% https://github.com/bids-standard/bids-matlab/issues/1206
51+
52+
opt = setOptions('vismotion');
53+
opt.anatOnly = true;
54+
55+
[BIDS, ~] = getData(opt, opt.dir.input);
56+
57+
assert(isempty(bids.query(BIDS, 'data', 'modality', 'func')));
58+
59+
end

0 commit comments

Comments
 (0)