|
30 | 30 | % images for this to work (check the README of the toolbox for more info): |
31 | 31 | % |
32 | 32 | % - ``EchoSpacing`` |
33 | | - % - ``PartialFourierInSlice``: between 0 and 1 (example: 6/8) |
| 33 | + % - ``SlicePartialFourier`` or ``PartialFourierInSlice``: |
| 34 | + % between 0 and 1 (example: 6/8) |
34 | 35 | % - ``FatSat``: must be "yes" or "no" |
35 | 36 | % |
36 | 37 | % Most of the those metadata should be available from the PDF of with yout |
|
144 | 145 |
|
145 | 146 | % Things that are not officially part of BIDS |
146 | 147 | % but that should be added to the JSON of the inversion images |
147 | | - try |
148 | | - estimateT1.EchoSpacing = metadataInv1.EchoSpacing; |
149 | | - estimateT1.PartialFourierInSlice = metadataInv1.PartialFourierInSlice; |
150 | | - estimateT1.FatSat = metadataInv1.FatSat; |
151 | | - catch |
152 | | - msg = sprintf('Missing non-BIDS metadata for %s\nSee ''help setBatchGenerateT1map''', ... |
153 | | - bids.internal.create_unordered_list(filter)); |
154 | | - id = 'missingNonBIDSMetadata'; |
155 | | - logger('WARNING', msg, 'id', id, 'options', opt, 'filename', mfilename()); |
156 | | - continue |
| 148 | + |
| 149 | + requiredMetadata = {'EchoSpacing', 'FatSat'}; |
| 150 | + for i = 1:numel(requiredMetadata) |
| 151 | + if ~ismember(requiredMetadata{i}, fieldnames(metadataInv1)) |
| 152 | + missingMetadata(requiredMetadata{i}, filter, opt); |
| 153 | + continue |
| 154 | + end |
| 155 | + estimateT1.(requiredMetadata{i}) = metadataInv1.(requiredMetadata{i}); |
157 | 156 | end |
158 | 157 |
|
159 | | - matlabbatch{end + 1}.spm.tools.mp2rage.estimateT1 = estimateT1; |
| 158 | + if ~ismember('SlicePartialFourier', fieldnames(metadataInv1)) |
| 159 | + missingMetadata('SlicePartialFourier', filter, opt, true); |
| 160 | + if ~ismember('PartialFourierInSlice', fieldnames(metadataInv1)) |
| 161 | + missingMetadata('PartialFourierInSlice', filter, opt); |
| 162 | + continue |
| 163 | + else |
| 164 | + estimateT1.PartialFourierInSlice = metadataInv1.PartialFourierInSlice; |
| 165 | + end |
| 166 | + else |
| 167 | + estimateT1.PartialFourierInSlice = metadataInv1.SlicePartialFourier; |
| 168 | + end |
| 169 | + |
| 170 | + matlabbatch{end + 1}.spm.tools.mp2rage.estimateT1 = estimateT1; %#ok<*AGROW> |
160 | 171 |
|
161 | 172 | end |
162 | 173 |
|
163 | 174 | end |
164 | 175 |
|
165 | 176 | end |
| 177 | + |
| 178 | +function missingMetadata(metadata, filter, opt, tolerant) |
| 179 | + if nargin < 3 |
| 180 | + tolerant = false; |
| 181 | + end |
| 182 | + msg = sprintf(['Missing non-BIDS metadata "%s" for %s\n', ... |
| 183 | + 'See "help setBatchGenerateT1map"'], ... |
| 184 | + metadata, ... |
| 185 | + bids.internal.create_unordered_list(filter)); |
| 186 | + id = 'missingNonBIDSMetadata'; |
| 187 | + if tolerant |
| 188 | + logger('WARNING', msg, 'id', id, 'options', opt, 'filename', mfilename()); |
| 189 | + else |
| 190 | + logger('ERROR', msg, 'id', id, 'options', opt, 'filename', mfilename()); |
| 191 | + end |
| 192 | +end |
0 commit comments