Skip to content

Commit 7718b99

Browse files
committed
ENH: Avoid detecting NSS if flag is used
1 parent fe23060 commit 7718b99

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

nibabies/workflows/bold/base.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,16 +511,21 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
511511
)
512512
bold_confounds_wf.get_node("inputnode").inputs.t1_transform_flags = [False]
513513

514-
# Detect dummy scans
515-
nss_detector = pe.Node(NonsteadyStatesDetector(), name='nss_detector')
516-
nss_detector.inputs.in_file = ref_file
514+
dummy_buffer = pe.Node(niu.IdentityInterface(fields=['n_dummy']), name='dummy_buffer')
515+
if (dummy := config.workflow.dummy_scans) is not None:
516+
dummy_buffer.inputs.n_dummy = dummy
517+
else:
518+
# Detect dummy scans
519+
nss_detector = pe.Node(NonsteadyStatesDetector(), name='nss_detector')
520+
nss_detector.inputs.in_file = ref_file
521+
workflow.connect(nss_detector, 'n_dummy', dummy_buffer, 'n_dummy')
517522

518523
# SLICE-TIME CORRECTION (or bypass) #############################################
519524
if run_stc:
520525
bold_stc_wf = init_bold_stc_wf(name="bold_stc_wf", metadata=metadata)
521526
# fmt:off
522527
workflow.connect([
523-
(nss_detector, bold_stc_wf, [('n_dummy', 'inputnode.skip_vols')]),
528+
(dummy_buffer, bold_stc_wf, [('n_dummy', 'inputnode.skip_vols')]),
524529
(select_bold, bold_stc_wf, [("out", 'inputnode.bold_file')]),
525530
(bold_stc_wf, boldbuffer, [('outputnode.stc_file', 'bold_file')]),
526531
])
@@ -663,7 +668,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
663668
('outputnode.rmsd_file', 'inputnode.rmsd_file')]),
664669
(bold_reg_wf, bold_confounds_wf, [
665670
('outputnode.itk_t1_to_bold', 'inputnode.t1_bold_xform')]),
666-
(nss_detector, bold_confounds_wf, [
671+
(dummy_buffer, bold_confounds_wf, [
667672
('n_dummy', 'inputnode.skip_vols')]),
668673
(bold_final, bold_confounds_wf, [
669674
('bold', 'inputnode.bold'),
@@ -676,7 +681,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
676681
('outputnode.tcompcor_mask', 'tcompcor_mask'),
677682
]),
678683
# Summary
679-
(nss_detector, summary, [('n_dummy', 'algo_dummy_scans')]),
684+
(dummy_buffer, summary, [('n_dummy', 'algo_dummy_scans')]),
680685
(bold_reg_wf, summary, [('outputnode.fallback', 'fallback')]),
681686
(outputnode, summary, [('confounds', 'confounds_file')]),
682687
# Select echo indices for original/validated BOLD files
@@ -878,7 +883,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
878883
('bold_file', 'inputnode.name_source')]),
879884
(bold_hmc_wf, ica_aroma_wf, [
880885
('outputnode.movpar_file', 'inputnode.movpar_file')]),
881-
(nss_detector, ica_aroma_wf, [
886+
(dummy_buffer, ica_aroma_wf, [
882887
('n_dummy', 'inputnode.skip_vols')]),
883888
(bold_confounds_wf, join, [
884889
('outputnode.confounds_file', 'in_file')]),

0 commit comments

Comments
 (0)