Skip to content

Commit 18dc4f0

Browse files
committed
only deal with known BIDS suffixes for raw sources
1 parent ea8a7f0 commit 18dc4f0

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

run_tests.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
if isdir(fullfile(thisDir, 'lib', 'bids-matlab'))
66
addpath(fullfile(thisDir, 'lib', 'bids-matlab'));
7+
end
8+
if isdir(fullfile(thisDir, 'lib', 'JSONio'))
79
addpath(fullfile(thisDir, 'lib', 'JSONio'));
810
end
911

1012
folderToCover = fullfile(thisDir, 'src');
1113
testFolder = fullfile(thisDir, 'tests');
1214

15+
addpath(fullfile(testFolder, 'utils'));
16+
1317
success = moxunit_runtests(testFolder, ...
1418
'-verbose', '-recursive', '-with_coverage', ...
1519
'-cover', folderToCover, ...

src/defaults/check_cfg.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
% just to keep track of all the BIDS entities in the cfg
7878
bidsFile = bids.File('sub-01_T1.nii', 'use_schema', false);
7979
bidsFile = bidsFile.reorder_entities;
80+
fields_to_set.schema = bids.Schema;
8081
fields_to_set.all_entity_order = bidsFile.entity_order;
8182

8283
fields_to_set.entity_order = {'hemi'; ...

src/utils/identify_rawsources.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,18 @@
4343
derivatives = strrep(derivatives, '_uw.mat', '.nii');
4444
end
4545

46+
% - only deal with files with official BIDS suffixes
4647
% - remove prefix
4748
% - remove eventual derivatives entities
4849
% - change surface extension to a volume one
4950
% - use only .nii.gz
5051
bf = bids.File(derivatives, 'verbose', verbose, 'use_schema', false);
5152

53+
if ~ismember(bf.suffix, fieldnames(map.cfg.schema.content.objects.suffixes))
54+
rawsource{1} = 'TODO';
55+
return
56+
end
57+
5258
bf.prefix = '';
5359

5460
entities = fieldnames(bf.entities);

tests/test_identify_rawsources.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@
88
initTestSuite;
99
end
1010

11+
function test_identify_rawsources_skip_unknown_suffix()
12+
13+
input_output = {'wsub-01_label-brain_mask.nii', ''};
14+
15+
verbose = false;
16+
17+
map = default_mapping();
18+
19+
for i = 1:size(input_output, 1)
20+
21+
rawsource = identify_rawsources(input_output{i, 1}, map, verbose);
22+
23+
assertEqual(rawsource, {'TODO'});
24+
25+
end
26+
27+
end
28+
29+
30+
1131
function test_identify_rawsources_surface()
1232

1333
input_output = {'c1sub-01_T1w.surf.gii', 'sub-01_T1w.nii.gz'};

0 commit comments

Comments
 (0)