@@ -495,8 +495,7 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
495495 "switch": ["run"],
496496 "option_key": "using",
497497 "option_val": "Blip-FSL-TOPUP",
498- "inputs": [(["desc-preproc_bold", "bold"],
499- "space-bold_desc-brain_mask"),
498+ "inputs": [("desc-mean_bold", "space-bold_desc-brain_mask"),
500499 "pe-direction",
501500 "epi-1",
502501 "epi-1-pedir",
@@ -547,12 +546,12 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
547546
548547 else:
549548 '''
550-
549+
551550 create_list = pe .Node (interface = util .Merge (2 ), name = "create_list" )
552551
553552 node , out = strat_pool .get_data ('epi-1' )
554553 wf .connect (node , out , create_list , 'in1' )
555-
554+
556555 node , out = strat_pool .get_data ('epi-2' )
557556 wf .connect (node , out , create_list , 'in2' )
558557
@@ -566,26 +565,28 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
566565 Mask .inputs .operand_value = 0
567566 Mask .inputs .operation = "mul"
568567 Mask .inputs .args = "-add 1"
569-
568+
570569 node , out = strat_pool .get_data ('epi-1' )
571570 wf .connect (node , out , Mask , 'in_file' )
572571
573- #zpad_phases = z_pad("zpad_phases")
574- #wf.connect(merge_image, "merged_file", zpad_phases, "inputspec.input_image")
572+ # zpad_phases = z_pad("zpad_phases")
573+ # wf.connect(merge_image, "merged_file", zpad_phases, "inputspec.input_image")
575574
576- #zpad_mask = z_pad("zpad_mask")
577- #wf.connect(Mask, "out_file", zpad_mask, "inputspec.input_image")
575+ # zpad_mask = z_pad("zpad_mask")
576+ # wf.connect(Mask, "out_file", zpad_mask, "inputspec.input_image")
578577
579578 # extrapolate existing values beyond the mask
580- extrap_vals = pe .Node (interface = fsl .maths .BinaryMaths (),
579+ extrap_vals = pe .Node (interface = fsl .maths .BinaryMaths (),
581580 name = "extrap_vals" )
582581 extrap_vals .inputs .operation = "add"
583582 extrap_vals .inputs .operand_value = 1
584583 extrap_vals .inputs .args = "-abs -dilM -dilM -dilM -dilM -dilM"
585-
586- #wf.connect(zpad_phases, "outputspec.output_image", extrap_vals, "in_file")
587- #wf.connect(zpad_mask, "outputspec.output_image", extrap_vals, "operand_file")
588-
584+
585+ # wf.connect(zpad_phases, "outputspec.output_image",
586+ # extrap_vals, "in_file")
587+ # wf.connect(zpad_mask, "outputspec.output_image",
588+ # extrap_vals, "operand_file")
589+
589590 wf .connect (merge_image , "merged_file" , extrap_vals , "in_file" )
590591 wf .connect (Mask , "out_file" , extrap_vals , "operand_file" )
591592
@@ -647,97 +648,93 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
647648 wf .connect (phase_encoding , "acq_params" , run_topup , "acqparams" )
648649
649650 choose_phase = pe .Node (
650- util .Function (
651- input_names = ["phase_imgs" ,
651+ util .Function (
652+ input_names = ["phase_imgs" ,
652653 "unwarp_dir" ],
653654 output_names = ["out_phase_image" ,
654655 "vnum" ],
655656 function = choose_phase_image
656- ),
657- name = "choose_phase" ,
657+ ), name = "choose_phase" ,
658658 )
659-
659+
660660 wf .connect (create_list , 'out' , choose_phase , 'phase_imgs' )
661661
662662 node , out = strat_pool .get_data ("pe-direction" )
663663 wf .connect (node , out , choose_phase , "unwarp_dir" )
664664
665665 vnum_base = pe .Node (
666- util .Function (
667- input_names = ["vnum" ,
666+ util .Function (
667+ input_names = ["vnum" ,
668668 "motion_mat_list" ,
669669 "jac_matrix_list" ,
670670 "warp_field_list" ],
671671 output_names = ["out_motion_mat" ,
672672 "out_jacobian" ,
673673 "out_warp_field" ],
674674 function = find_vnum_base
675- ),
676- name = "Motion_Jac_Warp_matrices" ,
677- )
675+ ), name = "Motion_Jac_Warp_matrices" ,
676+ )
678677
679678 wf .connect (choose_phase , 'vnum' , vnum_base , 'vnum' )
680679 wf .connect (run_topup , 'out_xfms' , vnum_base , 'motion_mat_list' )
681680 wf .connect (run_topup , 'out_jacs' , vnum_base , 'jac_matrix_list' )
682681 wf .connect (run_topup , 'out_warps' , vnum_base , 'warp_field_list' )
683682
684- create_scout = pe .Node (interface = afni_utils .Calc (),
685- name = "topupwf_create_scout" )
686- create_scout .inputs .set (
687- expr = 'a' ,
688- single_idx = 0 ,
689- outputtype = 'NIFTI_GZ'
690- )
683+ # create_scout = pe.Node(interface=afni_utils.Calc(),
684+ # name="topupwf_create_scout")
685+ # create_scout.inputs.set(
686+ # expr='a',
687+ # single_idx=0,
688+ # outputtype='NIFTI_GZ'
689+ # )
691690
692- node , out = strat_pool .get_data (["desc-preproc_bold" , "bold" ])
693- wf .connect (node , out , create_scout , 'in_file_a' )
691+ mean_bold = strat_pool .node_data ("desc-mean_bold" )
692+ # node, out = strat_pool.get_data(["desc-preproc_bold", "bold"])
693+ # wf.connect(node, out, create_scout, 'in_file_a')
694694
695695 flirt = pe .Node (interface = fsl .FLIRT (), name = "flirt" )
696696 flirt .inputs .dof = 6
697697 flirt .inputs .interp = 'spline'
698698 flirt .inputs .out_matrix_file = 'SBRef2PhaseTwo_gdc.mat'
699699
700- wf .connect (create_scout , 'out_file' , flirt , 'in_file' )
700+ wf .connect (mean_bold . node , mean_bold . out , flirt , 'in_file' )
701701 wf .connect (choose_phase , 'out_phase_image' , flirt , 'reference' )
702-
703- #fsl_convert_xfm
702+
703+ # fsl_convert_xfm
704704 convert_xfm = pe .Node (interface = fsl .ConvertXFM (), name = "convert_xfm" )
705705 convert_xfm .inputs .concat_xfm = True
706706 convert_xfm .inputs .out_file = 'SBRef2WarpField.mat'
707707
708- wf .connect (flirt , 'out_matrix_file' , convert_xfm ,'in_file' )
709- wf .connect (vnum_base , 'out_motion_mat' , convert_xfm ,'in_file2' )
708+ wf .connect (flirt , 'out_matrix_file' , convert_xfm , 'in_file' )
709+ wf .connect (vnum_base , 'out_motion_mat' , convert_xfm , 'in_file2' )
710710
711- #fsl_convert_warp
711+ # fsl_convert_warp
712712 convert_warp = pe .Node (interface = fsl .ConvertWarp (),
713- name = "convert_warp" )
713+ name = "convert_warp" )
714714 convert_warp .inputs .relwarp = True
715715 convert_warp .inputs .out_relwarp = True
716716 convert_warp .inputs .out_file = 'WarpField.nii.gz'
717717
718718 wf .connect (choose_phase , 'out_phase_image' , convert_warp , 'reference' )
719719 wf .connect (vnum_base , 'out_warp_field' , convert_warp , 'warp1' )
720- wf .connect (convert_xfm , 'out_file' ,convert_warp , 'premat' )
721-
722- out_convert_warp = (convert_warp ,'out_file' )
720+ wf .connect (convert_xfm , 'out_file' , convert_warp , 'premat' )
723721
724- VolumeNumber = 1 + 1
722+ VolumeNumber = 1 + 1
725723 vnum = str (VolumeNumber ).zfill (2 )
726724 name = "PhaseTwo_aw"
727725
728726 vnum_base_two = pe .Node (
729- util .Function (
727+ util .Function (
730728 input_names = ["vnum" ,
731729 "motion_mat_list" ,
732730 "jac_matrix_list" ,
733731 "warp_field_list" ],
734- output_names = ["out_motion_mat" ,
735- "out_jacobian" ,
732+ output_names = ["out_motion_mat" ,
733+ "out_jacobian" ,
736734 "out_warp_field" ],
737735 function = find_vnum_base
738- ),
739- name = f"Motion_Jac_Warp_matrices_{ name } " ,
740- )
736+ ), name = f"Motion_Jac_Warp_matrices_{ name } " ,
737+ )
741738 vnum_base_two .inputs .vnum = vnum
742739
743740 wf .connect (run_topup , 'out_xfms' , vnum_base_two , 'motion_mat_list' )
@@ -748,7 +745,7 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
748745 aw_two = pe .Node (interface = fsl .ApplyWarp (), name = "aw_two" )
749746 aw_two .inputs .relwarp = True
750747 aw_two .inputs .interp = 'spline'
751-
748+
752749 node , out = strat_pool .get_data ('epi-2' )
753750 wf .connect (node , out , aw_two , 'in_file' )
754751 wf .connect (node , out , aw_two , 'ref_file' )
@@ -762,14 +759,15 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
762759
763760 wf .connect (aw_two , 'out_file' , mul_phase_two , 'in_file' )
764761 wf .connect (vnum_base_two , 'out_jacobian' , mul_phase_two , 'operand_file' )
765-
766- # PhaseOne (first vol) - warp and Jacobian modulate to get distortion corrected output
767- VolumeNumber = 0 + 1
762+
763+ # PhaseOne (first vol) - warp and Jacobian modulate to get
764+ # distortion corrected output
765+ VolumeNumber = 0 + 1
768766 vnum = str (VolumeNumber ).zfill (2 )
769767 name = "PhaseOne_aw"
770768
771769 vnum_base_one = pe .Node (
772- util .Function (
770+ util .Function (
773771 input_names = ["vnum" ,
774772 "motion_mat_list" ,
775773 "jac_matrix_list" ,
@@ -778,17 +776,16 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
778776 "out_jacobian" ,
779777 "out_warp_field" ],
780778 function = find_vnum_base
781- ),
782- name = f"Motion_Jac_Warp_matrices_{ name } " ,
783- )
779+ ), name = f"Motion_Jac_Warp_matrices_{ name } " ,
780+ )
784781 vnum_base_one .inputs .vnum = vnum
785782
786783 wf .connect (run_topup , 'out_xfms' , vnum_base_one , 'motion_mat_list' )
787784 wf .connect (run_topup , 'out_jacs' , vnum_base_one , 'jac_matrix_list' )
788785 wf .connect (run_topup , 'out_warps' , vnum_base_one , 'warp_field_list' )
789786
790787 # fsl_applywarp to phaseOne
791- aw_one = pe .Node (interface = fsl .ApplyWarp (),name = "aw_one" )
788+ aw_one = pe .Node (interface = fsl .ApplyWarp (), name = "aw_one" )
792789 aw_one .inputs .relwarp = True
793790 aw_one .inputs .interp = 'spline'
794791
@@ -799,7 +796,7 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
799796 wf .connect (vnum_base_one , 'out_motion_mat' , aw_one , 'premat' )
800797 wf .connect (vnum_base_one , 'out_warp_field' , aw_one , 'field_file' )
801798
802- mul_phase_one = pe .Node (interface = fsl .BinaryMaths (), name = "mul_phase_one" )
799+ mul_phase_one = pe .Node (interface = fsl .BinaryMaths (), name = "mul_phase_one" )
803800 mul_phase_one .inputs .operation = 'mul'
804801
805802 wf .connect (aw_one , 'out_file' , mul_phase_one , 'in_file' )
@@ -810,19 +807,20 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
810807 aw_jac .inputs .relwarp = True
811808 aw_jac .inputs .interp = 'spline'
812809
813- wf .connect (create_scout , 'out_file' , aw_jac , 'in_file' ) #SBRef.nii.gz
814- wf .connect (create_scout , 'out_file' , aw_jac , 'ref_file' ) #SBRef.nii.gz
810+ wf .connect (mean_bold .node , mean_bold .out , aw_jac , 'in_file' ) # SBRef.nii.gz
811+ wf .connect (mean_bold .node , mean_bold .out ,
812+ aw_jac , 'ref_file' ) # SBRef.nii.gz
815813 wf .connect (convert_warp , 'out_file' , aw_jac , 'field_file' )
816814
817- mul_jac = pe .Node (interface = fsl .BinaryMaths (),name = "mul_jac" )
815+ mul_jac = pe .Node (interface = fsl .BinaryMaths (), name = "mul_jac" )
818816 mul_jac .inputs .operation = 'mul'
819817 mul_jac .inputs .out_file = "SBRef_dc_jac.nii.gz"
820818
821819 wf .connect (aw_jac , 'out_file' , mul_jac , 'in_file' )
822820 wf .connect (vnum_base , 'out_jacobian' , mul_jac , 'operand_file' )
823821
824- #Calculate Equivalent Field Map
825- tp_field_map = pe .Node (interface = fsl .BinaryMaths (),name = "tp_field_map" )
822+ # Calculate Equivalent Field Map
823+ tp_field_map = pe .Node (interface = fsl .BinaryMaths (), name = "tp_field_map" )
826824 tp_field_map .inputs .operation = 'mul'
827825 tp_field_map .inputs .operand_value = 6.283
828826
@@ -835,8 +833,8 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
835833
836834 wf .connect (run_topup , 'corrected_outfile' , mag_field_map , 'in_file' )
837835
838- #fsl_bet
839- bet = pe .Node (interface = fsl .BET (), name = "bet" )
836+ # fsl_bet
837+ bet = pe .Node (interface = fsl .BET (), name = "bet" )
840838 bet .inputs .frac = 0.35
841839 bet .inputs .mask = True
842840
0 commit comments