Skip to content

Commit 064aa3f

Browse files
committed
FIX: MCRIBS auto surface reconstruction logic
Previously, `--surface-recon-method auto` would not take into account the presence of a previously computed segmentation when determining MCRIBS as the method, despite the workflow erroring down the line if there is not one provided.
1 parent 6d778c4 commit 064aa3f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

nibabies/workflows/base.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
from niworkflows.utils.spaces import SpatialReferences
7272

7373

74+
AUTO_T2W_MAX_AGE = 8
75+
76+
7477
def init_nibabies_wf(subworkflows_list):
7578
"""
7679
Build *NiBabies*'s pipeline.
@@ -327,30 +330,30 @@ def init_single_subject_wf(
327330
# Determine some session level options here, as we should have
328331
# all the required information
329332
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
331335
recon_method = 'mcribs'
332336
elif age <= 24:
333337
recon_method = 'infantfs'
334338
else:
335339
recon_method = 'freesurfer'
336340

337-
preferred_anat = config.execution.reference_anat
341+
requested_anat = config.execution.reference_anat
338342
t1w = subject_data['t1w']
339343
t2w = subject_data['t2w']
340344
single_anat = False
341-
if not t1w and t2w:
345+
346+
if not (t1w and t2w):
342347
single_anat = True
343348
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:
345350
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'
347352
)
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 = 'T2w' if any(
355+
(recon_method == 'none' and age <= AUTO_T2W_MAX_AGE, recon_method == 'mcribs')
356+
) else 'T1w'
354357

355358
anat = reference_anat.lower() # To be used for workflow connections
356359

0 commit comments

Comments
 (0)