Skip to content

Commit 63b2acc

Browse files
committed
make sure that sources is either TODO or empty
1 parent 7c7e6b1 commit 63b2acc

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lib/JSONio
1212
coverage_html
1313
coverage.xml
1414
test_report.log
15+
mapping.md
1516

1617
## MATLAB / OCTAVE gitignore template
1718

src/spm_2_bids.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,15 @@
149149
json = bids.derivatives_json(bf.filename);
150150

151151
content = json.content;
152+
152153
content.RawSources = identify_rawsources(file, verbose);
153-
content.Sources = identify_sources(file, map, verbose);
154+
155+
Sources = identify_sources(file, map, verbose);
156+
if ~isempty(Sources)
157+
content.Sources = Sources;
158+
else
159+
content = rmfield(content, 'Sources');
160+
end
154161

155162
if isfield(bf.entities, 'space') && strcmp(bf.entities.space, 'IXI549Space')
156163
content.SpatialReference = struct('IXI549Space', ...

src/utils/identify_sources.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@
120120
% 'meanu'
121121
% 'meanua'
122122
% };
123+
sources = 'TODO';
123124
return
124125

125126
else
126127
% no idea
128+
sources = 'TODO';
127129
return
128130

129131
end
@@ -136,6 +138,7 @@
136138

137139
sources{1, 1} = fullfile(bf.bids_path, new_filename);
138140

141+
% for normalized images
139142
if add_deformation_field
140143

141144
% for anatomical data we assume that

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_source_must_be_empty()
12+
13+
file = 'msub-01_T1w.nii';
14+
15+
[~, ~, json] = spm_2_bids(file, [], false);
16+
17+
assertEqual(fieldnames(json), {'filename'; 'content'});
18+
assertEqual(fieldnames(json.content), {'Description'; 'RawSources'; 'SpatialReference'});
19+
assertEqual(json.content.RawSources{1}, 'sub-01/sub-01_T1w.nii');
20+
21+
bids.util.jsonencode(json.filename, json.content);
22+
23+
end
24+
1125
function test_spm_2_bids_metadata_anat()
1226

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

0 commit comments

Comments
 (0)