Skip to content

Commit d5f0b45

Browse files
committed
FIX: Revert to calculating bold reference per run
1 parent 5b20166 commit d5f0b45

File tree

1 file changed

+32
-67
lines changed

1 file changed

+32
-67
lines changed

nibabies/workflows/base.py

Lines changed: 32 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -408,80 +408,44 @@ def init_single_subject_wf(subject_id, session_id=None):
408408

409409
# Append the functional section to the existing anatomical exerpt
410410
# That way we do not need to stream down the number of bold datasets
411-
anat_preproc_wf.__postdesc__ = (
412-
(anat_preproc_wf.__postdesc__ if hasattr(anat_preproc_wf, "__postdesc__") else "")
413-
+ f"""
411+
anat_preproc_wf.__postdesc__ = getattr(anat_preproc_wf, '__postdesc__', '')
412+
func_pre_desc = f"""
414413
415414
Functional data preprocessing
416415
417416
: For each of the {len(subject_data['bold'])} BOLD runs found per subject (across all
418-
tasks and sessions), the following preprocessing was performed.
419-
"""
420-
)
421-
422-
# calculate reference image(s) for BOLD images
423-
# group all BOLD files based on same:
424-
# 1) session
425-
# 2) PE direction
426-
# 3) total readout time
427-
from niworkflows.workflows.epi.refmap import init_epi_reference_wf
428-
429-
bold_groupings = group_bolds_ref(
430-
layout=config.execution.layout,
431-
subject=subject_id,
432-
sessions=[session_id],
433-
)
417+
tasks and sessions), the following preprocessing was performed."""
434418

435419
func_preproc_wfs = []
436420
has_fieldmap = bool(fmap_estimators)
437-
for idx, grouping in enumerate(bold_groupings.values()):
438-
bold_ref_wf = init_epi_reference_wf(
439-
auto_bold_nss=True,
440-
name=f"bold_reference_wf{idx}",
441-
omp_nthreads=config.nipype.omp_nthreads,
442-
)
443-
bold_files = grouping.files
444-
bold_ref_wf.inputs.inputnode.in_files = grouping.files
445-
446-
if grouping.multiecho_id is not None:
447-
bold_files = [bold_files]
448-
for idx, bold_file in enumerate(bold_files):
449-
func_preproc_wf = init_func_preproc_wf(
450-
bold_file,
451-
has_fieldmap=has_fieldmap,
452-
existing_derivatives=derivatives,
453-
)
454-
# fmt: off
455-
workflow.connect([
456-
(bold_ref_wf, func_preproc_wf, [
457-
('outputnode.epi_ref_file', 'inputnode.bold_ref'),
458-
(
459-
('outputnode.xfm_files', _select_iter_idx, idx),
460-
'inputnode.bold_ref_xfm'),
461-
(
462-
('outputnode.n_dummy', _select_iter_idx, idx),
463-
'inputnode.n_dummy_scans'),
464-
]),
465-
(anat_preproc_wf, func_preproc_wf, [
466-
('outputnode.anat_preproc', 'inputnode.anat_preproc'),
467-
('outputnode.anat_mask', 'inputnode.anat_mask'),
468-
('outputnode.anat_brain', 'inputnode.anat_brain'),
469-
('outputnode.anat_dseg', 'inputnode.anat_dseg'),
470-
('outputnode.anat_aseg', 'inputnode.anat_aseg'),
471-
('outputnode.anat_aparc', 'inputnode.anat_aparc'),
472-
('outputnode.anat_tpms', 'inputnode.anat_tpms'),
473-
('outputnode.template', 'inputnode.template'),
474-
('outputnode.anat2std_xfm', 'inputnode.anat2std_xfm'),
475-
('outputnode.std2anat_xfm', 'inputnode.std2anat_xfm'),
476-
# Undefined if --fs-no-reconall, but this is safe
477-
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
478-
('outputnode.subject_id', 'inputnode.subject_id'),
479-
('outputnode.t1w2fsnative_xfm', 'inputnode.t1w2fsnative_xfm'),
480-
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'),
481-
]),
482-
])
483-
# fmt: on
484-
func_preproc_wfs.append(func_preproc_wf)
421+
for bold_file in subject_data['bold']:
422+
func_preproc_wf = init_func_preproc_wf(bold_file, has_fieldmap=has_fieldmap)
423+
if func_preproc_wf is None:
424+
continue
425+
426+
func_preproc_wf.__desc__ = func_pre_desc + getattr(func_preproc_wf, '__desc__', '')
427+
# fmt:off
428+
workflow.connect([
429+
(anat_preproc_wf, func_preproc_wf, [
430+
('outputnode.anat_preproc', 'inputnode.anat_preproc'),
431+
('outputnode.anat_mask', 'inputnode.anat_mask'),
432+
('outputnode.anat_brain', 'inputnode.anat_brain'),
433+
('outputnode.anat_dseg', 'inputnode.anat_dseg'),
434+
('outputnode.anat_aseg', 'inputnode.anat_aseg'),
435+
('outputnode.anat_aparc', 'inputnode.anat_aparc'),
436+
('outputnode.anat_tpms', 'inputnode.anat_tpms'),
437+
('outputnode.template', 'inputnode.template'),
438+
('outputnode.anat2std_xfm', 'inputnode.anat2std_xfm'),
439+
('outputnode.std2anat_xfm', 'inputnode.std2anat_xfm'),
440+
# Undefined if --fs-no-reconall, but this is safe
441+
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
442+
('outputnode.subject_id', 'inputnode.subject_id'),
443+
('outputnode.t1w2fsnative_xfm', 'inputnode.t1w2fsnative_xfm'),
444+
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'),
445+
]),
446+
])
447+
# fmt:on
448+
func_preproc_wfs.append(func_preproc_wf)
485449

486450
if not has_fieldmap:
487451
config.loggers.workflow.warning(
@@ -506,6 +470,7 @@ def init_single_subject_wf(subject_id, session_id=None):
506470
subject=subject_id,
507471
)
508472
fmap_wf.__desc__ = f"""
473+
509474
Preprocessing of B<sub>0</sub> inhomogeneity mappings
510475
511476
: A total of {len(fmap_estimators)} fieldmaps were found available within the input

0 commit comments

Comments
 (0)