Skip to content

Commit ea8a7f0

Browse files
committed
deal with RawSources for surface derivatives
1 parent 8f328c9 commit ea8a7f0

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/utils/identify_rawsources.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
% find the most likely files in the raw dataset
44
% that was used to create this derivatives
55
%
6+
% Assumption: the raw file was zipped
7+
%
68
% USAGE::
79
%
810
% rawsource = identify_rawsources(derivatives)
@@ -43,6 +45,7 @@
4345

4446
% - remove prefix
4547
% - remove eventual derivatives entities
48+
% - change surface extension to a volume one
4649
% - use only .nii.gz
4750
bf = bids.File(derivatives, 'verbose', verbose, 'use_schema', false);
4851

@@ -53,6 +56,11 @@
5356
for i = 1:numel(idx)
5457
bf.entities.(entities{idx(i)}) = '';
5558
end
59+
60+
if strcmp(bf.extension, '.surf.gii')
61+
bf.extension = '.nii';
62+
end
63+
5664
if strcmp(bf.extension, '.nii')
5765
bf.extension = '.nii.gz';
5866
end

tests/test_identify_rawsources.m

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

11+
function test_identify_rawsources_surface()
12+
13+
input_output = {'c1sub-01_T1w.surf.gii', 'sub-01_T1w.nii.gz'};
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, {['sub-01/' input_output{i, 2}]});
24+
25+
end
26+
27+
end
28+
1129
function test_identify_rawsources_when_der_entities()
1230

1331
input_output = {'sub-01_desc-skullstripped_T1w.nii', 'sub-01_T1w.nii.gz'};

0 commit comments

Comments
 (0)