|
16 | 16 | % :param verbose: Defaults to ``true`` |
17 | 17 | % :type verbose: boolean |
18 | 18 | % |
| 19 | + |
19 | 20 | % (C) Copyright 2021 spm_2_bids developers |
20 | 21 |
|
21 | 22 | % "r" could mean realigned or resliced... |
|
117 | 118 |
|
118 | 119 | end |
119 | 120 |
|
120 | | -function sources = add_deformation_field(bf, sources, map, verbose) |
121 | | - |
122 | | - if ~startsWith(bf.prefix, map.norm) |
123 | | - return |
124 | | - end |
125 | | - |
126 | | - % for anatomical data we assume that |
127 | | - % the deformation field comes from the anatomical file itself |
128 | | - if (~isempty(bf.modality) && ismember(bf.modality, {'anat'})) || ... |
129 | | - (~isempty(bf.suffix) && ~isempty(map.cfg.schema.find_suffix_group('anat', bf.suffix))) |
130 | | - |
131 | | - bf.prefix = 'y_'; |
132 | | - bf = bf.update; |
133 | | - new_filename = spm_2_bids(bf.filename, map, verbose); |
134 | | - deformation_field = fullfile(bf.bids_path, new_filename); |
135 | | - |
136 | | - % otherwise we can't guess it just from the file name |
137 | | - else |
138 | | - deformation_field = 'TODO: add deformation field'; |
139 | | - |
140 | | - end |
141 | | - |
142 | | - sources{end + 1, 1} = deformation_field; |
143 | | - |
144 | | -end |
145 | | - |
146 | | -function [status, bf] = update_prefix(bf, map) |
147 | | - |
148 | | - status = 2; |
149 | | - |
150 | | - if length(bf.prefix) < 2 |
151 | | - % TODO: files that have been realigned but not resliced have no |
152 | | - % "prefix" so we may miss some transformation |
153 | | - status = 0; |
154 | | - return |
155 | | - end |
156 | | - |
157 | | - % remove the prefix of the last step |
158 | | - if startsWith(bf.prefix, map.smooth) |
159 | | - |
160 | | - % in case the prefix includes a number to denotate the FXHM used |
161 | | - % for smoothing |
162 | | - starts_with_fwhm = regexp(bf.prefix, '^s[0-9]*', 'match'); |
163 | | - if ~isempty(starts_with_fwhm) |
164 | | - bf = shorten_prefix(bf, length(starts_with_fwhm{1})); |
165 | | - else |
166 | | - bf = shorten_prefix(bf, 1); |
167 | | - end |
168 | | - |
169 | | - elseif startsWith(bf.prefix, map.unwarp) |
170 | | - bf = shorten_prefix(bf, 1); |
171 | | - |
172 | | - elseif startsWith(bf.prefix, map.norm) |
173 | | - bf = shorten_prefix(bf, 1); |
174 | | - |
175 | | - elseif startsWith(bf.prefix, ['rp_' map.stc]) |
176 | | - bf = shorten_prefix(bf, 3); |
177 | | - |
178 | | - elseif startsWith(bf.prefix, 'mean') |
179 | | - % TODO mean may involve several files from the source (across runs |
180 | | - % and sessions |
181 | | - % prefixes = { |
182 | | - % 'mean' |
183 | | - % 'meanu' |
184 | | - % 'meanua' |
185 | | - % }; |
186 | | - status = 1; |
187 | | - return |
188 | | - |
189 | | - elseif ismember(bf.prefix(1:2), {'c1', 'c2', 'c3', 'c4', 'c5'}) |
190 | | - % bias corrected image |
191 | | - status = 1; |
192 | | - return |
193 | | - |
194 | | - else |
195 | | - % no idea |
196 | | - status = 1; |
197 | | - return |
198 | | - |
199 | | - end |
200 | | - |
201 | | -end |
202 | | - |
203 | 121 | function bf = shorten_prefix(bf, len) |
204 | 122 | bf.prefix = bf.prefix((len + 1):end); |
205 | 123 | end |
0 commit comments