Skip to content

Commit 09da459

Browse files
committed
get the correct source metadata if smoothing prefix includes FWHM
1 parent 63b2acc commit 09da459

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

miss_hit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ copyright_entity: "spm_2_bids developers"
1717
# metric for code quality
1818
metric "cnest": limit 5
1919
metric "file_length": limit 500
20-
metric "cyc": limit 16
20+
metric "cyc": limit 20
2121
metric "parameters": limit 6

src/spm_2_bids.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
Sources = identify_sources(file, map, verbose);
156156
if ~isempty(Sources)
157157
content.Sources = Sources;
158-
else
158+
elseif isfield(content, 'Sources')
159159
content = rmfield(content, 'Sources');
160160
end
161161

src/utils/identify_sources.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,18 @@
102102
else
103103
% remove the prefix of the last step
104104

105-
if startsWith(bf.prefix, 's') || startsWith(bf.prefix, 'u')
105+
if startsWith(bf.prefix, 's')
106+
107+
% in case the prefix includes a number to denotate the FXHM used
108+
% for smoothing
109+
starts_with_fwhm = regexp(bf.prefix, '^s[0-9]*', 'match');
110+
if ~isempty(starts_with_fwhm)
111+
bf.prefix = bf.prefix(length(starts_with_fwhm{1}) + 1:end);
112+
else
113+
bf.prefix = bf.prefix(2:end);
114+
end
115+
116+
elseif startsWith(bf.prefix, 'u')
106117
bf.prefix = bf.prefix(2:end);
107118

108119
elseif startsWith(bf.prefix, 'w')

tests/test_spm_2_bids_metadata.m

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

11+
function test_spm_2_bids_metadata_smoothed_data()
12+
13+
file = 's6wusub-01_task-auditory_bold.nii';
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_task-auditory_bold.nii');
19+
assertEqual(json.content.Sources{1}, ...
20+
'sub-01/sub-01_task-auditory_space-IXI549Space_desc-preproc_bold.nii');
21+
22+
bids.util.jsonencode(json.filename, json.content);
23+
24+
end
25+
1126
function test_spm_2_bids_metadata_source_must_be_empty()
1227

1328
file = 'msub-01_T1w.nii';

0 commit comments

Comments
 (0)