|
60 | 60 | {'suffix': 'magnitude1', 'metadata': {'EchoTime': 0.005}},
|
61 | 61 | {
|
62 | 62 | 'suffix': 'epi',
|
63 |
| - 'direction': 'PA', |
| 63 | + 'dir': 'PA', |
64 | 64 | 'metadata': {'PhaseEncodingDirection': 'j', 'TotalReadoutTime': 0.6},
|
65 | 65 | },
|
66 | 66 | {
|
67 | 67 | 'suffix': 'epi',
|
68 |
| - 'direction': 'AP', |
| 68 | + 'dir': 'AP', |
69 | 69 | 'metadata': {'PhaseEncodingDirection': 'j-', 'TotalReadoutTime': 0.6},
|
70 | 70 | },
|
71 | 71 | ],
|
@@ -230,6 +230,25 @@ def test_init_fmriprep_wf(
|
230 | 230 | generate_expanded_graph(wf._create_flat_graph())
|
231 | 231 |
|
232 | 232 |
|
| 233 | +def test_init_fmriprep_wf_sanitize_fmaps(tmp_path): |
| 234 | + bids_dir = tmp_path / 'bids' |
| 235 | + |
| 236 | + spec = deepcopy(BASE_LAYOUT) |
| 237 | + spec['01']['func'][0]['metadata']['B0FieldSource'] = 'epi<<run1>>' |
| 238 | + spec['01']['fmap'][2]['metadata']['B0FieldIdentifier'] = 'epi<<run1>>' |
| 239 | + spec['01']['fmap'][3]['metadata']['B0FieldIdentifier'] = 'epi<<run1>>' |
| 240 | + del spec['01']['func'][4:] |
| 241 | + |
| 242 | + generate_bids_skeleton(bids_dir, spec) |
| 243 | + img = nb.Nifti1Image(np.zeros((10, 10, 10, 10)), np.eye(4)) |
| 244 | + for img_path in bids_dir.glob('sub-01/*/*.nii.gz'): |
| 245 | + img.to_filename(img_path) |
| 246 | + |
| 247 | + with mock_config(bids_dir=bids_dir): |
| 248 | + wf = init_fmriprep_wf() |
| 249 | + generate_expanded_graph(wf._create_flat_graph()) |
| 250 | + |
| 251 | + |
233 | 252 | def test_get_estimator_none(tmp_path):
|
234 | 253 | bids_dir = tmp_path / 'bids'
|
235 | 254 |
|
@@ -265,6 +284,25 @@ def test_get_estimator_b0field_and_intendedfor(tmp_path):
|
265 | 284 | )
|
266 | 285 |
|
267 | 286 | assert get_estimator(layout, bold_files[0]) == ('epi',)
|
| 287 | + # if B0FieldIdentifiers are found, IntendedFor will not be used |
| 288 | + assert get_estimator(layout, bold_files[1]) == () |
| 289 | + |
| 290 | + |
| 291 | +def test_get_estimator_intendedfor(tmp_path): |
| 292 | + bids_dir = tmp_path / 'bids' |
| 293 | + |
| 294 | + # Set B0FieldSource for run 1 |
| 295 | + spec = deepcopy(BASE_LAYOUT) |
| 296 | + spec['01']['fmap'][0]['metadata']['IntendedFor'] = 'func/sub-01_task-rest_run-2_bold.nii.gz' |
| 297 | + |
| 298 | + generate_bids_skeleton(bids_dir, spec) |
| 299 | + layout = bids.BIDSLayout(bids_dir) |
| 300 | + _ = find_estimators(layout=layout, subject='01') |
| 301 | + |
| 302 | + bold_files = sorted( |
| 303 | + layout.get(suffix='bold', task='rest', extension='.nii.gz', return_type='file') |
| 304 | + ) |
| 305 | + |
268 | 306 | assert get_estimator(layout, bold_files[1]) == ('auto_00000',)
|
269 | 307 |
|
270 | 308 |
|
|
0 commit comments