Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 8, 2024
1 parent c4466ff commit 0e37b96
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 33 deletions.
34 changes: 21 additions & 13 deletions pydra/tasks/ants/v2_5/apply_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ def _format_output(
return "-o {}".format(
f"Linear[{output_transform},{invert_transform:%d}]"
if save_transform
else f"[{output_warp_field},{save_warp_field:%d}]"
if save_warp_field
else f"{output_image}"
else (
f"[{output_warp_field},{save_warp_field:%d}]"
if save_warp_field
else f"{output_image}"
)
)


Expand All @@ -30,11 +32,15 @@ def _format_interpolation(
) -> str:
return "-n {}{}".format(
interpolator,
f"[{order}]"
if interpolator == "BSpline"
else f"[{sigma},{alpha}]"
if interpolator in ("MultiLabel", "Gaussian")
else "",
(
f"[{order}]"
if interpolator == "BSpline"
else (
f"[{sigma},{alpha}]"
if interpolator in ("MultiLabel", "Gaussian")
else ""
)
),
)


Expand Down Expand Up @@ -202,11 +208,13 @@ class InputSpec(ShellSpec):
"formatter": lambda input_transforms, invert_transforms: (
""
if not input_transforms
else " ".join(f"-t {f}" for f in input_transforms)
if not invert_transforms
else " ".join(
f"-t [{f},{int(i)}]"
for f, i in zip(input_transforms, invert_transforms)
else (
" ".join(f"-t {f}" for f in input_transforms)
if not invert_transforms
else " ".join(
f"-t [{f},{int(i)}]"
for f, i in zip(input_transforms, invert_transforms)
)
)
),
}
Expand Down
46 changes: 26 additions & 20 deletions pydra/tasks/ants/v2_5/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ def _format_syn_transform_type(
return (
"-t {}[{}]".format(
syn_transform_type,
f"{syn_gradient_step},{syn_spline_distance},0,{syn_spline_order}"
if syn_transform_type == "BSplineSyn"
else f"{syn_gradient_step},{syn_flow_sigma},{syn_total_sigma}",
(
f"{syn_gradient_step},{syn_spline_distance},0,{syn_spline_order}"
if syn_transform_type == "BSplineSyn"
else f"{syn_gradient_step},{syn_flow_sigma},{syn_total_sigma}"
),
)
if enable_syn_stage
else ""
Expand Down Expand Up @@ -172,11 +174,11 @@ class InputSpec(ShellSpec):
"formatter": lambda interpolator, sigma, alpha, order: (
"-n {}{}".format(
interpolator,
f"[{sigma},{alpha}]"
if interpolator == "Gaussian"
else f"[{order}]"
if interpolator == "BSpline"
else "",
(
f"[{sigma},{alpha}]"
if interpolator == "Gaussian"
else f"[{order}]" if interpolator == "BSpline" else ""
),
)
),
}
Expand Down Expand Up @@ -265,12 +267,14 @@ class InputSpec(ShellSpec):
"formatter": lambda initial_fixed_transforms, invert_fixed_transforms: (
""
if not initial_fixed_transforms
else " ".join(f"-q {x}" for x in initial_fixed_transforms)
if not invert_fixed_transforms
else " ".join(
f"-q [{x},{y:d}]"
for x, y in zip(
initial_fixed_transforms, invert_fixed_transforms
else (
" ".join(f"-q {x}" for x in initial_fixed_transforms)
if not invert_fixed_transforms
else " ".join(
f"-q [{x},{y:d}]"
for x, y in zip(
initial_fixed_transforms, invert_fixed_transforms
)
)
)
),
Expand All @@ -290,12 +294,14 @@ class InputSpec(ShellSpec):
"formatter": lambda initial_moving_transforms, invert_moving_transforms, fixed_image, moving_image: (
f"-r [{fixed_image},{moving_image},1]"
if not initial_moving_transforms
else " ".join(f"-r {x}" for x in initial_moving_transforms)
if not invert_moving_transforms
else " ".join(
f"-r [{x},{y:d}]"
for x, y in zip(
initial_moving_transforms, invert_moving_transforms
else (
" ".join(f"-r {x}" for x in initial_moving_transforms)
if not invert_moving_transforms
else " ".join(
f"-r [{x},{y:d}]"
for x, y in zip(
initial_moving_transforms, invert_moving_transforms
)
)
)
),
Expand Down

0 comments on commit 0e37b96

Please sign in to comment.