From 28fe6b461495be6ddb34e060ffbfbdabe378c5f5 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Sat, 9 Dec 2023 13:06:17 -0500 Subject: [PATCH] Replace fmt:on and fmt:off with fmt:skip (#372) --- aslprep/workflows/asl/cbf.py | 24 ++++------------ aslprep/workflows/asl/confounds.py | 4 +-- aslprep/workflows/asl/fit.py | 46 +++++++++--------------------- aslprep/workflows/asl/outputs.py | 16 +++-------- 4 files changed, 24 insertions(+), 66 deletions(-) diff --git a/aslprep/workflows/asl/cbf.py b/aslprep/workflows/asl/cbf.py index 60331c85e..4468acbae 100644 --- a/aslprep/workflows/asl/cbf.py +++ b/aslprep/workflows/asl/cbf.py @@ -711,14 +711,12 @@ def init_parcellate_cbf_wf( merge_xforms = pe.Node(niu.Merge(3), name="merge_xforms") merge_xforms.inputs.in1 = MNI152NLin6Asym_to_MNI152NLin2009cAsym - # fmt:off workflow.connect([ (inputnode, merge_xforms, [ ("MNI152NLin2009cAsym_to_anat_xfm", "in2"), ("aslref2anat_xfm", "in3"), ]), - ]) - # fmt:on + ]) # fmt:skip # Using the generated transforms, apply them to get everything in the correct MNI form warp_atlases_to_asl_space = pe.MapNode( @@ -735,13 +733,11 @@ def init_parcellate_cbf_wf( n_procs=omp_nthreads, ) - # fmt:off workflow.connect([ (inputnode, warp_atlases_to_asl_space, [("asl_mask", "reference_image")]), (atlas_file_grabber, warp_atlases_to_asl_space, [("atlas_file", "input_image")]), (merge_xforms, warp_atlases_to_asl_space, [("out", "transforms")]), - ]) - # fmt:on + ]) # fmt:skip for cbf_type in cbf_3d: parcellate_cbf = pe.MapNode( @@ -751,7 +747,6 @@ def init_parcellate_cbf_wf( mem_gb=mem_gb, ) - # fmt:off workflow.connect([ (inputnode, parcellate_cbf, [ (cbf_type, "in_file"), @@ -759,8 +754,7 @@ def init_parcellate_cbf_wf( ]), (atlas_file_grabber, parcellate_cbf, [("atlas_labels_file", "atlas_labels")]), (warp_atlases_to_asl_space, parcellate_cbf, [("output_image", "atlas")]), - ]) - # fmt:on + ]) # fmt:skip ds_cbf = pe.MapNode( DerivativesDataSink( @@ -829,7 +823,6 @@ def init_parcellate_cbf_wf( run_without_submitting=True, ) - # fmt:off workflow.connect([ (inputnode, ds_atlas, [("source_file", "source_file")]), (atlas_file_grabber, ds_atlas, [("atlas_file", "in_file")]), @@ -840,8 +833,7 @@ def init_parcellate_cbf_wf( ("suffix", "suffix"), ("extension", "extension"), ]), - ]) - # fmt:on + ]) # fmt:skip ds_atlas_labels_file = pe.MapNode( DerivativesDataSink( @@ -867,7 +859,6 @@ def init_parcellate_cbf_wf( run_without_submitting=True, ) - # fmt:off workflow.connect([ (inputnode, ds_atlas_labels_file, [("source_file", "source_file")]), (atlas_file_grabber, ds_atlas_labels_file, [("atlas_labels_file", "in_file")]), @@ -875,8 +866,7 @@ def init_parcellate_cbf_wf( ("atlas", "atlas"), ("suffix", "suffix"), ]), - ]) - # fmt:on + ]) # fmt:skip ds_atlas_metadata = pe.MapNode( DerivativesDataSink( @@ -902,7 +892,6 @@ def init_parcellate_cbf_wf( run_without_submitting=True, ) - # fmt:off workflow.connect([ (inputnode, ds_atlas_metadata, [("source_file", "source_file")]), (atlas_file_grabber, ds_atlas_metadata, [("atlas_metadata_file", "in_file")]), @@ -910,7 +899,6 @@ def init_parcellate_cbf_wf( ("atlas", "atlas"), ("suffix", "suffix"), ]), - ]) - # fmt:on + ]) # fmt:skip return workflow diff --git a/aslprep/workflows/asl/confounds.py b/aslprep/workflows/asl/confounds.py index ff9ca3673..45f907922 100644 --- a/aslprep/workflows/asl/confounds.py +++ b/aslprep/workflows/asl/confounds.py @@ -428,7 +428,6 @@ def init_carpetplot_wf( if cifti_output: workflow.connect(inputnode, "cifti_asl", conf_plot, "in_cifti") - # fmt:off workflow.connect([ (inputnode, mrg_xfms, [ ("aslref2anat_xfm", "in1"), @@ -449,8 +448,7 @@ def init_carpetplot_wf( (parcels, conf_plot, [("out", "in_segm")]), (conf_plot, ds_report_asl_conf, [("out_file", "in_file")]), (conf_plot, outputnode, [("out_file", "out_carpetplot")]), - ]) - # fmt:on + ]) # fmt:skip return workflow diff --git a/aslprep/workflows/asl/fit.py b/aslprep/workflows/asl/fit.py index b734eb4d6..c17c76b44 100644 --- a/aslprep/workflows/asl/fit.py +++ b/aslprep/workflows/asl/fit.py @@ -323,7 +323,6 @@ def init_asl_fit_wf( output_dir=config.execution.aslprep_dir, ) - # fmt:off workflow.connect([ # XXX: Was from hmc_aslref_wf (inputnode, hmcref_buffer, [("dummy_scans", "dummy_scans")]), @@ -355,8 +354,7 @@ def init_asl_fit_wf( ("aslref2anat_xfm", "inputnode.aslref2anat_xfm"), ]), (summary, asl_fit_reports_wf, [("out_report", "inputnode.summary_report")]), - ]) - # fmt:on + ]) # fmt:skip # Stage 1: Generate motion correction aslref if not have_hmcref: @@ -380,7 +378,6 @@ def init_asl_fit_wf( ) ds_hmc_aslref_wf.inputs.inputnode.source_files = [asl_file] - # fmt:off workflow.connect([ (hmc_aslref_wf, hmcref_buffer, [ ("outputnode.asl_file", "asl_file"), @@ -390,8 +387,7 @@ def init_asl_fit_wf( (hmc_aslref_wf, asl_fit_reports_wf, [ ("outputnode.validation_report", "inputnode.validation_report"), ]), - ]) - # fmt:on + ]) # fmt:skip else: config.loggers.workflow.info("Found HMC aslref - skipping Stage 1") @@ -400,12 +396,10 @@ def init_asl_fit_wf( hmcref_buffer.inputs.aslref = precomputed["hmc_aslref"] - # fmt:off workflow.connect([ (validate_asl, hmcref_buffer, [("out_file", "asl_file")]), (validate_asl, asl_fit_reports_wf, [("out_report", "inputnode.validation_report")]), - ]) - # fmt:on + ]) # fmt:skip # Reduce the ASL series to only include volumes that need to be processed. processing_target = pe.Node( @@ -421,14 +415,13 @@ def init_asl_fit_wf( ReduceASLFiles(metadata=metadata), name="reduce_asl_file", ) - # fmt:off + workflow.connect([ (inputnode, processing_target, [("aslcontext", "aslcontext")]), (inputnode, reduce_asl_file, [("aslcontext", "aslcontext")]), (processing_target, reduce_asl_file, [("processing_target", "processing_target")]), (hmcref_buffer, reduce_asl_file, [("asl_file", "asl_file")]), - ]) - # fmt:on + ]) # fmt:skip # Stage 2: Estimate head motion if not hmc_xforms: @@ -451,7 +444,6 @@ def init_asl_fit_wf( ds_hmc_wf.get_node("ds_xforms").inputs.datatype = "perf" ds_hmc_wf.get_node("ds_xforms").inputs.to = "aslref" - # fmt:off workflow.connect([ (hmcref_buffer, asl_hmc_wf, [("aslref", "inputnode.raw_ref_image")]), (reduce_asl_file, asl_hmc_wf, [ @@ -464,8 +456,7 @@ def init_asl_fit_wf( ("outputnode.movpar_file", "movpar_file"), ("outputnode.rmsd_file", "rmsd_file"), ]), - ]) - # fmt:on + ]) # fmt:skip else: config.loggers.workflow.info("Found motion correction transforms - skipping Stage 2") hmc_buffer.inputs.hmc_xforms = hmc_xforms @@ -486,15 +477,13 @@ def init_asl_fit_wf( name="ds_coreg_aslref_wf", ) - # fmt:off workflow.connect([ (hmcref_buffer, fmapref_buffer, [("aslref", "aslref_files")]), (fmapref_buffer, enhance_aslref_wf, [("out", "inputnode.in_file")]), (fmapref_buffer, ds_coreg_aslref_wf, [("out", "inputnode.source_files")]), (ds_coreg_aslref_wf, regref_buffer, [("outputnode.aslref", "aslref")]), (fmapref_buffer, asl_fit_reports_wf, [("out", "inputnode.sdc_aslref")]), - ]) - # fmt:on + ]) # fmt:skip if fieldmap_id: fmap_select = pe.Node( @@ -527,7 +516,6 @@ def init_asl_fit_wf( name="ds_fmapreg_wf", ) - # fmt:off workflow.connect([ (enhance_aslref_wf, fmapreg_wf, [ ("outputnode.bias_corrected_file", "inputnode.target_ref"), @@ -541,8 +529,7 @@ def init_asl_fit_wf( (itk_mat2txt, ds_fmapreg_wf, [("out_xfm", "inputnode.xform")]), (fmapref_buffer, ds_fmapreg_wf, [("out", "inputnode.source_files")]), (ds_fmapreg_wf, fmapreg_buffer, [("outputnode.xform", "aslref2fmap_xfm")]), - ]) - # fmt:on + ]) # fmt:skip else: fmapreg_buffer.inputs.aslref2fmap_xfm = aslref2fmap_xform @@ -553,7 +540,6 @@ def init_asl_fit_wf( ) unwarp_wf.inputs.inputnode.metadata = layout.get_metadata(asl_file) - # fmt:off workflow.connect([ (inputnode, fmap_select, [ ("fmap_ref", "fmap_ref"), @@ -581,17 +567,14 @@ def init_asl_fit_wf( ("aslref2fmap_xfm", "inputnode.aslref2fmap_xfm"), ]), (unwarp_wf, asl_fit_reports_wf, [("outputnode.fieldmap", "inputnode.fieldmap")]), - ]) - # fmt:on + ]) # fmt:skip else: - # fmt:off workflow.connect([ (enhance_aslref_wf, ds_coreg_aslref_wf, [ ("outputnode.bias_corrected_file", "inputnode.aslref"), ]), (enhance_aslref_wf, regref_buffer, [("outputnode.mask_file", "aslmask")]), - ]) - # fmt:on + ]) # fmt:skip else: config.loggers.workflow.info("Found coregistration reference - skipping Stage 3") regref_buffer.inputs.aslref = precomputed["coreg_aslref"] @@ -620,7 +603,6 @@ def init_asl_fit_wf( name="ds_aslreg_wf", ) - # fmt:off workflow.connect([ (inputnode, asl_reg_wf, [ ("t1w_preproc", "inputnode.t1w_preproc"), @@ -637,8 +619,7 @@ def init_asl_fit_wf( (asl_reg_wf, ds_aslreg_wf, [("outputnode.itk_bold_to_t1", "inputnode.xform")]), (ds_aslreg_wf, outputnode, [("outputnode.xform", "aslref2anat_xfm")]), (asl_reg_wf, summary, [("outputnode.fallback", "fallback")]), - ]) - # fmt:on + ]) # fmt:skip else: outputnode.inputs.aslref2anat_xfm = aslref2anat_xform @@ -789,7 +770,7 @@ def init_asl_native_wf( ReduceASLFiles(metadata=metadata), name="reduce_asl_file", ) - # fmt:off + workflow.connect([ (inputnode, processing_target, [("aslcontext", "aslcontext")]), (processing_target, reduce_asl_file, [("processing_target", "processing_target")]), @@ -800,8 +781,7 @@ def init_asl_native_wf( ("aslcontext", "aslcontext"), ("metadata", "metadata"), ]), - ]) - # fmt:on + ]) # fmt:skip # Prepare fieldmap metadata if fieldmap_id: diff --git a/aslprep/workflows/asl/outputs.py b/aslprep/workflows/asl/outputs.py index 003450a0a..e3557d4eb 100644 --- a/aslprep/workflows/asl/outputs.py +++ b/aslprep/workflows/asl/outputs.py @@ -282,7 +282,6 @@ def init_asl_fit_reports_wf( mem_gb=1, ) - # fmt:off workflow.connect([ (inputnode, ds_summary, [ ("source_file", "source_file"), @@ -303,8 +302,7 @@ def init_asl_fit_reports_wf( ("aslref2anat_xfm", "transforms"), ]), (t1w_wm, aslref_wm, [("out", "input_image")]), - ]) - # fmt:on + ]) # fmt:skip # Reportlets follow the structure of init_asl_fit_wf stages # - SDC1: @@ -376,7 +374,6 @@ def init_asl_fit_reports_wf( name="ds_sdc_report", ) - # fmt:off workflow.connect([ (inputnode, fmapref_aslref, [ ("fmap_ref", "input_image"), @@ -397,8 +394,7 @@ def init_asl_fit_reports_wf( (aslref_wm, sdc_report, [("output_image", "wm_seg")]), (inputnode, ds_sdc_report, [("source_file", "source_file")]), (sdc_report, ds_sdc_report, [("out_report", "in_file")]), - ]) - # fmt:on + ]) # fmt:skip # EPI-T1 registration # Resample T1w image onto EPI-space @@ -424,15 +420,13 @@ def init_asl_fit_reports_wf( name="ds_epi_t1_report", ) - # fmt:off workflow.connect([ (inputnode, epi_t1_report, [("coreg_aslref", "after")]), (t1w_aslref, epi_t1_report, [("output_image", "before")]), (aslref_wm, epi_t1_report, [("output_image", "wm_seg")]), (inputnode, ds_epi_t1_report, [("source_file", "source_file")]), (epi_t1_report, ds_epi_t1_report, [("out_report", "in_file")]), - ]) - # fmt:on + ]) # fmt:skip return workflow @@ -468,7 +462,6 @@ def init_ds_aslref_wf( run_without_submitting=True, ) - # fmt:off workflow.connect([ (inputnode, raw_sources, [("source_files", "in_files")]), (inputnode, ds_aslref, [ @@ -477,8 +470,7 @@ def init_ds_aslref_wf( ]), (raw_sources, ds_aslref, [("out", "RawSources")]), (ds_aslref, outputnode, [("out_file", "aslref")]), - ]) - # fmt:on + ]) # fmt:skip return workflow