|
71 | 71 | from niworkflows.utils.spaces import SpatialReferences
|
72 | 72 |
|
73 | 73 |
|
| 74 | +AUTO_T2W_MAX_AGE = 8 |
| 75 | + |
| 76 | + |
74 | 77 | def init_nibabies_wf(subworkflows_list):
|
75 | 78 | """
|
76 | 79 | Build *NiBabies*'s pipeline.
|
@@ -105,8 +108,8 @@ def init_nibabies_wf(subworkflows_list):
|
105 | 108 | nibabies_wf.base_dir = config.execution.work_dir
|
106 | 109 |
|
107 | 110 | execution_spaces = init_execution_spaces()
|
108 |
| - freesurfer = config.workflow.surface_recon_method is not None |
109 |
| - if freesurfer: |
| 111 | + surface_recon = config.workflow.surface_recon_method is not None |
| 112 | + if surface_recon: |
110 | 113 | fsdir = pe.Node(
|
111 | 114 | BIDSFreeSurferDir(
|
112 | 115 | derivatives=config.execution.output_dir,
|
@@ -154,7 +157,7 @@ def init_nibabies_wf(subworkflows_list):
|
154 | 157 | single_subject_wf.config['execution']['crashdump_dir'] = str(log_dir)
|
155 | 158 | for node in single_subject_wf._get_all_nodes():
|
156 | 159 | node.config = deepcopy(single_subject_wf.config)
|
157 |
| - if freesurfer: |
| 160 | + if surface_recon: |
158 | 161 | nibabies_wf.connect(fsdir, 'subjects_dir', single_subject_wf, 'inputnode.subjects_dir')
|
159 | 162 | else:
|
160 | 163 | nibabies_wf.add_nodes([single_subject_wf])
|
@@ -327,30 +330,32 @@ def init_single_subject_wf(
|
327 | 330 | # Determine some session level options here, as we should have
|
328 | 331 | # all the required information
|
329 | 332 | if recon_method == 'auto':
|
330 |
| - if age <= 8: |
| 333 | + if age <= AUTO_T2W_MAX_AGE and anatomical_cache.get('t2w_aseg'): |
| 334 | + # do not force mcribs without a vetted segmentation |
331 | 335 | recon_method = 'mcribs'
|
332 | 336 | elif age <= 24:
|
333 | 337 | recon_method = 'infantfs'
|
334 | 338 | else:
|
335 | 339 | recon_method = 'freesurfer'
|
336 | 340 |
|
337 |
| - preferred_anat = config.execution.reference_anat |
| 341 | + requested_anat = config.execution.reference_anat |
338 | 342 | t1w = subject_data['t1w']
|
339 | 343 | t2w = subject_data['t2w']
|
340 | 344 | single_anat = False
|
341 |
| - if not t1w and t2w: |
| 345 | + |
| 346 | + if not (t1w and t2w): |
342 | 347 | single_anat = True
|
343 | 348 | reference_anat = 'T1w' if t1w else 'T2w'
|
344 |
| - if preferred_anat and reference_anat != preferred_anat: |
| 349 | + if requested_anat and reference_anat != requested_anat: |
345 | 350 | raise AttributeError(
|
346 |
| - f'Requested to use {preferred_anat} as anatomical reference but none available' |
| 351 | + f'Requested to use {requested_anat} as anatomical reference but none available' |
347 | 352 | )
|
348 |
| - else: |
349 |
| - if not (reference_anat := preferred_anat): |
350 |
| - if recon_method is None: |
351 |
| - reference_anat = 'T2w' if age <= 8 else 'T1w' |
352 |
| - else: |
353 |
| - reference_anat = 'T2w' if recon_method == 'mcribs' else 'T1w' |
| 353 | + elif (reference_anat := requested_anat) is None: # Both available with no preference |
| 354 | + reference_anat = ( |
| 355 | + 'T2w' |
| 356 | + if any((recon_method == 'none' and age <= AUTO_T2W_MAX_AGE, recon_method == 'mcribs')) |
| 357 | + else 'T1w' |
| 358 | + ) |
354 | 359 |
|
355 | 360 | anat = reference_anat.lower() # To be used for workflow connections
|
356 | 361 |
|
|
0 commit comments