diff --git a/pydra/tasks/ants/v2_5/apply_transforms.py b/pydra/tasks/ants/v2_5/apply_transforms.py index af9e3a7..770098e 100644 --- a/pydra/tasks/ants/v2_5/apply_transforms.py +++ b/pydra/tasks/ants/v2_5/apply_transforms.py @@ -25,7 +25,9 @@ def _format_output( ) -def _format_interpolation(interpolator: str, sigma: float, alpha: float, order: int) -> str: +def _format_interpolation( + interpolator: str, sigma: float, alpha: float, order: int +) -> str: return "-n {}{}".format( interpolator, f"[{order}]" @@ -70,7 +72,11 @@ class ApplyTransforms(ShellCommandTask): @define(kw_only=True) class InputSpec(ShellSpec): dimensionality: int = field( - metadata={"help_string": "image dimensionality", "argstr": "-d", "allowed_values": {2, 3, 4}} + metadata={ + "help_string": "image dimensionality", + "argstr": "-d", + "allowed_values": {2, 3, 4}, + } ) image_type: str = field( @@ -85,19 +91,32 @@ class InputSpec(ShellSpec): }, ) - moving_image: PathLike = field(metadata={"help_string": "moving image", "mandatory": True, "argstr": "-i"}) + moving_image: PathLike = field( + metadata={"help_string": "moving image", "mandatory": True, "argstr": "-i"} + ) - fixed_image: PathLike = field(metadata={"help_string": "fixed image", "mandatory": True, "argstr": "-r"}) + fixed_image: PathLike = field( + metadata={"help_string": "fixed image", "mandatory": True, "argstr": "-r"} + ) output_: str = field( - metadata={"help_string": "output parameter", "readonly": True, "formatter": _format_output} + metadata={ + "help_string": "output parameter", + "readonly": True, + "formatter": _format_output, + } ) output_image: str = field( - metadata={"help_string": "output image", "output_file_template": "{moving_image}_warped"} + metadata={ + "help_string": "output image", + "output_file_template": "{moving_image}_warped", + } ) - save_warp_field: bool = field(metadata={"help_string": "save composite warp field"}) + save_warp_field: bool = field( + metadata={"help_string": "save composite warp field"} + ) output_warp_field: str = field( metadata={ @@ -107,7 +126,9 @@ class InputSpec(ShellSpec): } ) - save_transform: bool = field(metadata={"help_string": "save composite transform"}) + save_transform: bool = field( + metadata={"help_string": "save composite transform"} + ) output_transform: str = field( metadata={ @@ -118,10 +139,16 @@ class InputSpec(ShellSpec): } ) - invert_transform: bool = field(default=False, metadata={"help_string": "invert composite transform"}) + invert_transform: bool = field( + default=False, metadata={"help_string": "invert composite transform"} + ) interpolation_: str = field( - metadata={"help_string": "interpolation parameter", "readonly": True, "formatter": _format_interpolation} + metadata={ + "help_string": "interpolation parameter", + "readonly": True, + "formatter": _format_interpolation, + } ) interpolator: str = field( @@ -141,17 +168,31 @@ class InputSpec(ShellSpec): }, ) - sigma: float = field(default=1.0, metadata={"help_string": "sigma parameter interpolation"}) + sigma: float = field( + default=1.0, metadata={"help_string": "sigma parameter interpolation"} + ) - alpha: float = field(default=1.0, metadata={"help_string": "alpha parameter for interpolation"}) + alpha: float = field( + default=1.0, metadata={"help_string": "alpha parameter for interpolation"} + ) - order: int = field(default=3, metadata={"help_string": "order parameter for interpolation"}) + order: int = field( + default=3, metadata={"help_string": "order parameter for interpolation"} + ) output_datatype: str = field( metadata={ "help_string": "force output image datatype", "argstr": "-u", - "allowed_values": {"char", "uchar", "short", "int", "float", "double", "default"}, + "allowed_values": { + "char", + "uchar", + "short", + "int", + "float", + "double", + "default", + }, } ) @@ -163,16 +204,24 @@ class InputSpec(ShellSpec): 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},{int(i)}]" + for f, i in zip(input_transforms, invert_transforms) + ) ), } ) invert_transforms: Sequence[bool] = field( - metadata={"help_string": "which transforms to invert", "requires": {"input_transforms"}} + metadata={ + "help_string": "which transforms to invert", + "requires": {"input_transforms"}, + } ) - default_value: float = field(metadata={"help_string": "default voxel value", "argstr": "-f"}) + default_value: float = field( + metadata={"help_string": "default voxel value", "argstr": "-f"} + ) use_float_precision: bool = field( default=False, diff --git a/pydra/tasks/ants/v2_5/bias_correction.py b/pydra/tasks/ants/v2_5/bias_correction.py index 4ec6bb8..ddbd3b4 100644 --- a/pydra/tasks/ants/v2_5/bias_correction.py +++ b/pydra/tasks/ants/v2_5/bias_correction.py @@ -22,12 +22,20 @@ class N4BiasFieldCorrection(ShellCommandTask): @define(kw_only=True) class InputSpec(ShellSpec): dimensionality: int = field( - metadata={"help_string": "image dimensionality", "argstr": "-d", "allowed_values": {2, 3, 4}} + metadata={ + "help_string": "image dimensionality", + "argstr": "-d", + "allowed_values": {2, 3, 4}, + } ) - input_image: PathLike = field(metadata={"help_string": "input image", "mandatory": True, "argstr": "-i"}) + input_image: PathLike = field( + metadata={"help_string": "input image", "mandatory": True, "argstr": "-i"} + ) - mask_image: PathLike = field(metadata={"help_string": "mask image", "argstr": "-x"}) + mask_image: PathLike = field( + metadata={"help_string": "mask image", "argstr": "-x"} + ) rescale_intensities: bool = field( default=True, @@ -37,9 +45,13 @@ class InputSpec(ShellSpec): }, ) - weight_image: PathLike = field(metadata={"help_string": "weight image", "argstr": "-w"}) + weight_image: PathLike = field( + metadata={"help_string": "weight image", "argstr": "-w"} + ) - shrink_factor: int = field(default=4, metadata={"help_string": "shrink factor", "argstr": "-s"}) + shrink_factor: int = field( + default=4, metadata={"help_string": "shrink factor", "argstr": "-s"} + ) bspline_fitting_: str = field( metadata={ @@ -49,7 +61,9 @@ class InputSpec(ShellSpec): } ) - spline_distance: float = field(default=200, metadata={"help_string": "spline distance"}) + spline_distance: float = field( + default=200, metadata={"help_string": "spline distance"} + ) spline_order: int = field(default=3, metadata={"help_string": "spline order"}) @@ -58,7 +72,9 @@ class InputSpec(ShellSpec): "help_string": "convergence parameters", "readonly": True, "formatter": lambda num_iterations, threshold: ( - "-c [{},{}]".format("x".join(str(i) for i in num_iterations), threshold) + "-c [{},{}]".format( + "x".join(str(i) for i in num_iterations), threshold + ) ), } ) @@ -67,7 +83,9 @@ class InputSpec(ShellSpec): default=(50, 50, 50, 50), metadata={"help_string": "number of iterations"} ) - threshold: float = field(default=0.0, metadata={"help_string": "convergence threshold"}) + threshold: float = field( + default=0.0, metadata={"help_string": "convergence threshold"} + ) histogram_sharpening_: str = field( metadata={ @@ -77,30 +95,46 @@ class InputSpec(ShellSpec): } ) - bias_field_fwhm: float = field(default=0.15, metadata={"help_string": "Bias field FWHM"}) + bias_field_fwhm: float = field( + default=0.15, metadata={"help_string": "Bias field FWHM"} + ) - wiener_filter_noise: float = field(default=0.01, metadata={"help_string": "Wiener filter noise"}) + wiener_filter_noise: float = field( + default=0.01, metadata={"help_string": "Wiener filter noise"} + ) - num_histogram_bins: int = field(default=200, metadata={"help_string": "number of histogram bins"}) + num_histogram_bins: int = field( + default=200, metadata={"help_string": "number of histogram bins"} + ) output_ = field( metadata={ "help_string": "output parameters", "readonly": True, "formatter": lambda output_image, save_bias_field, output_bias_field: ( - f"-o [{output_image},{output_bias_field}]" if save_bias_field else f"-o {output_image}" + f"-o [{output_image},{output_bias_field}]" + if save_bias_field + else f"-o {output_image}" ), } ) output_image: str = field( - metadata={"help_string": "output image", "output_file_template": "{input_image}_corrected"} + metadata={ + "help_string": "output image", + "output_file_template": "{input_image}_corrected", + } ) - save_bias_field: bool = field(default=False, metadata={"help_string": "save bias field"}) + save_bias_field: bool = field( + default=False, metadata={"help_string": "save bias field"} + ) output_bias_field: str = field( - metadata={"help_string": "output bias field", "output_file_template": "{input_image}_biasfield"} + metadata={ + "help_string": "output bias field", + "output_file_template": "{input_image}_biasfield", + } ) input_spec = SpecInfo(name="Input", bases=(InputSpec,)) diff --git a/pydra/tasks/ants/v2_5/create_jacobian_determinant_image.py b/pydra/tasks/ants/v2_5/create_jacobian_determinant_image.py index a2ba264..e70bc11 100644 --- a/pydra/tasks/ants/v2_5/create_jacobian_determinant_image.py +++ b/pydra/tasks/ants/v2_5/create_jacobian_determinant_image.py @@ -20,13 +20,28 @@ class CreateJacobianDeterminantImage(ShellCommandTask): @define(kw_only=True) class InputSpec(ShellSpec): dimensionality: int = field( - metadata={"help_string": "image dimensionality", "mandatory": True, "argstr": "", "allowed_values": {2, 3}} + metadata={ + "help_string": "image dimensionality", + "mandatory": True, + "argstr": "", + "allowed_values": {2, 3}, + } ) - warp_field: PathLike = field(metadata={"help_string": "displacement field", "mandatory": True, "argstr": ""}) + warp_field: PathLike = field( + metadata={ + "help_string": "displacement field", + "mandatory": True, + "argstr": "", + } + ) output_image: str = field( - metadata={"help_string": "output image", "argstr": "", "output_file_template": "{warp_field}_jac"} + metadata={ + "help_string": "output image", + "argstr": "", + "output_file_template": "{warp_field}_jac", + } ) calculate_log_jacobian: bool = field( diff --git a/pydra/tasks/ants/v2_5/registration.py b/pydra/tasks/ants/v2_5/registration.py index 492bd2b..cb8f276 100644 --- a/pydra/tasks/ants/v2_5/registration.py +++ b/pydra/tasks/ants/v2_5/registration.py @@ -16,12 +16,21 @@ class Registration(ShellCommandTask): @define(kw_only=True) class InputSpec(ShellSpec): dimensionality: int = field( - default=3, metadata={"help_string": "image dimensionality", "argstr": "-d", "allowed_values": {2, 3, 4}} + default=3, + metadata={ + "help_string": "image dimensionality", + "argstr": "-d", + "allowed_values": {2, 3, 4}, + }, ) - fixed_image: PathLike = field(metadata={"help_string": "fixed image", "mandatory": True}) + fixed_image: PathLike = field( + metadata={"help_string": "fixed image", "mandatory": True} + ) - moving_image: PathLike = field(metadata={"help_string": "moving image", "mandatory": True}) + moving_image: PathLike = field( + metadata={"help_string": "moving image", "mandatory": True} + ) output_: str = field( metadata={ @@ -37,7 +46,9 @@ class InputSpec(ShellSpec): } ) - output_transform_prefix: str = field(default="output", metadata={"help_string": "output transform prefix"}) + output_transform_prefix: str = field( + default="output", metadata={"help_string": "output transform prefix"} + ) warped_image: str = field( metadata={ @@ -95,25 +106,37 @@ class InputSpec(ShellSpec): }, ) - sigma: float = field(default=1.0, metadata={"help_string": "sigma parameter for interpolation"}) + sigma: float = field( + default=1.0, metadata={"help_string": "sigma parameter for interpolation"} + ) - alpha: float = field(default=1.0, metadata={"help_string": "alpha parameter for interpolation"}) + alpha: float = field( + default=1.0, metadata={"help_string": "alpha parameter for interpolation"} + ) - order: int = field(default=3, metadata={"help_string": "order parameter for interpolation"}) + order: int = field( + default=3, metadata={"help_string": "order parameter for interpolation"} + ) masks_: str = field( metadata={ "help_string": "masks parameter", "readonly": True, "formatter": lambda fixed_mask, moving_mask: ( - f"-x [{fixed_mask or 'NULL'},{moving_mask or 'NULL'}]" if any([fixed_mask, moving_mask]) else "" + f"-x [{fixed_mask or 'NULL'},{moving_mask or 'NULL'}]" + if any([fixed_mask, moving_mask]) + else "" ), } ) - fixed_mask: PathLike = field(metadata={"help_string": "mask applied to the fixed image"}) + fixed_mask: PathLike = field( + metadata={"help_string": "mask applied to the fixed image"} + ) - moving_mask: PathLike = field(metadata={"help_string": "mask applied to the moving image"}) + moving_mask: PathLike = field( + metadata={"help_string": "mask applied to the moving image"} + ) use_histogram_matching: bool = field( default=False, @@ -128,14 +151,20 @@ class InputSpec(ShellSpec): metadata={ "help_string": "winsorize image intensities", "formatter": lambda winsorize_image_intensities, lower_quantile, upper_quantile: ( - f"-w [{lower_quantile},{upper_quantile}]" if winsorize_image_intensities else "" + f"-w [{lower_quantile},{upper_quantile}]" + if winsorize_image_intensities + else "" ), }, ) - lower_quantile: float = field(default=0.0, metadata={"help_string": "lower quantile"}) + lower_quantile: float = field( + default=0.0, metadata={"help_string": "lower quantile"} + ) - upper_quantile: float = field(default=1.0, metadata={"help_string": "upper quantile"}) + upper_quantile: float = field( + default=1.0, metadata={"help_string": "upper quantile"} + ) initial_fixed_transforms: Sequence[PathLike] = field( metadata={ @@ -145,7 +174,12 @@ class InputSpec(ShellSpec): 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},{y:d}]" + for x, y in zip( + initial_fixed_transforms, invert_fixed_transforms + ) + ) ), } ) @@ -166,7 +200,10 @@ class InputSpec(ShellSpec): 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) + f"-r [{x},{y:d}]" + for x, y in zip( + initial_moving_transforms, invert_moving_transforms + ) ) ), } @@ -179,7 +216,9 @@ class InputSpec(ShellSpec): } ) - enable_rigid_stage = field(default=True, metadata={"help_string": "enable rigid registration stage"}) + enable_rigid_stage = field( + default=True, metadata={"help_string": "enable rigid registration stage"} + ) rigid_transform_type: str = field( default="Rigid", @@ -187,12 +226,16 @@ class InputSpec(ShellSpec): "help_string": "transform type for rigid stage", "allowed_values": {"Rigid", "Translation"}, "formatter": lambda enable_rigid_stage, rigid_transform_type, rigid_gradient_step: ( - f"-t {rigid_transform_type}[{rigid_gradient_step}]" if enable_rigid_stage else "" + f"-t {rigid_transform_type}[{rigid_gradient_step}]" + if enable_rigid_stage + else "" ), }, ) - rigid_gradient_step: bool = field(default=0.1, metadata={"help_string": "gradient step for rigid stage"}) + rigid_gradient_step: bool = field( + default=0.1, metadata={"help_string": "gradient step for rigid stage"} + ) rigid_metric: str = field( metadata={ @@ -203,7 +246,9 @@ class InputSpec(ShellSpec): rigid_metric, fixed_image, moving_image, - rigid_num_bins if rigid_metric in {"MI", "Mattes"} else rigid_radius, + rigid_num_bins + if rigid_metric in {"MI", "Mattes"} + else rigid_radius, rigid_sampling_strategy, rigid_sampling_rate, ) @@ -213,9 +258,13 @@ class InputSpec(ShellSpec): } ) - rigid_radius: int = field(default=4, metadata={"help_string": "radius for rigid stage"}) + rigid_radius: int = field( + default=4, metadata={"help_string": "radius for rigid stage"} + ) - rigid_num_bins: int = field(default=32, metadata={"help_string": "number of bins for rigid stage"}) + rigid_num_bins: int = field( + default=32, metadata={"help_string": "number of bins for rigid stage"} + ) rigid_sampling_strategy: str = field( default="None", @@ -225,7 +274,9 @@ class InputSpec(ShellSpec): }, ) - rigid_sampling_rate: float = field(default=1.0, metadata={"help_string": "sampling rate for rigid stage"}) + rigid_sampling_rate: float = field( + default=1.0, metadata={"help_string": "sampling rate for rigid stage"} + ) rigid_convergence_: Sequence[int] = field( metadata={ @@ -233,7 +284,9 @@ class InputSpec(ShellSpec): "readonly": True, "formatter": lambda enable_rigid_stage, rigid_num_iterations, rigid_threshold, rigid_window_size: ( "-c [{},{},{}]".format( - "x".join(str(c) for c in rigid_num_iterations), rigid_threshold, rigid_window_size + "x".join(str(c) for c in rigid_num_iterations), + rigid_threshold, + rigid_window_size, ) if enable_rigid_stage else "" @@ -242,19 +295,28 @@ class InputSpec(ShellSpec): ) rigid_num_iterations: Sequence[int] = field( - default=(1000, 500, 250, 0), metadata={"help_string": "number of iterations for rigid stage"} + default=(1000, 500, 250, 0), + metadata={"help_string": "number of iterations for rigid stage"}, ) - rigid_threshold: float = field(default=1e-6, metadata={"help_string": "convergence threshold for rigid stage"}) + rigid_threshold: float = field( + default=1e-6, + metadata={"help_string": "convergence threshold for rigid stage"}, + ) - rigid_window_size: int = field(default=10, metadata={"help_string": "convergence window size for rigid stage"}) + rigid_window_size: int = field( + default=10, + metadata={"help_string": "convergence window size for rigid stage"}, + ) rigid_shrink_factors: Sequence[int] = field( default=(8, 4, 2, 1), metadata={ "help_string": "shrink factors for rigid stage", "formatter": lambda enable_rigid_stage, rigid_shrink_factors: ( - "-f {}".format("x".join(str(f) for f in rigid_shrink_factors)) if enable_rigid_stage else "" + "-f {}".format("x".join(str(f) for f in rigid_shrink_factors)) + if enable_rigid_stage + else "" ), }, ) @@ -264,7 +326,10 @@ class InputSpec(ShellSpec): metadata={ "help_string": "smoothing sigmas for rigid stage", "formatter": lambda enable_rigid_stage, rigid_smoothing_sigmas, rigid_smoothing_units: ( - "-s {}{}".format("x".join(str(s) for s in rigid_smoothing_sigmas), rigid_smoothing_units) + "-s {}{}".format( + "x".join(str(s) for s in rigid_smoothing_sigmas), + rigid_smoothing_units, + ) if enable_rigid_stage else "" ), @@ -273,10 +338,15 @@ class InputSpec(ShellSpec): rigid_smoothing_units: str = field( default="vox", - metadata={"help_string": "smoothing units for rigid stage", "allowed_values": {"vox", "mm"}}, + metadata={ + "help_string": "smoothing units for rigid stage", + "allowed_values": {"vox", "mm"}, + }, ) - enable_affine_stage: bool = field(default=True, metadata={"help_string": "enable affine registration stage"}) + enable_affine_stage: bool = field( + default=True, metadata={"help_string": "enable affine registration stage"} + ) affine_transform_type: str = field( default="Affine", @@ -284,12 +354,16 @@ class InputSpec(ShellSpec): "help_string": "transform type for affine stage", "allowed_values": {"Affine", "CompositeAffine", "Similarity"}, "formatter": lambda enable_affine_stage, affine_transform_type, affine_gradient_step: ( - f"-t {affine_transform_type}[{affine_gradient_step}]" if enable_affine_stage else "" + f"-t {affine_transform_type}[{affine_gradient_step}]" + if enable_affine_stage + else "" ), }, ) - affine_gradient_step: bool = field(default=0.1, metadata={"help_string": "gradient step for affine stage"}) + affine_gradient_step: bool = field( + default=0.1, metadata={"help_string": "gradient step for affine stage"} + ) affine_metric: str = field( metadata={ @@ -300,7 +374,9 @@ class InputSpec(ShellSpec): affine_metric, fixed_image, moving_image, - affine_num_bins if affine_metric in {"MI", "Mattes"} else affine_radius, + affine_num_bins + if affine_metric in {"MI", "Mattes"} + else affine_radius, affine_sampling_strategy, affine_sampling_rate, ) @@ -310,9 +386,13 @@ class InputSpec(ShellSpec): } ) - affine_radius: int = field(default=4, metadata={"help_string": "radius for affine stage"}) + affine_radius: int = field( + default=4, metadata={"help_string": "radius for affine stage"} + ) - affine_num_bins: int = field(default=32, metadata={"help_string": "number of bins for affine stage"}) + affine_num_bins: int = field( + default=32, metadata={"help_string": "number of bins for affine stage"} + ) affine_sampling_strategy: str = field( default="None", @@ -322,7 +402,9 @@ class InputSpec(ShellSpec): }, ) - affine_sampling_rate: float = field(default=1.0, metadata={"help_string": "sampling rate for affine stage"}) + affine_sampling_rate: float = field( + default=1.0, metadata={"help_string": "sampling rate for affine stage"} + ) affine_convergence_: Sequence[int] = field( metadata={ @@ -330,7 +412,9 @@ class InputSpec(ShellSpec): "readonly": True, "formatter": lambda enable_affine_stage, affine_num_iterations, affine_threshold, affine_window_size: ( "-c [{},{},{}]".format( - "x".join(str(c) for c in affine_num_iterations), affine_threshold, affine_window_size + "x".join(str(c) for c in affine_num_iterations), + affine_threshold, + affine_window_size, ) if enable_affine_stage else "" @@ -339,15 +423,18 @@ class InputSpec(ShellSpec): ) affine_num_iterations: Sequence[int] = field( - default=(1000, 500, 250, 0), metadata={"help_string": "number of iterations for affine stage"} + default=(1000, 500, 250, 0), + metadata={"help_string": "number of iterations for affine stage"}, ) affine_threshold: float = field( - default=1e-6, metadata={"help_string": "convergence threshold for affine stage"} + default=1e-6, + metadata={"help_string": "convergence threshold for affine stage"}, ) affine_window_size: int = field( - default=10, metadata={"help_string": "convergence window size for affine stage"} + default=10, + metadata={"help_string": "convergence window size for affine stage"}, ) affine_shrink_factors: Sequence[int] = field( @@ -355,7 +442,9 @@ class InputSpec(ShellSpec): metadata={ "help_string": "shrink factors for affine stage", "formatter": lambda enable_affine_stage, affine_shrink_factors: ( - "-f {}".format("x".join(str(f) for f in affine_shrink_factors)) if enable_affine_stage else "" + "-f {}".format("x".join(str(f) for f in affine_shrink_factors)) + if enable_affine_stage + else "" ), }, ) @@ -365,7 +454,10 @@ class InputSpec(ShellSpec): metadata={ "help_string": "smoothing sigmas for affine stage", "formatter": lambda enable_affine_stage, affine_smoothing_sigmas, affine_smoothing_units: ( - "-s {}{}".format("x".join(str(s) for s in affine_smoothing_sigmas), affine_smoothing_units) + "-s {}{}".format( + "x".join(str(s) for s in affine_smoothing_sigmas), + affine_smoothing_units, + ) if enable_affine_stage else "" ), @@ -374,10 +466,15 @@ class InputSpec(ShellSpec): affine_smoothing_units: str = field( default="vox", - metadata={"help_string": "smoothing units for affine stage", "allowed_values": {"vox", "mm"}}, + metadata={ + "help_string": "smoothing units for affine stage", + "allowed_values": {"vox", "mm"}, + }, ) - enable_syn_stage: str = field(default=True, metadata={"help_string": "enable SyN registration stage"}) + enable_syn_stage: str = field( + default=True, metadata={"help_string": "enable SyN registration stage"} + ) syn_transform_type: str = field( default="Syn", @@ -397,15 +494,25 @@ class InputSpec(ShellSpec): }, ) - syn_gradient_step: bool = field(default=0.1, metadata={"help_string": "gradient step for SyN stage"}) + syn_gradient_step: bool = field( + default=0.1, metadata={"help_string": "gradient step for SyN stage"} + ) - syn_flow_sigma: float = field(default=3, metadata={"help_string": "sigma for flow field in SyN stage"}) + syn_flow_sigma: float = field( + default=3, metadata={"help_string": "sigma for flow field in SyN stage"} + ) - syn_total_sigma: float = field(default=0, metadata={"help_string": "sigma for total field in SyN stage"}) + syn_total_sigma: float = field( + default=0, metadata={"help_string": "sigma for total field in SyN stage"} + ) - syn_spline_distance: int = field(default=26, metadata={"help_string": "spline distance for SyN stage"}) + syn_spline_distance: int = field( + default=26, metadata={"help_string": "spline distance for SyN stage"} + ) - syn_spline_order: int = field(default=3, metadata={"help_string": "spline order for SyN stage"}) + syn_spline_order: int = field( + default=3, metadata={"help_string": "spline order for SyN stage"} + ) syn_metric: str = field( default="MI", @@ -427,9 +534,13 @@ class InputSpec(ShellSpec): }, ) - syn_radius: int = field(default=4, metadata={"help_string": "radius for SyN stage"}) + syn_radius: int = field( + default=4, metadata={"help_string": "radius for SyN stage"} + ) - syn_num_bins: int = field(default=32, metadata={"help_string": "number of bins for SyN stage"}) + syn_num_bins: int = field( + default=32, metadata={"help_string": "number of bins for SyN stage"} + ) syn_sampling_strategy: str = field( default="None", @@ -439,14 +550,20 @@ class InputSpec(ShellSpec): }, ) - syn_sampling_rate: float = field(default=1.0, metadata={"help_string": "sampling rate for SyN stage"}) + syn_sampling_rate: float = field( + default=1.0, metadata={"help_string": "sampling rate for SyN stage"} + ) syn_convergence_: str = field( metadata={ "help_string": "convergence parameter for SyN stage", "readonly": True, "formatter": lambda enable_syn_stage, syn_num_iterations, syn_threshold, syn_window_size: ( - "-c [{},{},{}]".format("x".join(str(c) for c in syn_num_iterations), syn_threshold, syn_window_size) + "-c [{},{},{}]".format( + "x".join(str(c) for c in syn_num_iterations), + syn_threshold, + syn_window_size, + ) if enable_syn_stage else "" ), @@ -454,19 +571,28 @@ class InputSpec(ShellSpec): ) syn_num_iterations: Sequence[int] = field( - default=(100, 70, 50, 20), metadata={"help_string": "number of iterations for SyN stage"} + default=(100, 70, 50, 20), + metadata={"help_string": "number of iterations for SyN stage"}, ) - syn_threshold: float = field(default=1e-6, metadata={"help_string": "convergence threshold for SyN stage"}) + syn_threshold: float = field( + default=1e-6, + metadata={"help_string": "convergence threshold for SyN stage"}, + ) - syn_window_size: int = field(default=10, metadata={"help_string": "convergence window size for SyN stage"}) + syn_window_size: int = field( + default=10, + metadata={"help_string": "convergence window size for SyN stage"}, + ) syn_shrink_factors: Sequence[int] = field( default=(8, 4, 2, 1), metadata={ "help_string": "shrink factors for SyN stage", "formatter": lambda enable_syn_stage, syn_shrink_factors: ( - "-f {}".format("x".join(str(f) for f in syn_shrink_factors)) if enable_syn_stage else "" + "-f {}".format("x".join(str(f) for f in syn_shrink_factors)) + if enable_syn_stage + else "" ), }, ) @@ -476,7 +602,10 @@ class InputSpec(ShellSpec): metadata={ "help_string": "smoothing sigmas for SyN stage", "formatter": lambda enable_syn_stage, syn_smoothing_sigmas, syn_smoothing_units: ( - "-s {}{}".format("x".join(str(s) for s in syn_smoothing_sigmas), syn_smoothing_units) + "-s {}{}".format( + "x".join(str(s) for s in syn_smoothing_sigmas), + syn_smoothing_units, + ) if enable_syn_stage else "" ), @@ -485,7 +614,10 @@ class InputSpec(ShellSpec): syn_smoothing_units: str = field( default="vox", - metadata={"help_string": "smoothing units for SyN stage", "allowed_values": {"vox", "mm"}}, + metadata={ + "help_string": "smoothing units for SyN stage", + "allowed_values": {"vox", "mm"}, + }, ) use_float_precision: bool = field( @@ -504,7 +636,9 @@ class InputSpec(ShellSpec): }, ) - random_seed: int = field(metadata={"help_string": "random seed", "argstr": "--random-seed"}) + random_seed: int = field( + metadata={"help_string": "random seed", "argstr": "--random-seed"} + ) verbose: bool = field( default=False, @@ -523,7 +657,9 @@ class OutputSpec(ShellOutSpec): "help_string": "affine transform", "callable": lambda output_transform_prefix, use_minc_format: ( Path.cwd() - / "{}0GenericAffine{}".format(output_transform_prefix, ".xfm" if use_minc_format else ".mat") + / "{}0GenericAffine{}".format( + output_transform_prefix, ".xfm" if use_minc_format else ".mat" + ) ), } ) @@ -723,7 +859,11 @@ def registration_syn( syn_metric="CC" if reproducible else "MI", syn_radius=radius, syn_num_bins=num_bins, - syn_num_iterations=((100, 100, 70, 50, 0 if quick else 20) if large else (100, 70, 50, 0 if quick else 20)), + syn_num_iterations=( + (100, 100, 70, 50, 0 if quick else 20) + if large + else (100, 70, 50, 0 if quick else 20) + ), syn_shrink_factors=(10, 6, 4, 2, 1) if large else (8, 4, 2, 1), syn_smoothing_sigmas=(5, 3, 2, 1, 0) if large else (3, 2, 1, 0), use_histogram_matching=use_histogram_matching,