Skip to content

Commit 3231c08

Browse files
committed
rely on prefixes stored in map rather than rely on hardcoded values
1 parent 3683fa2 commit 3231c08

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/utils/identify_rawsources.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
% 'wmeanu'
2828
% };
2929

30-
% TODO adapt in case prefixes have been changed from SPM defaults
31-
3230
rawsource = '';
3331

3432
if nargin < 1 || isempty(derivatives)

src/utils/identify_sources.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
% anything prefix based
9898
if prefix_based
9999

100-
[status, bf] = update_prefix(bf);
100+
[status, bf] = update_prefix(bf, map);
101101

102102
if status == 0
103103
return
@@ -119,7 +119,7 @@
119119

120120
function sources = add_deformation_field(bf, sources, map, verbose)
121121

122-
if ~startsWith(bf.prefix, 'w')
122+
if ~startsWith(bf.prefix, map.norm)
123123
return
124124
end
125125

@@ -143,7 +143,7 @@
143143

144144
end
145145

146-
function [status, bf] = update_prefix(bf)
146+
function [status, bf] = update_prefix(bf, map)
147147

148148
status = 2;
149149

@@ -155,7 +155,7 @@
155155
end
156156

157157
% remove the prefix of the last step
158-
if startsWith(bf.prefix, 's')
158+
if startsWith(bf.prefix, map.smooth)
159159

160160
% in case the prefix includes a number to denotate the FXHM used
161161
% for smoothing
@@ -166,13 +166,13 @@
166166
bf = shorten_prefix(bf, 1);
167167
end
168168

169-
elseif startsWith(bf.prefix, 'u')
169+
elseif startsWith(bf.prefix, map.unwarp)
170170
bf = shorten_prefix(bf, 1);
171171

172-
elseif startsWith(bf.prefix, 'w')
172+
elseif startsWith(bf.prefix, map.norm)
173173
bf = shorten_prefix(bf, 1);
174174

175-
elseif startsWith(bf.prefix, 'rp_a')
175+
elseif startsWith(bf.prefix, ['rp_' map.stc])
176176
bf = shorten_prefix(bf, 3);
177177

178178
elseif startsWith(bf.prefix, 'mean')

tests/test_spm_2_bids_metadata.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ function test_spm_2_bids_metadata_func()
3131

3232
assertEqual(fieldnames(json), {'filename'; 'content'});
3333
assertEqual(json.content.RawSources{1}, 'sub-01/sub-01_task-foo_bold.nii.gz');
34-
assertEqual(json.content.Sources{1}, ...
34+
assertEqual(json.content.Sources{2}, ...
3535
'sub-01/sub-01_task-foo_space-individual_desc-realignUnwarp_bold.nii');
36-
assertEqual(json.content.Sources{2}, 'TODO: add deformation field');
36+
assertEqual(json.content.Sources{1}, 'TODO: add deformation field');
3737

3838
bids.util.jsonencode(json.filename, json.content);
3939

@@ -47,7 +47,7 @@ function test_spm_2_bids_non_raw_suffix()
4747

4848
assertEqual(fieldnames(json), {'filename'; 'content'});
4949
assertEqual(json.content.RawSources{1}, 'TODO');
50-
assertEqual(json.content.Sources{1}, 'TODO');
50+
assertEqual(json.content.Sources{end}, 'TODO');
5151

5252
bids.util.jsonencode(json.filename, json.content);
5353

@@ -61,7 +61,7 @@ function test_spm_2_bids_metadata_surface()
6161

6262
assertEqual(fieldnames(json), {'filename'; 'content'});
6363
assertEqual(json.content.RawSources{1}, 'sub-01/sub-01_T1w.nii.gz');
64-
assertEqual(json.content.Sources{1}, ...
64+
assertEqual(json.content.Sources{end}, ...
6565
'sub-01/sub-01_space-IXI549Space_desc-preproc_T1w.nii');
6666

6767
bids.util.jsonencode(json.filename, json.content);
@@ -90,7 +90,7 @@ function test_spm_2_bids_metadata_smoothed_data()
9090

9191
assertEqual(fieldnames(json), {'filename'; 'content'});
9292
assertEqual(json.content.RawSources{1}, 'sub-01/sub-01_task-auditory_bold.nii.gz');
93-
assertEqual(json.content.Sources{1}, ...
93+
assertEqual(json.content.Sources{end}, ...
9494
'sub-01/sub-01_task-auditory_space-IXI549Space_desc-preproc_bold.nii');
9595

9696
bids.util.jsonencode(json.filename, json.content);

0 commit comments

Comments
 (0)