Skip to content

Commit 262c2fc

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9d89c6f commit 262c2fc

File tree

3 files changed

+48
-31
lines changed

3 files changed

+48
-31
lines changed

CPAC/func_preproc/func_preproc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,9 +1926,7 @@ def template_space_bold_masking(
19261926
func_apply_mask.inputs.expr = "a*b"
19271927
func_apply_mask.inputs.outputtype = "NIFTI_GZ"
19281928

1929-
node_head_bold, out_head_bold = strat_pool.get_data(
1930-
"space-template_desc-head_bold"
1931-
)
1929+
node_head_bold, out_head_bold = strat_pool.get_data("space-template_desc-head_bold")
19321930
wf.connect(node_head_bold, out_head_bold, func_apply_mask, "in_file_a")
19331931

19341932
node, out = strat_pool.get_data("space-template_desc-bold_mask")

CPAC/pipeline/cpac_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None):
14841484
pipeline_blocks += [
14851485
template_space_bold_masking,
14861486
]
1487-
1487+
14881488
# Template-space nuisance regression
14891489
nuisance_template = (
14901490
cfg["nuisance_corrections", "2-nuisance_regression", "space"] == "template"

CPAC/registration/registration.py

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from voluptuous import RequiredFieldInvalid
2323
from nipype.interfaces import afni, ants, c3, fsl, utility as util
2424
from nipype.interfaces.afni import utils as afni_utils
25-
from pathlib import Path
25+
from pathlib import Path
2626

2727
from CPAC.anat_preproc.lesion_preproc import create_lesion_preproc
2828
from CPAC.func_preproc.func_preproc import fsl_afni_subworkflow
@@ -4202,14 +4202,14 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
42024202
input_names=["workdir"],
42034203
output_names=["identity_file"],
42044204
function=lambda workdir: (
4205-
np.savetxt(Path(workdir) / "identity.mat", np.eye(4), fmt="%.6f") or
4206-
str(Path(workdir) / "identity.mat")
4207-
)
4205+
np.savetxt(Path(workdir) / "identity.mat", np.eye(4), fmt="%.6f")
4206+
or str(Path(workdir) / "identity.mat")
4207+
),
42084208
),
4209-
name=f"create_identity_matrix_{pipe_num}"
4209+
name=f"create_identity_matrix_{pipe_num}",
42104210
)
42114211
identity_node.inputs.workdir = str(Path.cwd())
4212-
4212+
42134213
convert_func_to_anat_linear_warp = pe.Node(
42144214
interface=fsl.ConvertWarp(), name=f"convert_func_to_anat_linear_warp_{pipe_num}"
42154215
)
@@ -4248,7 +4248,8 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
42484248

42494249
node, out = strat_pool.get_data("space-template_res-bold_desc-head_T1w")
42504250
wf.connect(
4251-
node, out,
4251+
node,
4252+
out,
42524253
convert_func_to_standard_warp,
42534254
"reference",
42544255
)
@@ -4278,7 +4279,9 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
42784279
### Loop starts! ###
42794280
# Match FOV func_to_standard
42804281
match_fov_func = pe.MapNode(
4281-
interface=fsl.FLIRT(apply_xfm=True, interp="spline"), name=f"match_fov_func_{pipe_num}", iterfield=["in_file"]
4282+
interface=fsl.FLIRT(apply_xfm=True, interp="spline"),
4283+
name=f"match_fov_func_{pipe_num}",
4284+
iterfield=["in_file"],
42824285
)
42834286
wf.connect(identity_node, "identity_file", match_fov_func, "in_matrix_file")
42844287
wf.connect(split_func, "out_files", match_fov_func, "in_file")
@@ -4317,7 +4320,10 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
43174320

43184321
node, out = strat_pool.get_data("space-template_res-bold_desc-head_T1w")
43194322
wf.connect(
4320-
node, out, convert_registration_warp, "reference",
4323+
node,
4324+
out,
4325+
convert_registration_warp,
4326+
"reference",
43214327
)
43224328

43234329
wf.connect(
@@ -4345,7 +4351,10 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
43454351

43464352
node, out = strat_pool.get_data("space-template_res-bold_desc-head_T1w")
43474353
wf.connect(
4348-
node, out, applywarp_func_to_standard, "ref_file",
4354+
node,
4355+
out,
4356+
applywarp_func_to_standard,
4357+
"ref_file",
43494358
)
43504359

43514360
# applywarp --rel --interp=nn --in=${WD}/prevols/vol${vnum}_mask.nii.gz --warp=${MotionMatrixFolder}/${MotionMatrixPrefix}${vnum}_all_warp.nii.gz --ref=${WD}/${T1wImageFile}.${FinalfMRIResolution} --out=${WD}/postvols/vol${vnum}_mask.nii.gz
@@ -4358,9 +4367,7 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
43584367
applywarp_func_mask_to_standard.inputs.interp = "nn"
43594368

43604369
node, out = strat_pool.get_data("space-template_desc-bold_mask")
4361-
wf.connect(
4362-
node, out, applywarp_func_mask_to_standard, "in_file"
4363-
)
4370+
wf.connect(node, out, applywarp_func_mask_to_standard, "in_file")
43644371

43654372
wf.connect(
43664373
convert_registration_warp,
@@ -4371,7 +4378,10 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
43714378

43724379
node, out = strat_pool.get_data("space-template_res-bold_desc-head_T1w")
43734380
wf.connect(
4374-
node, out, applywarp_func_mask_to_standard, "ref_file",
4381+
node,
4382+
out,
4383+
applywarp_func_mask_to_standard,
4384+
"ref_file",
43754385
)
43764386

43774387
### Loop ends! ###
@@ -4412,16 +4422,18 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
44124422

44134423
# Match FOV scout_to_standard
44144424
match_fov_scout_to_standard = pe.MapNode(
4415-
interface=fsl.FLIRT(apply_xfm=True, interp="spline"), name=f"match_fov_scout_to_standard_{pipe_num}", iterfield=["in_file"]
4425+
interface=fsl.FLIRT(apply_xfm=True, interp="spline"),
4426+
name=f"match_fov_scout_to_standard_{pipe_num}",
4427+
iterfield=["in_file"],
4428+
)
4429+
wf.connect(
4430+
identity_node, "identity_file", match_fov_scout_to_standard, "in_matrix_file"
44164431
)
4417-
wf.connect(identity_node, "identity_file", match_fov_scout_to_standard, "in_matrix_file")
44184432
node, out = strat_pool.get_data("motion-basefile")
44194433
wf.connect(node, out, match_fov_scout_to_standard, "in_file")
44204434

44214435
node, out = strat_pool.get_data("space-template_res-bold_desc-head_T1w")
4422-
wf.connect(
4423-
node, out, match_fov_scout_to_standard, "reference"
4424-
)
4436+
wf.connect(node, out, match_fov_scout_to_standard, "reference")
44254437

44264438
# applywarp --rel --interp=spline --in=${ScoutInput} -w ${WD}/Scout_gdc_MNI_warp.nii.gz -r ${WD}/${T1wImageFile}.${FinalfMRIResolution} -o ${ScoutOutput}
44274439
applywarp_scout = pe.Node(
@@ -4434,7 +4446,10 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
44344446

44354447
node, out = strat_pool.get_data("space-template_res-bold_desc-head_T1w")
44364448
wf.connect(
4437-
node, out, applywarp_scout, "ref_file",
4449+
node,
4450+
out,
4451+
applywarp_scout,
4452+
"ref_file",
44384453
)
44394454

44404455
# warp field is just fMRI->standard (skip GDC)
@@ -4446,7 +4461,10 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
44464461

44474462
node, out = strat_pool.get_data("space-template_desc-bold_mask")
44484463
wf.connect(
4449-
node, out, merge_func_mask, "in1",
4464+
node,
4465+
out,
4466+
merge_func_mask,
4467+
"in1",
44504468
)
44514469

44524470
wf.connect(find_min_mask, "out_file", merge_func_mask, "in2")
@@ -5601,29 +5619,30 @@ def create_identity_matrix(workdir):
56015619
np.savetxt(identity_file, np.eye(4), fmt="%.6f")
56025620
return str(identity_file)
56035621

5622+
56045623
def build_match_fov_wf(name, workdir, pipe_num):
56055624
"""
56065625
Workflow to match Field-of-View for T1w or functional images
56075626
using an identity matrix.
56085627
"""
56095628
wf = Workflow(name=name)
5610-
5629+
56115630
identity_node = Node(
56125631
Function(
56135632
input_names=["workdir"],
56145633
output_names=["identity_file"],
5615-
function=create_identity_matrix
5634+
function=create_identity_matrix,
56165635
),
5617-
name=f"create_identity_matrix_{pipe_num}"
5636+
name=f"create_identity_matrix_{pipe_num}",
56185637
)
56195638
identity_node.inputs.workdir = workdir
56205639

56215640
match_fov_node = MapNode(
56225641
interface=fsl.FLIRT(apply_xfm=True, interp="spline"),
56235642
name=f"match_fov_{pipe_num}",
5624-
iterfield=["in_file"]
5643+
iterfield=["in_file"],
56255644
)
5626-
5645+
56275646
wf.connect(identity_node, "identity_file", match_fov_node, "in_matrix_file")
56285647

5629-
return wf, match_fov_node
5648+
return wf, match_fov_node

0 commit comments

Comments
 (0)