Skip to content

Commit a2f5328

Browse files
committed
identify sources surface data
1 parent 18dc4f0 commit a2f5328

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/utils/identify_sources.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@
9191

9292
bf = bids.File(derivatives, 'verbose', verbose, 'use_schema', false);
9393

94+
% deal with surface data
95+
if strcmp(bf.extension, '.surf.gii')
96+
bf.extension = '.nii';
97+
prefix_based = false;
98+
end
99+
100+
% anything prefix based
94101
if prefix_based
95102

96103
if numel(bf.prefix) < 2

tests/test_identify_sources.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_sources_surface()
12+
13+
anat_file = 'sub-01_T1w.surf.gii';
14+
15+
prefix_output = {'wm', 'sub-01/sub-01_space-IXI549Space_desc-preproc_T1w.nii'};
16+
17+
map = default_mapping();
18+
19+
for i = 1:size(prefix_output, 1)
20+
21+
sources = identify_sources([prefix_output{i, 1} anat_file], map, false);
22+
23+
assertEqual(sources{1}, prefix_output{i, 2});
24+
25+
end
26+
27+
end
28+
1129
function test_identify_sources_anat()
1230

1331
anat_file = 'sub-01_T1w.nii';

tests/test_spm_2_bids_metadata.m

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

11+
function test_spm_2_bids_metadata_surface()
12+
13+
file = 'wmsub-01_T1w.surf.gii';
14+
15+
[~, ~, json] = spm_2_bids(file, [], false);
16+
17+
assertEqual(fieldnames(json), {'filename'; 'content'});
18+
assertEqual(json.content.RawSources{1}, 'sub-01/sub-01_T1w.nii.gz');
19+
assertEqual(json.content.Sources{1}, ...
20+
'sub-01/sub-01_space-IXI549Space_desc-preproc_T1w.nii');
21+
22+
bids.util.jsonencode(json.filename, json.content);
23+
24+
end
1125
function test_spm_2_bids_metadata_probseg()
1226

1327
file = 'c1sub-01_T1w.nii';

0 commit comments

Comments
 (0)