# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *

ANTS_REGISTRATION_METADATA = Metadata(
    id="c1ca233b97fb2c34e284eb1f804669cd3da9255a.boutiques",
    name="antsRegistration",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


AntsRegistrationInitialMovingTransformParameters = typing.TypedDict('AntsRegistrationInitialMovingTransformParameters', {
    "__STYX_TYPE__": typing.Literal["initial_moving_transform"],
    "initial_moving_transform": InputPathType,
})


AntsRegistrationInitialMovingTransformUseInverseParameters = typing.TypedDict('AntsRegistrationInitialMovingTransformUseInverseParameters', {
    "__STYX_TYPE__": typing.Literal["initial_moving_transform_use_inverse"],
    "initial_moving_transform": InputPathType,
    "use_inverse": typing.NotRequired[typing.Literal[0, 1] | None],
})


AntsRegistrationInitialMovingTransformInitializationFeatureParameters = typing.TypedDict('AntsRegistrationInitialMovingTransformInitializationFeatureParameters', {
    "__STYX_TYPE__": typing.Literal["initial_moving_transform_initialization_feature"],
    "fixed_image": InputPathType,
    "moving_image": InputPathType,
    "initialization_feature": typing.Literal[0, 1, 2],
})


AntsRegistrationTransformRigidParameters = typing.TypedDict('AntsRegistrationTransformRigidParameters', {
    "__STYX_TYPE__": typing.Literal["transform_rigid"],
    "gradient_step": float,
})


AntsRegistrationTransformAffineParameters = typing.TypedDict('AntsRegistrationTransformAffineParameters', {
    "__STYX_TYPE__": typing.Literal["transform_affine"],
    "gradient_step": float,
})


AntsRegistrationTransformCompositeAffineParameters = typing.TypedDict('AntsRegistrationTransformCompositeAffineParameters', {
    "__STYX_TYPE__": typing.Literal["transform_composite_affine"],
    "gradient_step": float,
})


AntsRegistrationTransformSimilarityParameters = typing.TypedDict('AntsRegistrationTransformSimilarityParameters', {
    "__STYX_TYPE__": typing.Literal["transform_similarity"],
    "gradient_step": float,
})


AntsRegistrationTransformTranslationParameters = typing.TypedDict('AntsRegistrationTransformTranslationParameters', {
    "__STYX_TYPE__": typing.Literal["transform_translation"],
    "gradient_step": float,
})


AntsRegistrationTransformBsplineParameters = typing.TypedDict('AntsRegistrationTransformBsplineParameters', {
    "__STYX_TYPE__": typing.Literal["transform_bspline"],
    "gradient_step": float,
    "mesh_size_at_base_level": float,
})


AntsRegistrationTransformGaussianDisplacementFieldParameters = typing.TypedDict('AntsRegistrationTransformGaussianDisplacementFieldParameters', {
    "__STYX_TYPE__": typing.Literal["transform_gaussian_displacement_field"],
    "gradient_step": float,
    "update_field_variance_in_voxel_space": float,
    "total_field_variance_in_voxel_space": float,
})


AntsRegistrationTransformBsplineDisplacementFieldParameters = typing.TypedDict('AntsRegistrationTransformBsplineDisplacementFieldParameters', {
    "__STYX_TYPE__": typing.Literal["transform_bspline_displacement_field"],
    "gradient_step": float,
    "update_field_mesh_size_at_base_level": float,
    "total_field_mesh_size_at_base_level": typing.NotRequired[float | None],
    "spline_order": typing.NotRequired[float | None],
})


AntsRegistrationTransformTimeVaryingVelocityFieldParameters = typing.TypedDict('AntsRegistrationTransformTimeVaryingVelocityFieldParameters', {
    "__STYX_TYPE__": typing.Literal["transform_time_varying_velocity_field"],
    "gradient_step": float,
    "number_of_time_indices": float,
    "update_field_variance_in_voxel_space": float,
    "update_field_time_variance": float,
    "total_field_variance_in_voxel_space": float,
    "total_field_time_variance": float,
})


AntsRegistrationTransformTimeVaryingBsplineVelocityFieldParameters = typing.TypedDict('AntsRegistrationTransformTimeVaryingBsplineVelocityFieldParameters', {
    "__STYX_TYPE__": typing.Literal["transform_time_varying_bspline_velocity_field"],
    "gradient_step": float,
    "velocity_field_mesh_size": float,
    "number_of_time_point_samples": typing.NotRequired[float | None],
    "spline_order": typing.NotRequired[float | None],
})


AntsRegistrationTransformSynParameters = typing.TypedDict('AntsRegistrationTransformSynParameters', {
    "__STYX_TYPE__": typing.Literal["transform_syn"],
    "gradient_step": float,
    "update_field_variance_in_voxel_space": float,
    "total_field_variance_in_voxel_space": float,
})


AntsRegistrationTransformBsplineSynParameters = typing.TypedDict('AntsRegistrationTransformBsplineSynParameters', {
    "__STYX_TYPE__": typing.Literal["transform_bspline_syn"],
    "gradient_step": float,
    "update_field_mesh_size_at_base_level": float,
    "total_field_mesh_size_at_base_level": typing.NotRequired[float | None],
    "spline_order": typing.NotRequired[float | None],
})


AntsRegistrationTransformExponentialParameters = typing.TypedDict('AntsRegistrationTransformExponentialParameters', {
    "__STYX_TYPE__": typing.Literal["transform_exponential"],
    "gradient_step": float,
    "update_field_variance_in_voxel_space": float,
    "velocity_field_variance_in_voxel_space": float,
    "number_of_integration_steps": float,
})


AntsRegistrationTransformBsplineExponentialParameters = typing.TypedDict('AntsRegistrationTransformBsplineExponentialParameters', {
    "__STYX_TYPE__": typing.Literal["transform_bspline_exponential"],
    "gradient_step": float,
    "update_field_mesh_size_at_base_level": float,
    "velocity_field_mesh_size_at_base_level": typing.NotRequired[float | None],
    "number_of_integration_steps": typing.NotRequired[float | None],
    "spline_order": typing.NotRequired[float | None],
})


AntsRegistrationMetricAntsNeighbourhoodCrossCorrelationParameters = typing.TypedDict('AntsRegistrationMetricAntsNeighbourhoodCrossCorrelationParameters', {
    "__STYX_TYPE__": typing.Literal["metric_ants_neighbourhood_cross_correlation"],
    "fixed_image": str,
    "moving_image": str,
    "metric_weight": float,
    "radius": typing.NotRequired[float | None],
    "sampling_strategy": typing.NotRequired[typing.Literal["None", "Regular", "Random"] | None],
    "sampling_percentage": typing.NotRequired[float | None],
    "use_gradient_filter": typing.NotRequired[typing.Literal["true", "false"] | None],
})


AntsRegistrationMetricMutualInformationParameters = typing.TypedDict('AntsRegistrationMetricMutualInformationParameters', {
    "__STYX_TYPE__": typing.Literal["metric_mutual_information"],
    "fixed_image": str,
    "moving_image": str,
    "metric_weight": float,
    "number_of_bins": typing.NotRequired[float | None],
    "sampling_strategy": typing.NotRequired[typing.Literal["None", "Regular", "Random"] | None],
    "sampling_percentage": typing.NotRequired[float | None],
    "use_gradient_filter": typing.NotRequired[typing.Literal["true", "false"] | None],
})


AntsRegistrationMetricMattesParameters = typing.TypedDict('AntsRegistrationMetricMattesParameters', {
    "__STYX_TYPE__": typing.Literal["metric_mattes"],
    "fixed_image": str,
    "moving_image": str,
    "metric_weight": float,
    "number_of_bins": typing.NotRequired[float | None],
    "sampling_strategy": typing.NotRequired[typing.Literal["None", "Regular", "Random"] | None],
    "sampling_percentage": typing.NotRequired[float | None],
    "use_gradient_filter": typing.NotRequired[typing.Literal["true", "false"] | None],
})


AntsRegistrationMetricMeanSquaresParameters = typing.TypedDict('AntsRegistrationMetricMeanSquaresParameters', {
    "__STYX_TYPE__": typing.Literal["metric_mean_squares"],
    "fixed_image": str,
    "moving_image": str,
    "metric_weight": float,
    "radius": typing.NotRequired[float | None],
    "sampling_strategy": typing.NotRequired[typing.Literal["None", "Regular", "Random"] | None],
    "sampling_percentage": typing.NotRequired[float | None],
    "use_gradient_filter": typing.NotRequired[typing.Literal["true", "false"] | None],
})


AntsRegistrationMetricDemonsParameters = typing.TypedDict('AntsRegistrationMetricDemonsParameters', {
    "__STYX_TYPE__": typing.Literal["metric_demons"],
    "fixed_image": str,
    "moving_image": str,
    "metric_weight": float,
    "number_of_bins": typing.NotRequired[float | None],
    "sampling_strategy": typing.NotRequired[typing.Literal["None", "Regular", "Random"] | None],
    "sampling_percentage": typing.NotRequired[float | None],
    "use_gradient_filter": typing.NotRequired[typing.Literal["true", "false"] | None],
})


AntsRegistrationMetricGlobalCorrelationParameters = typing.TypedDict('AntsRegistrationMetricGlobalCorrelationParameters', {
    "__STYX_TYPE__": typing.Literal["metric_global_correlation"],
    "fixed_image": str,
    "moving_image": str,
    "metric_weight": float,
    "radius": typing.NotRequired[float | None],
    "sampling_strategy": typing.NotRequired[typing.Literal["None", "Regular", "Random"] | None],
    "sampling_percentage": typing.NotRequired[float | None],
    "use_gradient_filter": typing.NotRequired[typing.Literal["true", "false"] | None],
})


AntsRegistrationMetricEuclideanIcpParameters = typing.TypedDict('AntsRegistrationMetricEuclideanIcpParameters', {
    "__STYX_TYPE__": typing.Literal["metric_euclidean_icp"],
    "fixed_point_set": str,
    "moving_point_set": str,
    "metric_weight": float,
    "sampling_percentage": typing.NotRequired[float | None],
    "boundary_points_only": typing.NotRequired[typing.Literal["0"] | None],
})


AntsRegistrationMetricPointSetExpectationParameters = typing.TypedDict('AntsRegistrationMetricPointSetExpectationParameters', {
    "__STYX_TYPE__": typing.Literal["metric_point_set_expectation"],
    "metric_weight": float,
    "point_set_sigma": typing.NotRequired[float | None],
    "sampling_percentage": typing.NotRequired[float | None],
})


AntsRegistrationMetricJensenHavrdaCharvetTsallisParameters = typing.TypedDict('AntsRegistrationMetricJensenHavrdaCharvetTsallisParameters', {
    "__STYX_TYPE__": typing.Literal["metric_jensen_havrda_charvet_tsallis"],
    "fixed_point_set": str,
    "moving_point_set": str,
    "metric_weight": float,
    "sampling_percentage": typing.NotRequired[float | None],
    "boundary_points_only": typing.NotRequired[typing.Literal["0"] | None],
    "point_set_sigma": typing.NotRequired[float | None],
    "k_neighborhood": typing.NotRequired[float | None],
})


AntsRegistrationMetricIgdmParameters = typing.TypedDict('AntsRegistrationMetricIgdmParameters', {
    "__STYX_TYPE__": typing.Literal["metric_igdm"],
})


AntsRegistrationConvergenceParameters = typing.TypedDict('AntsRegistrationConvergenceParameters', {
    "__STYX_TYPE__": typing.Literal["convergence"],
    "convergence": str,
    "convergence_threshold": float,
    "convergence_window_size": int,
})


AntsRegistrationStageParameters = typing.TypedDict('AntsRegistrationStageParameters', {
    "__STYX_TYPE__": typing.Literal["stage"],
    "transform": typing.Union[AntsRegistrationTransformRigidParameters, AntsRegistrationTransformAffineParameters, AntsRegistrationTransformCompositeAffineParameters, AntsRegistrationTransformSimilarityParameters, AntsRegistrationTransformTranslationParameters, AntsRegistrationTransformBsplineParameters, AntsRegistrationTransformGaussianDisplacementFieldParameters, AntsRegistrationTransformBsplineDisplacementFieldParameters, AntsRegistrationTransformTimeVaryingVelocityFieldParameters, AntsRegistrationTransformTimeVaryingBsplineVelocityFieldParameters, AntsRegistrationTransformSynParameters, AntsRegistrationTransformBsplineSynParameters, AntsRegistrationTransformExponentialParameters, AntsRegistrationTransformBsplineExponentialParameters],
    "metric": typing.Union[AntsRegistrationMetricAntsNeighbourhoodCrossCorrelationParameters, AntsRegistrationMetricMutualInformationParameters, AntsRegistrationMetricMattesParameters, AntsRegistrationMetricMeanSquaresParameters, AntsRegistrationMetricDemonsParameters, AntsRegistrationMetricGlobalCorrelationParameters, AntsRegistrationMetricEuclideanIcpParameters, AntsRegistrationMetricPointSetExpectationParameters, AntsRegistrationMetricJensenHavrdaCharvetTsallisParameters, AntsRegistrationMetricIgdmParameters],
    "convergence": AntsRegistrationConvergenceParameters,
    "smoothing_sigmas": str,
    "shrink_factors": str,
    "use_histogram_matching": typing.NotRequired[typing.Literal[0, 1] | None],
})


AntsRegistrationWinsorizeImageIntensitiesParameters = typing.TypedDict('AntsRegistrationWinsorizeImageIntensitiesParameters', {
    "__STYX_TYPE__": typing.Literal["winsorize_image_intensities"],
    "lower_quantile": float,
    "upper_quantile": float,
})


AntsRegistrationMasksParameters = typing.TypedDict('AntsRegistrationMasksParameters', {
    "__STYX_TYPE__": typing.Literal["masks"],
    "fixed_mask": typing.NotRequired[str | None],
    "moving_mask": typing.NotRequired[str | None],
})


AntsRegistrationParameters = typing.TypedDict('AntsRegistrationParameters', {
    "__STYX_TYPE__": typing.Literal["antsRegistration"],
    "dimensionality": typing.NotRequired[typing.Literal[2, 3, 4] | None],
    "output": typing.NotRequired[str | None],
    "save_state": typing.NotRequired[str | None],
    "restore_state": typing.NotRequired[str | None],
    "write_composite_transform": typing.NotRequired[typing.Literal[0, 1] | None],
    "print_similarity_measure_interval": typing.NotRequired[int | None],
    "write_interval_volumes": typing.NotRequired[int | None],
    "collapse_output_transforms": typing.NotRequired[typing.Literal[1, 0] | None],
    "initialize_transforms_per_stage": typing.NotRequired[typing.Literal[1, 0] | None],
    "interpolation": typing.NotRequired[typing.Literal["Linear", "NearestNeighbor", "MultiLabel", "Gaussian", "BSpline", "CosineWindowedSinc", "WelchWindowedSinc", "HammingWindowedSinc", "LanczosWindowedSinc", "GenericLabel"] | None],
    "restrict_deformation": typing.NotRequired[list[typing.Literal[0, 1]] | None],
    "initial_fixed_transform": typing.NotRequired[str | None],
    "initial_moving_transform": typing.NotRequired[typing.Union[AntsRegistrationInitialMovingTransformParameters, AntsRegistrationInitialMovingTransformUseInverseParameters, AntsRegistrationInitialMovingTransformInitializationFeatureParameters] | None],
    "stages": list[AntsRegistrationStageParameters],
    "winsorize_image_intensities": typing.NotRequired[AntsRegistrationWinsorizeImageIntensitiesParameters | None],
    "masks": typing.NotRequired[AntsRegistrationMasksParameters | None],
    "minc": typing.NotRequired[typing.Literal[0, 1] | None],
    "random_seed": typing.NotRequired[int | None],
    "verbose": typing.NotRequired[typing.Literal[0, 1] | None],
    "float": typing.NotRequired[typing.Literal[0, 1] | None],
})


def dyn_cargs(
    t: str,
) -> typing.Any:
    """
    Get build cargs function by command type.
    
    Args:
        t: Command type.
    Returns:
        Build cargs function.
    """
    return {
        "antsRegistration": ants_registration_cargs,
        "initial_moving_transform": ants_registration_initial_moving_transform_cargs,
        "initial_moving_transform_use_inverse": ants_registration_initial_moving_transform_use_inverse_cargs,
        "initial_moving_transform_initialization_feature": ants_registration_initial_moving_transform_initialization_feature_cargs,
        "stage": ants_registration_stage_cargs,
        "transform_rigid": ants_registration_transform_rigid_cargs,
        "transform_affine": ants_registration_transform_affine_cargs,
        "transform_composite_affine": ants_registration_transform_composite_affine_cargs,
        "transform_similarity": ants_registration_transform_similarity_cargs,
        "transform_translation": ants_registration_transform_translation_cargs,
        "transform_bspline": ants_registration_transform_bspline_cargs,
        "transform_gaussian_displacement_field": ants_registration_transform_gaussian_displacement_field_cargs,
        "transform_bspline_displacement_field": ants_registration_transform_bspline_displacement_field_cargs,
        "transform_time_varying_velocity_field": ants_registration_transform_time_varying_velocity_field_cargs,
        "transform_time_varying_bspline_velocity_field": ants_registration_transform_time_varying_bspline_velocity_field_cargs,
        "transform_syn": ants_registration_transform_syn_cargs,
        "transform_bspline_syn": ants_registration_transform_bspline_syn_cargs,
        "transform_exponential": ants_registration_transform_exponential_cargs,
        "transform_bspline_exponential": ants_registration_transform_bspline_exponential_cargs,
        "metric_ants_neighbourhood_cross_correlation": ants_registration_metric_ants_neighbourhood_cross_correlation_cargs,
        "metric_mutual_information": ants_registration_metric_mutual_information_cargs,
        "metric_mattes": ants_registration_metric_mattes_cargs,
        "metric_mean_squares": ants_registration_metric_mean_squares_cargs,
        "metric_demons": ants_registration_metric_demons_cargs,
        "metric_global_correlation": ants_registration_metric_global_correlation_cargs,
        "metric_euclidean_icp": ants_registration_metric_euclidean_icp_cargs,
        "metric_point_set_expectation": ants_registration_metric_point_set_expectation_cargs,
        "metric_jensen_havrda_charvet_tsallis": ants_registration_metric_jensen_havrda_charvet_tsallis_cargs,
        "metric_igdm": ants_registration_metric_igdm_cargs,
        "convergence": ants_registration_convergence_cargs,
        "winsorize_image_intensities": ants_registration_winsorize_image_intensities_cargs,
        "masks": ants_registration_masks_cargs,
    }.get(t)


def dyn_outputs(
    t: str,
) -> typing.Any:
    """
    Get build outputs function by command type.
    
    Args:
        t: Command type.
    Returns:
        Build outputs function.
    """
    return {
        "antsRegistration": ants_registration_outputs,
    }.get(t)


def ants_registration_initial_moving_transform_params(
    initial_moving_transform: InputPathType,
) -> AntsRegistrationInitialMovingTransformParameters:
    """
    Build parameters.
    
    Args:
        initial_moving_transform:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "initial_moving_transform",
        "initial_moving_transform": initial_moving_transform,
    }
    return params


def ants_registration_initial_moving_transform_cargs(
    params: AntsRegistrationInitialMovingTransformParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append(execution.input_file(params.get("initial_moving_transform")))
    return cargs


def ants_registration_initial_moving_transform_use_inverse_params(
    initial_moving_transform: InputPathType,
    use_inverse: typing.Literal[0, 1] | None = None,
) -> AntsRegistrationInitialMovingTransformUseInverseParameters:
    """
    Build parameters.
    
    Args:
        initial_moving_transform:.
        use_inverse: Use the inverse of the initial moving transform.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "initial_moving_transform_use_inverse",
        "initial_moving_transform": initial_moving_transform,
    }
    if use_inverse is not None:
        params["use_inverse"] = use_inverse
    return params


def ants_registration_initial_moving_transform_use_inverse_cargs(
    params: AntsRegistrationInitialMovingTransformUseInverseParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("use_inverse") is not None:
        cargs.append("[" + execution.input_file(params.get("initial_moving_transform")) + "," + str(params.get("use_inverse")) + "]")
    return cargs


def ants_registration_initial_moving_transform_initialization_feature_params(
    fixed_image: InputPathType,
    moving_image: InputPathType,
    initialization_feature: typing.Literal[0, 1, 2],
) -> AntsRegistrationInitialMovingTransformInitializationFeatureParameters:
    """
    Build parameters.
    
    Args:
        fixed_image:.
        moving_image:.
        initialization_feature: Initialization feature. 0: Geometric center of\
            images, 1: Image intensities, 2: Origin of images.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "initial_moving_transform_initialization_feature",
        "fixed_image": fixed_image,
        "moving_image": moving_image,
        "initialization_feature": initialization_feature,
    }
    return params


def ants_registration_initial_moving_transform_initialization_feature_cargs(
    params: AntsRegistrationInitialMovingTransformInitializationFeatureParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("[" + execution.input_file(params.get("fixed_image")) + "," + execution.input_file(params.get("moving_image")) + "," + str(params.get("initialization_feature")) + "]")
    return cargs


def ants_registration_transform_rigid_params(
    gradient_step: float,
) -> AntsRegistrationTransformRigidParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_rigid",
        "gradient_step": gradient_step,
    }
    return params


def ants_registration_transform_rigid_cargs(
    params: AntsRegistrationTransformRigidParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("Rigid[" + str(params.get("gradient_step")) + "]")
    return cargs


def ants_registration_transform_affine_params(
    gradient_step: float,
) -> AntsRegistrationTransformAffineParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_affine",
        "gradient_step": gradient_step,
    }
    return params


def ants_registration_transform_affine_cargs(
    params: AntsRegistrationTransformAffineParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("Affine[" + str(params.get("gradient_step")) + "]")
    return cargs


def ants_registration_transform_composite_affine_params(
    gradient_step: float,
) -> AntsRegistrationTransformCompositeAffineParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_composite_affine",
        "gradient_step": gradient_step,
    }
    return params


def ants_registration_transform_composite_affine_cargs(
    params: AntsRegistrationTransformCompositeAffineParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("CompositeAffine[" + str(params.get("gradient_step")) + "]")
    return cargs


def ants_registration_transform_similarity_params(
    gradient_step: float,
) -> AntsRegistrationTransformSimilarityParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_similarity",
        "gradient_step": gradient_step,
    }
    return params


def ants_registration_transform_similarity_cargs(
    params: AntsRegistrationTransformSimilarityParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("Similarity[" + str(params.get("gradient_step")) + "]")
    return cargs


def ants_registration_transform_translation_params(
    gradient_step: float,
) -> AntsRegistrationTransformTranslationParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_translation",
        "gradient_step": gradient_step,
    }
    return params


def ants_registration_transform_translation_cargs(
    params: AntsRegistrationTransformTranslationParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("Translation[" + str(params.get("gradient_step")) + "]")
    return cargs


def ants_registration_transform_bspline_params(
    gradient_step: float,
    mesh_size_at_base_level: float,
) -> AntsRegistrationTransformBsplineParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        mesh_size_at_base_level:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_bspline",
        "gradient_step": gradient_step,
        "mesh_size_at_base_level": mesh_size_at_base_level,
    }
    return params


def ants_registration_transform_bspline_cargs(
    params: AntsRegistrationTransformBsplineParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("BSpline[" + str(params.get("gradient_step")) + "," + str(params.get("mesh_size_at_base_level")) + "]")
    return cargs


def ants_registration_transform_gaussian_displacement_field_params(
    gradient_step: float,
    update_field_variance_in_voxel_space: float,
    total_field_variance_in_voxel_space: float,
) -> AntsRegistrationTransformGaussianDisplacementFieldParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        update_field_variance_in_voxel_space:.
        total_field_variance_in_voxel_space:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_gaussian_displacement_field",
        "gradient_step": gradient_step,
        "update_field_variance_in_voxel_space": update_field_variance_in_voxel_space,
        "total_field_variance_in_voxel_space": total_field_variance_in_voxel_space,
    }
    return params


def ants_registration_transform_gaussian_displacement_field_cargs(
    params: AntsRegistrationTransformGaussianDisplacementFieldParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("GaussianDisplacementField[" + str(params.get("gradient_step")) + "," + str(params.get("update_field_variance_in_voxel_space")) + "," + str(params.get("total_field_variance_in_voxel_space")) + "]")
    return cargs


def ants_registration_transform_bspline_displacement_field_params(
    gradient_step: float,
    update_field_mesh_size_at_base_level: float,
    total_field_mesh_size_at_base_level: float | None = None,
    spline_order: float | None = None,
) -> AntsRegistrationTransformBsplineDisplacementFieldParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        update_field_mesh_size_at_base_level:.
        total_field_mesh_size_at_base_level:.
        spline_order:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_bspline_displacement_field",
        "gradient_step": gradient_step,
        "update_field_mesh_size_at_base_level": update_field_mesh_size_at_base_level,
    }
    if total_field_mesh_size_at_base_level is not None:
        params["total_field_mesh_size_at_base_level"] = total_field_mesh_size_at_base_level
    if spline_order is not None:
        params["spline_order"] = spline_order
    return params


def ants_registration_transform_bspline_displacement_field_cargs(
    params: AntsRegistrationTransformBsplineDisplacementFieldParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("total_field_mesh_size_at_base_level") is not None or params.get("spline_order") is not None:
        cargs.append("BSplineDisplacementField[" + str(params.get("gradient_step")) + "," + str(params.get("update_field_mesh_size_at_base_level")) + "," + (str(params.get("total_field_mesh_size_at_base_level")) if (params.get("total_field_mesh_size_at_base_level") is not None) else "") + (str(params.get("spline_order")) if (params.get("spline_order") is not None) else "") + "]")
    return cargs


def ants_registration_transform_time_varying_velocity_field_params(
    gradient_step: float,
    number_of_time_indices: float,
    update_field_variance_in_voxel_space: float,
    update_field_time_variance: float,
    total_field_variance_in_voxel_space: float,
    total_field_time_variance: float,
) -> AntsRegistrationTransformTimeVaryingVelocityFieldParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        number_of_time_indices:.
        update_field_variance_in_voxel_space:.
        update_field_time_variance:.
        total_field_variance_in_voxel_space:.
        total_field_time_variance:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_time_varying_velocity_field",
        "gradient_step": gradient_step,
        "number_of_time_indices": number_of_time_indices,
        "update_field_variance_in_voxel_space": update_field_variance_in_voxel_space,
        "update_field_time_variance": update_field_time_variance,
        "total_field_variance_in_voxel_space": total_field_variance_in_voxel_space,
        "total_field_time_variance": total_field_time_variance,
    }
    return params


def ants_registration_transform_time_varying_velocity_field_cargs(
    params: AntsRegistrationTransformTimeVaryingVelocityFieldParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("TimeVaryingVelocityField[" + str(params.get("gradient_step")) + "," + str(params.get("number_of_time_indices")) + "," + str(params.get("update_field_variance_in_voxel_space")) + "," + str(params.get("update_field_time_variance")) + "," + str(params.get("total_field_variance_in_voxel_space")) + "," + str(params.get("total_field_time_variance")) + "]")
    return cargs


def ants_registration_transform_time_varying_bspline_velocity_field_params(
    gradient_step: float,
    velocity_field_mesh_size: float,
    number_of_time_point_samples: float | None = None,
    spline_order: float | None = None,
) -> AntsRegistrationTransformTimeVaryingBsplineVelocityFieldParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        velocity_field_mesh_size:.
        number_of_time_point_samples:.
        spline_order:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_time_varying_bspline_velocity_field",
        "gradient_step": gradient_step,
        "velocity_field_mesh_size": velocity_field_mesh_size,
    }
    if number_of_time_point_samples is not None:
        params["number_of_time_point_samples"] = number_of_time_point_samples
    if spline_order is not None:
        params["spline_order"] = spline_order
    return params


def ants_registration_transform_time_varying_bspline_velocity_field_cargs(
    params: AntsRegistrationTransformTimeVaryingBsplineVelocityFieldParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("number_of_time_point_samples") is not None or params.get("spline_order") is not None:
        cargs.append("TimeVaryingBSplineVelocityField[" + str(params.get("gradient_step")) + "," + str(params.get("velocity_field_mesh_size")) + "," + (str(params.get("number_of_time_point_samples")) if (params.get("number_of_time_point_samples") is not None) else "") + "," + (str(params.get("spline_order")) if (params.get("spline_order") is not None) else "") + "]")
    return cargs


def ants_registration_transform_syn_params(
    gradient_step: float,
    update_field_variance_in_voxel_space: float,
    total_field_variance_in_voxel_space: float,
) -> AntsRegistrationTransformSynParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        update_field_variance_in_voxel_space:.
        total_field_variance_in_voxel_space:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_syn",
        "gradient_step": gradient_step,
        "update_field_variance_in_voxel_space": update_field_variance_in_voxel_space,
        "total_field_variance_in_voxel_space": total_field_variance_in_voxel_space,
    }
    return params


def ants_registration_transform_syn_cargs(
    params: AntsRegistrationTransformSynParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("SyN[" + str(params.get("gradient_step")) + "," + str(params.get("update_field_variance_in_voxel_space")) + "," + str(params.get("total_field_variance_in_voxel_space")) + "]")
    return cargs


def ants_registration_transform_bspline_syn_params(
    gradient_step: float,
    update_field_mesh_size_at_base_level: float,
    total_field_mesh_size_at_base_level: float | None = None,
    spline_order: float | None = None,
) -> AntsRegistrationTransformBsplineSynParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        update_field_mesh_size_at_base_level:.
        total_field_mesh_size_at_base_level:.
        spline_order:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_bspline_syn",
        "gradient_step": gradient_step,
        "update_field_mesh_size_at_base_level": update_field_mesh_size_at_base_level,
    }
    if total_field_mesh_size_at_base_level is not None:
        params["total_field_mesh_size_at_base_level"] = total_field_mesh_size_at_base_level
    if spline_order is not None:
        params["spline_order"] = spline_order
    return params


def ants_registration_transform_bspline_syn_cargs(
    params: AntsRegistrationTransformBsplineSynParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("total_field_mesh_size_at_base_level") is not None or params.get("spline_order") is not None:
        cargs.append("BSplineSyN[" + str(params.get("gradient_step")) + "," + str(params.get("update_field_mesh_size_at_base_level")) + "," + (str(params.get("total_field_mesh_size_at_base_level")) if (params.get("total_field_mesh_size_at_base_level") is not None) else "") + "," + (str(params.get("spline_order")) if (params.get("spline_order") is not None) else "") + "]")
    return cargs


def ants_registration_transform_exponential_params(
    gradient_step: float,
    update_field_variance_in_voxel_space: float,
    velocity_field_variance_in_voxel_space: float,
    number_of_integration_steps: float,
) -> AntsRegistrationTransformExponentialParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        update_field_variance_in_voxel_space:.
        velocity_field_variance_in_voxel_space:.
        number_of_integration_steps:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_exponential",
        "gradient_step": gradient_step,
        "update_field_variance_in_voxel_space": update_field_variance_in_voxel_space,
        "velocity_field_variance_in_voxel_space": velocity_field_variance_in_voxel_space,
        "number_of_integration_steps": number_of_integration_steps,
    }
    return params


def ants_registration_transform_exponential_cargs(
    params: AntsRegistrationTransformExponentialParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("Exponential[" + str(params.get("gradient_step")) + "," + str(params.get("update_field_variance_in_voxel_space")) + "," + str(params.get("velocity_field_variance_in_voxel_space")) + "," + str(params.get("number_of_integration_steps")) + "]")
    return cargs


def ants_registration_transform_bspline_exponential_params(
    gradient_step: float,
    update_field_mesh_size_at_base_level: float,
    velocity_field_mesh_size_at_base_level: float | None = None,
    number_of_integration_steps: float | None = None,
    spline_order: float | None = None,
) -> AntsRegistrationTransformBsplineExponentialParameters:
    """
    Build parameters.
    
    Args:
        gradient_step:.
        update_field_mesh_size_at_base_level:.
        velocity_field_mesh_size_at_base_level:.
        number_of_integration_steps:.
        spline_order:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "transform_bspline_exponential",
        "gradient_step": gradient_step,
        "update_field_mesh_size_at_base_level": update_field_mesh_size_at_base_level,
    }
    if velocity_field_mesh_size_at_base_level is not None:
        params["velocity_field_mesh_size_at_base_level"] = velocity_field_mesh_size_at_base_level
    if number_of_integration_steps is not None:
        params["number_of_integration_steps"] = number_of_integration_steps
    if spline_order is not None:
        params["spline_order"] = spline_order
    return params


def ants_registration_transform_bspline_exponential_cargs(
    params: AntsRegistrationTransformBsplineExponentialParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("velocity_field_mesh_size_at_base_level") is not None or params.get("number_of_integration_steps") is not None or params.get("spline_order") is not None:
        cargs.append("BSplineExponential[" + str(params.get("gradient_step")) + "," + str(params.get("update_field_mesh_size_at_base_level")) + "," + (str(params.get("velocity_field_mesh_size_at_base_level")) if (params.get("velocity_field_mesh_size_at_base_level") is not None) else "") + "," + (str(params.get("number_of_integration_steps")) if (params.get("number_of_integration_steps") is not None) else "") + "," + (str(params.get("spline_order")) if (params.get("spline_order") is not None) else "") + "]")
    return cargs


def ants_registration_metric_ants_neighbourhood_cross_correlation_params(
    fixed_image: str,
    moving_image: str,
    metric_weight: float,
    radius: float | None = None,
    sampling_strategy: typing.Literal["None", "Regular", "Random"] | None = None,
    sampling_percentage: float | None = None,
    use_gradient_filter: typing.Literal["true", "false"] | None = None,
) -> AntsRegistrationMetricAntsNeighbourhoodCrossCorrelationParameters:
    """
    Build parameters.
    
    Args:
        fixed_image:.
        moving_image:.
        metric_weight:.
        radius:.
        sampling_strategy:.
        sampling_percentage:.
        use_gradient_filter:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_ants_neighbourhood_cross_correlation",
        "fixed_image": fixed_image,
        "moving_image": moving_image,
        "metric_weight": metric_weight,
    }
    if radius is not None:
        params["radius"] = radius
    if sampling_strategy is not None:
        params["sampling_strategy"] = sampling_strategy
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if use_gradient_filter is not None:
        params["use_gradient_filter"] = use_gradient_filter
    return params


def ants_registration_metric_ants_neighbourhood_cross_correlation_cargs(
    params: AntsRegistrationMetricAntsNeighbourhoodCrossCorrelationParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("radius") is not None or params.get("sampling_strategy") is not None or params.get("sampling_percentage") is not None or params.get("use_gradient_filter") is not None:
        cargs.append("CC[" + params.get("fixed_image") + "," + params.get("moving_image") + "," + str(params.get("metric_weight")) + "," + (str(params.get("radius")) if (params.get("radius") is not None) else "") + "," + (params.get("sampling_strategy") if (params.get("sampling_strategy") is not None) else "") + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("use_gradient_filter") if (params.get("use_gradient_filter") is not None) else "") + "]")
    return cargs


def ants_registration_metric_mutual_information_params(
    fixed_image: str,
    moving_image: str,
    metric_weight: float,
    number_of_bins: float | None = None,
    sampling_strategy: typing.Literal["None", "Regular", "Random"] | None = None,
    sampling_percentage: float | None = None,
    use_gradient_filter: typing.Literal["true", "false"] | None = None,
) -> AntsRegistrationMetricMutualInformationParameters:
    """
    Build parameters.
    
    Args:
        fixed_image:.
        moving_image:.
        metric_weight:.
        number_of_bins:.
        sampling_strategy:.
        sampling_percentage:.
        use_gradient_filter:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_mutual_information",
        "fixed_image": fixed_image,
        "moving_image": moving_image,
        "metric_weight": metric_weight,
    }
    if number_of_bins is not None:
        params["number_of_bins"] = number_of_bins
    if sampling_strategy is not None:
        params["sampling_strategy"] = sampling_strategy
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if use_gradient_filter is not None:
        params["use_gradient_filter"] = use_gradient_filter
    return params


def ants_registration_metric_mutual_information_cargs(
    params: AntsRegistrationMetricMutualInformationParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("number_of_bins") is not None or params.get("sampling_strategy") is not None or params.get("sampling_percentage") is not None or params.get("use_gradient_filter") is not None:
        cargs.append("MI[" + params.get("fixed_image") + "," + params.get("moving_image") + "," + str(params.get("metric_weight")) + "," + (str(params.get("number_of_bins")) if (params.get("number_of_bins") is not None) else "") + "," + (params.get("sampling_strategy") if (params.get("sampling_strategy") is not None) else "") + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("use_gradient_filter") if (params.get("use_gradient_filter") is not None) else "") + "]")
    return cargs


def ants_registration_metric_mattes_params(
    fixed_image: str,
    moving_image: str,
    metric_weight: float,
    number_of_bins: float | None = None,
    sampling_strategy: typing.Literal["None", "Regular", "Random"] | None = None,
    sampling_percentage: float | None = None,
    use_gradient_filter: typing.Literal["true", "false"] | None = None,
) -> AntsRegistrationMetricMattesParameters:
    """
    Build parameters.
    
    Args:
        fixed_image:.
        moving_image:.
        metric_weight:.
        number_of_bins:.
        sampling_strategy:.
        sampling_percentage:.
        use_gradient_filter:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_mattes",
        "fixed_image": fixed_image,
        "moving_image": moving_image,
        "metric_weight": metric_weight,
    }
    if number_of_bins is not None:
        params["number_of_bins"] = number_of_bins
    if sampling_strategy is not None:
        params["sampling_strategy"] = sampling_strategy
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if use_gradient_filter is not None:
        params["use_gradient_filter"] = use_gradient_filter
    return params


def ants_registration_metric_mattes_cargs(
    params: AntsRegistrationMetricMattesParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("number_of_bins") is not None or params.get("sampling_strategy") is not None or params.get("sampling_percentage") is not None or params.get("use_gradient_filter") is not None:
        cargs.append("Mattes[" + params.get("fixed_image") + "," + params.get("moving_image") + "," + str(params.get("metric_weight")) + "," + (str(params.get("number_of_bins")) if (params.get("number_of_bins") is not None) else "") + "," + (params.get("sampling_strategy") if (params.get("sampling_strategy") is not None) else "") + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("use_gradient_filter") if (params.get("use_gradient_filter") is not None) else "") + "]")
    return cargs


def ants_registration_metric_mean_squares_params(
    fixed_image: str,
    moving_image: str,
    metric_weight: float,
    radius: float | None = None,
    sampling_strategy: typing.Literal["None", "Regular", "Random"] | None = None,
    sampling_percentage: float | None = None,
    use_gradient_filter: typing.Literal["true", "false"] | None = None,
) -> AntsRegistrationMetricMeanSquaresParameters:
    """
    Build parameters.
    
    Args:
        fixed_image:.
        moving_image:.
        metric_weight:.
        radius:.
        sampling_strategy:.
        sampling_percentage:.
        use_gradient_filter:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_mean_squares",
        "fixed_image": fixed_image,
        "moving_image": moving_image,
        "metric_weight": metric_weight,
    }
    if radius is not None:
        params["radius"] = radius
    if sampling_strategy is not None:
        params["sampling_strategy"] = sampling_strategy
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if use_gradient_filter is not None:
        params["use_gradient_filter"] = use_gradient_filter
    return params


def ants_registration_metric_mean_squares_cargs(
    params: AntsRegistrationMetricMeanSquaresParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("radius") is not None or params.get("sampling_strategy") is not None or params.get("sampling_percentage") is not None or params.get("use_gradient_filter") is not None:
        cargs.append("MeanSquares[" + params.get("fixed_image") + "," + params.get("moving_image") + "," + str(params.get("metric_weight")) + "," + (str(params.get("radius")) if (params.get("radius") is not None) else "") + "," + (params.get("sampling_strategy") if (params.get("sampling_strategy") is not None) else "") + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("use_gradient_filter") if (params.get("use_gradient_filter") is not None) else "") + "]")
    return cargs


def ants_registration_metric_demons_params(
    fixed_image: str,
    moving_image: str,
    metric_weight: float,
    number_of_bins: float | None = None,
    sampling_strategy: typing.Literal["None", "Regular", "Random"] | None = None,
    sampling_percentage: float | None = None,
    use_gradient_filter: typing.Literal["true", "false"] | None = None,
) -> AntsRegistrationMetricDemonsParameters:
    """
    Build parameters.
    
    Args:
        fixed_image:.
        moving_image:.
        metric_weight:.
        number_of_bins:.
        sampling_strategy:.
        sampling_percentage:.
        use_gradient_filter:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_demons",
        "fixed_image": fixed_image,
        "moving_image": moving_image,
        "metric_weight": metric_weight,
    }
    if number_of_bins is not None:
        params["number_of_bins"] = number_of_bins
    if sampling_strategy is not None:
        params["sampling_strategy"] = sampling_strategy
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if use_gradient_filter is not None:
        params["use_gradient_filter"] = use_gradient_filter
    return params


def ants_registration_metric_demons_cargs(
    params: AntsRegistrationMetricDemonsParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("number_of_bins") is not None or params.get("sampling_strategy") is not None or params.get("sampling_percentage") is not None or params.get("use_gradient_filter") is not None:
        cargs.append("Demons[" + params.get("fixed_image") + "," + params.get("moving_image") + "," + str(params.get("metric_weight")) + "," + (str(params.get("number_of_bins")) if (params.get("number_of_bins") is not None) else "") + "," + (params.get("sampling_strategy") if (params.get("sampling_strategy") is not None) else "") + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("use_gradient_filter") if (params.get("use_gradient_filter") is not None) else "") + "]")
    return cargs


def ants_registration_metric_global_correlation_params(
    fixed_image: str,
    moving_image: str,
    metric_weight: float,
    radius: float | None = None,
    sampling_strategy: typing.Literal["None", "Regular", "Random"] | None = None,
    sampling_percentage: float | None = None,
    use_gradient_filter: typing.Literal["true", "false"] | None = None,
) -> AntsRegistrationMetricGlobalCorrelationParameters:
    """
    Build parameters.
    
    Args:
        fixed_image:.
        moving_image:.
        metric_weight:.
        radius:.
        sampling_strategy:.
        sampling_percentage:.
        use_gradient_filter:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_global_correlation",
        "fixed_image": fixed_image,
        "moving_image": moving_image,
        "metric_weight": metric_weight,
    }
    if radius is not None:
        params["radius"] = radius
    if sampling_strategy is not None:
        params["sampling_strategy"] = sampling_strategy
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if use_gradient_filter is not None:
        params["use_gradient_filter"] = use_gradient_filter
    return params


def ants_registration_metric_global_correlation_cargs(
    params: AntsRegistrationMetricGlobalCorrelationParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("radius") is not None or params.get("sampling_strategy") is not None or params.get("sampling_percentage") is not None or params.get("use_gradient_filter") is not None:
        cargs.append("GC[" + params.get("fixed_image") + "," + params.get("moving_image") + "," + str(params.get("metric_weight")) + "," + (str(params.get("radius")) if (params.get("radius") is not None) else "") + "," + (params.get("sampling_strategy") if (params.get("sampling_strategy") is not None) else "") + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("use_gradient_filter") if (params.get("use_gradient_filter") is not None) else "") + "]")
    return cargs


def ants_registration_metric_euclidean_icp_params(
    fixed_point_set: str,
    moving_point_set: str,
    metric_weight: float,
    sampling_percentage: float | None = None,
    boundary_points_only: typing.Literal["0"] | None = None,
) -> AntsRegistrationMetricEuclideanIcpParameters:
    """
    Build parameters.
    
    Args:
        fixed_point_set:.
        moving_point_set:.
        metric_weight:.
        sampling_percentage:.
        boundary_points_only:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_euclidean_icp",
        "fixed_point_set": fixed_point_set,
        "moving_point_set": moving_point_set,
        "metric_weight": metric_weight,
    }
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if boundary_points_only is not None:
        params["boundary_points_only"] = boundary_points_only
    return params


def ants_registration_metric_euclidean_icp_cargs(
    params: AntsRegistrationMetricEuclideanIcpParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("sampling_percentage") is not None or params.get("boundary_points_only") is not None:
        cargs.append("ICP[" + params.get("fixed_point_set") + "," + params.get("moving_point_set") + "," + str(params.get("metric_weight")) + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("boundary_points_only") if (params.get("boundary_points_only") is not None) else "") + "]")
    return cargs


def ants_registration_metric_point_set_expectation_params(
    metric_weight: float,
    point_set_sigma: float | None = None,
    sampling_percentage: float | None = None,
) -> AntsRegistrationMetricPointSetExpectationParameters:
    """
    Build parameters.
    
    Args:
        metric_weight:.
        point_set_sigma:.
        sampling_percentage:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_point_set_expectation",
        "metric_weight": metric_weight,
    }
    if point_set_sigma is not None:
        params["point_set_sigma"] = point_set_sigma
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    return params


def ants_registration_metric_point_set_expectation_cargs(
    params: AntsRegistrationMetricPointSetExpectationParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("point_set_sigma") is not None or params.get("sampling_percentage") is not None:
        cargs.append("PSE[[FIXED_IMAGE],[MOVING_IMAGE]," + str(params.get("metric_weight")) + ",," + (str(params.get("point_set_sigma")) if (params.get("point_set_sigma") is not None) else "") + "[SAMPLING_STRATEGY]," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "[USE_GRADIENT_FILTER]]")
    return cargs


def ants_registration_metric_jensen_havrda_charvet_tsallis_params(
    fixed_point_set: str,
    moving_point_set: str,
    metric_weight: float,
    sampling_percentage: float | None = None,
    boundary_points_only: typing.Literal["0"] | None = None,
    point_set_sigma: float | None = None,
    k_neighborhood: float | None = None,
) -> AntsRegistrationMetricJensenHavrdaCharvetTsallisParameters:
    """
    Build parameters.
    
    Args:
        fixed_point_set:.
        moving_point_set:.
        metric_weight:.
        sampling_percentage:.
        boundary_points_only:.
        point_set_sigma:.
        k_neighborhood:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_jensen_havrda_charvet_tsallis",
        "fixed_point_set": fixed_point_set,
        "moving_point_set": moving_point_set,
        "metric_weight": metric_weight,
    }
    if sampling_percentage is not None:
        params["sampling_percentage"] = sampling_percentage
    if boundary_points_only is not None:
        params["boundary_points_only"] = boundary_points_only
    if point_set_sigma is not None:
        params["point_set_sigma"] = point_set_sigma
    if k_neighborhood is not None:
        params["k_neighborhood"] = k_neighborhood
    return params


def ants_registration_metric_jensen_havrda_charvet_tsallis_cargs(
    params: AntsRegistrationMetricJensenHavrdaCharvetTsallisParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("sampling_percentage") is not None or params.get("boundary_points_only") is not None or params.get("point_set_sigma") is not None or params.get("k_neighborhood") is not None:
        cargs.append("JHCT[" + params.get("fixed_point_set") + "," + params.get("moving_point_set") + "," + str(params.get("metric_weight")) + "," + (str(params.get("sampling_percentage")) if (params.get("sampling_percentage") is not None) else "") + "," + (params.get("boundary_points_only") if (params.get("boundary_points_only") is not None) else "") + "," + (str(params.get("point_set_sigma")) if (params.get("point_set_sigma") is not None) else "") + "," + (str(params.get("k_neighborhood")) if (params.get("k_neighborhood") is not None) else "") + "]")
    return cargs


def ants_registration_metric_igdm_params(
) -> AntsRegistrationMetricIgdmParameters:
    """
    Build parameters.
    
    Args:
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "metric_igdm",
    }
    return params


def ants_registration_metric_igdm_cargs(
    params: AntsRegistrationMetricIgdmParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("IGDM[")
    return cargs


def ants_registration_convergence_params(
    convergence: str,
    convergence_threshold: float,
    convergence_window_size: int,
) -> AntsRegistrationConvergenceParameters:
    """
    Build parameters.
    
    Args:
        convergence:.
        convergence_threshold:.
        convergence_window_size:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "convergence",
        "convergence": convergence,
        "convergence_threshold": convergence_threshold,
        "convergence_window_size": convergence_window_size,
    }
    return params


def ants_registration_convergence_cargs(
    params: AntsRegistrationConvergenceParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("[" + params.get("convergence") + "," + str(params.get("convergence_threshold")) + "," + str(params.get("convergence_window_size")) + "]")
    return cargs


def ants_registration_stage_params(
    transform: typing.Union[AntsRegistrationTransformRigidParameters, AntsRegistrationTransformAffineParameters, AntsRegistrationTransformCompositeAffineParameters, AntsRegistrationTransformSimilarityParameters, AntsRegistrationTransformTranslationParameters, AntsRegistrationTransformBsplineParameters, AntsRegistrationTransformGaussianDisplacementFieldParameters, AntsRegistrationTransformBsplineDisplacementFieldParameters, AntsRegistrationTransformTimeVaryingVelocityFieldParameters, AntsRegistrationTransformTimeVaryingBsplineVelocityFieldParameters, AntsRegistrationTransformSynParameters, AntsRegistrationTransformBsplineSynParameters, AntsRegistrationTransformExponentialParameters, AntsRegistrationTransformBsplineExponentialParameters],
    metric: typing.Union[AntsRegistrationMetricAntsNeighbourhoodCrossCorrelationParameters, AntsRegistrationMetricMutualInformationParameters, AntsRegistrationMetricMattesParameters, AntsRegistrationMetricMeanSquaresParameters, AntsRegistrationMetricDemonsParameters, AntsRegistrationMetricGlobalCorrelationParameters, AntsRegistrationMetricEuclideanIcpParameters, AntsRegistrationMetricPointSetExpectationParameters, AntsRegistrationMetricJensenHavrdaCharvetTsallisParameters, AntsRegistrationMetricIgdmParameters],
    convergence: AntsRegistrationConvergenceParameters,
    smoothing_sigmas: str,
    shrink_factors: str,
    use_histogram_matching: typing.Literal[0, 1] | None = None,
) -> AntsRegistrationStageParameters:
    """
    Build parameters.
    
    Args:
        transform: Several transform options are available. The gradientStep or\
            learningRate characterizes the gradient descent optimization and is\
            scaled appropriately for each transform using the shift scales\
            estimator. Subsequent parameters are transform-specific and can be\
            determined from the usage. For the B-spline transforms one can also\
            specify the smoothing in terms of spline distance (i.e. knot spacing).
        metric: These image metrics are available--- CC: ANTS neighborhood\
            cross correlation, MI: Mutual information, Demons: (Thirion),\
            MeanSquares, and GC: Global Correlation. The "metricWeight" variable is\
            used to modulate the per stage weighting of the metrics. The metrics\
            can also employ a sampling strategy defined by a sampling percentage.\
            The sampling strategy defaults to 'None' (aka a dense sampling of one\
            sample per voxel), otherwise it defines a point set over which to\
            optimize the metric. The point set can be on a regular lattice or a\
            random lattice of points slightly perturbed to minimize aliasing\
            artifacts. samplingPercentage defines the fraction of points to select\
            from the domain. useGradientFilter specifies whether a smoothingfilter\
            is applied when estimating the metric gradient.In addition, three point\
            set metrics are available: Euclidean (ICP), Point-set expectation\
            (PSE), and Jensen-Havrda-Charvet-Tsallis (JHCT).
        convergence: Convergence is determined from the number of iterations\
            per level and is determined by fitting a line to the normalized energy\
            profile of the last N iterations (where N is specified by the window\
            size) and determining the slope which is then compared with the\
            convergence threshold.
        smoothing_sigmas: Specify the sigma of gaussian smoothing at each\
            level. Units are given in terms of voxels ('vox') or physical spacing\
            ('mm'). Example usage is '4x2x1mm' and '4x2x1vox' where no units\
            implies voxel spacing.
        shrink_factors: Specify the shrink factor for the virtual domain\
            (typically the fixed image) at each level.
        use_histogram_matching: Use histogram matching.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "stage",
        "transform": transform,
        "metric": metric,
        "convergence": convergence,
        "smoothing_sigmas": smoothing_sigmas,
        "shrink_factors": shrink_factors,
    }
    if use_histogram_matching is not None:
        params["use_histogram_matching"] = use_histogram_matching
    return params


def ants_registration_stage_cargs(
    params: AntsRegistrationStageParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.extend([
        "--transform",
        *dyn_cargs(params.get("transform")["__STYXTYPE__"])(params.get("transform"), execution)
    ])
    cargs.extend([
        "--metric",
        *dyn_cargs(params.get("metric")["__STYXTYPE__"])(params.get("metric"), execution)
    ])
    cargs.extend([
        "--convergence",
        *dyn_cargs(params.get("convergence")["__STYXTYPE__"])(params.get("convergence"), execution)
    ])
    cargs.extend([
        "--smoothing-sigmas",
        params.get("smoothing_sigmas")
    ])
    cargs.extend([
        "--shrink-factors",
        params.get("shrink_factors")
    ])
    if params.get("use_histogram_matching") is not None:
        cargs.extend([
            "--use-histogram-matching",
            str(params.get("use_histogram_matching"))
        ])
    return cargs


def ants_registration_winsorize_image_intensities_params(
    lower_quantile: float,
    upper_quantile: float,
) -> AntsRegistrationWinsorizeImageIntensitiesParameters:
    """
    Build parameters.
    
    Args:
        lower_quantile:.
        upper_quantile:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "winsorize_image_intensities",
        "lower_quantile": lower_quantile,
        "upper_quantile": upper_quantile,
    }
    return params


def ants_registration_winsorize_image_intensities_cargs(
    params: AntsRegistrationWinsorizeImageIntensitiesParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("[" + str(params.get("lower_quantile")) + str(params.get("upper_quantile")) + "]")
    return cargs


def ants_registration_masks_params(
    fixed_mask: str | None = None,
    moving_mask: str | None = None,
) -> AntsRegistrationMasksParameters:
    """
    Build parameters.
    
    Args:
        fixed_mask:.
        moving_mask:.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "masks",
    }
    if fixed_mask is not None:
        params["fixed_mask"] = fixed_mask
    if moving_mask is not None:
        params["moving_mask"] = moving_mask
    return params


def ants_registration_masks_cargs(
    params: AntsRegistrationMasksParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    if params.get("fixed_mask") is not None or params.get("moving_mask") is not None:
        cargs.append("[" + (params.get("fixed_mask") if (params.get("fixed_mask") is not None) else "") + (params.get("moving_mask") if (params.get("moving_mask") is not None) else "") + "]")
    return cargs


class AntsRegistrationOutputs(typing.NamedTuple):
    """
    Output object returned when calling `ants_registration(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    generic_affine: OutputPathType | None
    """The output is the generic affine transformation matrix."""
    inverse_warped: OutputPathType | None
    """The output is the warped fixed image."""
    inverse_warp: OutputPathType | None
    """The output is the inverse warp field."""
    warped: OutputPathType | None
    """The output is the warped moving image."""
    warp: OutputPathType | None
    """The output is the warp field."""


def ants_registration_params(
    stages: list[AntsRegistrationStageParameters],
    dimensionality: typing.Literal[2, 3, 4] | None = None,
    output: str | None = None,
    save_state: str | None = None,
    restore_state: str | None = None,
    write_composite_transform: typing.Literal[0, 1] | None = None,
    print_similarity_measure_interval: int | None = None,
    write_interval_volumes: int | None = None,
    collapse_output_transforms: typing.Literal[1, 0] | None = None,
    initialize_transforms_per_stage: typing.Literal[1, 0] | None = None,
    interpolation: typing.Literal["Linear", "NearestNeighbor", "MultiLabel", "Gaussian", "BSpline", "CosineWindowedSinc", "WelchWindowedSinc", "HammingWindowedSinc", "LanczosWindowedSinc", "GenericLabel"] | None = None,
    restrict_deformation: list[typing.Literal[0, 1]] | None = None,
    initial_fixed_transform: str | None = None,
    initial_moving_transform: typing.Union[AntsRegistrationInitialMovingTransformParameters, AntsRegistrationInitialMovingTransformUseInverseParameters, AntsRegistrationInitialMovingTransformInitializationFeatureParameters] | None = None,
    winsorize_image_intensities: AntsRegistrationWinsorizeImageIntensitiesParameters | None = None,
    masks: AntsRegistrationMasksParameters | None = None,
    minc: typing.Literal[0, 1] | None = None,
    random_seed: int | None = None,
    verbose: typing.Literal[0, 1] | None = None,
    float_: typing.Literal[0, 1] | None = None,
) -> AntsRegistrationParameters:
    """
    Build parameters.
    
    Args:
        stages: Stages of the registration process.
        dimensionality: This option forces the image to be treated as a\
            specified-dimensional image. If not specified, we try to infer the\
            dimensionality from the input image.
        output: Specify the output transform prefix (output format is .nii.gz\
            ). Optionally, one can choose to warp the moving image to the fixed\
            space and, if the inverse transform exists, one can also output the\
            warped fixed image. Note that only the images specified in the first\
            metric call are warped. Use antsApplyTransforms to warp other images\
            using the resultant transform(s). When a composite transform is not\
            specified, linear transforms are specified with a '.mat' suffix and\
            displacement fields with a 'Warp.nii.gz' suffix (and\
            'InverseWarp.nii.gz', when applicable. In addition, for velocity-based\
            transforms, the full velocity field is written to file\
            ('VelocityField.nii.gz') as long as the collapse transforms flag is\
            turned off ('-z 0').
        save_state: Specify the output file for the current state of the\
            registration. The state file is written to an hdf5 composite file. It\
            is specially usefull if we want to save the current state of a SyN\
            registration to the disk, so we can load and restore that later to\
            continue the next registration process directly started from the last\
            saved state. The output file of this flag is the same as the\
            write-composite-transform, unless the last transform is a SyN\
            transform. In that case, the inverse displacement field of the SyN\
            transform is also added to the output composite transform. Again notice\
            that this file cannot be treated as a transform, and restore-state\
            option must be used to load the written file by this flag.
        restore_state: Specify the initial state of the registration which get\
            immediately used to directly initialize the registration process. The\
            flag is mutually exclusive with other intialization flags.If this flag\
            is used, none of the initial-moving-transform and\
            initial-fixed-transform cannot be used.
        write_composite_transform: Boolean specifying whether or not the\
            composite transform (and its inverse, if it exists) should be written\
            to an hdf5 composite file. This is false by default so that only the\
            transform for each stage is written to file.
        print_similarity_measure_interval: Prints out the CC similarity metric\
            measure between the full-size input fixed and the transformed moving\
            images at each iteration a value of 0 (the default) indicates that the\
            full scale computation should not take placeany value greater than 0\
            represents the interval of full scale metric computation.
        write_interval_volumes: Writes out the output volume at each iteration.\
            It helps to present the registration process as a short movie a value\
            of 0 (the default) indicates that this option should not take placeany\
            value greater than 0 represents the interval between the iterations\
            which outputs are written to the disk.
        collapse_output_transforms: Collapse output transforms. Specifically,\
            enabling this option combines all adjacent transforms where possible.\
            All adjacent linear transforms are written to disk in the form of an\
            itk affine transform (called xxxGenericAffine.mat).\
            Similarly, all adjacent displacement field transforms are combined\
            when written to disk (e.g. xxxWarp.nii.gz and xxxInverseWarp.nii.gz\
            (if available)). Also, an output composite transform including the\
            collapsed transforms is written to the disk (called\
            outputCollapsed(Inverse)Composite).
        initialize_transforms_per_stage: Initialize linear transforms from the\
            previous stage. By enabling this option, the current linear stage\
            transform is directly intialized from the previous stage's linear\
            transform; this allows multiple linear stages to be run where each\
            stage directly updates the estimated linear transform from the previous\
            stage. (e.g. Translation -> Rigid -> Affine).
        interpolation: Several interpolation options are available in ITK.\
            These have all been made available. Currently the interpolator choice\
            is only used to warp (and possibly inverse warp) the final output\
            image(s).
        restrict_deformation: This option allows the user to restrict the\
            optimization of the displacement field, translation, rigid or affine\
            transform on a per-component basis. For example, if one wants to limit\
            the deformation or rotation of 3-D volume to the first two dimensions,\
            this is possible by specifying a weight vector of '1x1x0' for a\
            deformation field or '1x1x0x1x1x0' for a rigid transformation.\
            Low-dimensional restriction only works if there are no preceding\
            transformations.All stages up to and including the desired stage must\
            have this option specified,even if they should not be restricted (in\
            which case specify 1x1x1...).
        initial_fixed_transform: Specify the initial fixed transform(s) which\
            get immediately incorporated into the composite transform. The order of\
            the transforms is stack-esque in that the last transform specified on\
            the command line is the first to be applied. In addition to\
            initialization with ITK transforms, the user can perform an initial\
            translation alignment by specifying the fixed and moving images and\
            selecting an initialization feature. These features include using the\
            geometric center of the images (=0), the image intensities (=1), or the\
            origin of the images (=2).
        initial_moving_transform: Specify the initial moving transform(s) which\
            get immediately incorporated into the composite transform. The order of\
            the transforms is stack-esque in that the last transform specified on\
            the command line is the first to be applied. In addition to\
            initialization with ITK transforms, the user can perform an initial\
            translation alignment by specifying the fixed and moving images and\
            selecting an initialization feature. These features include using the\
            geometric center of the images (=0), the image intensities (=1), or the\
            origin of the images (=2).
        winsorize_image_intensities: Winsorize data based on specified\
            quantiles.
        masks: Image masks to limit voxels considered by the metric. Two\
            options are allowed for mask specification: 1) Either the user\
            specifies a single mask to be used for all stages or 2) the user\
            specifies a mask for each stage. With the latter one can select to\
            which stages masks are applied by supplying valid file names. If the\
            file does not exist, a mask will not be used for that stage. Note that\
            we handle the fixed and moving masks separately to enforce this\
            constraint.
        minc: Use MINC file formats for transformations.
        random_seed: Random seed.
        verbose: Verbose output.
        float_: Use 'float' instead of 'double' for computations.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "antsRegistration",
        "stages": stages,
    }
    if dimensionality is not None:
        params["dimensionality"] = dimensionality
    if output is not None:
        params["output"] = output
    if save_state is not None:
        params["save_state"] = save_state
    if restore_state is not None:
        params["restore_state"] = restore_state
    if write_composite_transform is not None:
        params["write_composite_transform"] = write_composite_transform
    if print_similarity_measure_interval is not None:
        params["print_similarity_measure_interval"] = print_similarity_measure_interval
    if write_interval_volumes is not None:
        params["write_interval_volumes"] = write_interval_volumes
    if collapse_output_transforms is not None:
        params["collapse_output_transforms"] = collapse_output_transforms
    if initialize_transforms_per_stage is not None:
        params["initialize_transforms_per_stage"] = initialize_transforms_per_stage
    if interpolation is not None:
        params["interpolation"] = interpolation
    if restrict_deformation is not None:
        params["restrict_deformation"] = restrict_deformation
    if initial_fixed_transform is not None:
        params["initial_fixed_transform"] = initial_fixed_transform
    if initial_moving_transform is not None:
        params["initial_moving_transform"] = initial_moving_transform
    if winsorize_image_intensities is not None:
        params["winsorize_image_intensities"] = winsorize_image_intensities
    if masks is not None:
        params["masks"] = masks
    if minc is not None:
        params["minc"] = minc
    if random_seed is not None:
        params["random_seed"] = random_seed
    if verbose is not None:
        params["verbose"] = verbose
    if float_ is not None:
        params["float"] = float_
    return params


def ants_registration_cargs(
    params: AntsRegistrationParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("antsRegistration")
    if params.get("dimensionality") is not None:
        cargs.extend([
            "--dimensionality",
            str(params.get("dimensionality"))
        ])
    if params.get("output") is not None:
        cargs.extend([
            "-o",
            params.get("output")
        ])
    if params.get("save_state") is not None:
        cargs.extend([
            "-j",
            params.get("save_state")
        ])
    if params.get("restore_state") is not None:
        cargs.extend([
            "-k",
            params.get("restore_state")
        ])
    if params.get("write_composite_transform") is not None:
        cargs.extend([
            "-a",
            str(params.get("write_composite_transform"))
        ])
    if params.get("print_similarity_measure_interval") is not None:
        cargs.extend([
            "-p",
            str(params.get("print_similarity_measure_interval"))
        ])
    if params.get("write_interval_volumes") is not None:
        cargs.extend([
            "--write-interval-volumes",
            str(params.get("write_interval_volumes"))
        ])
    if params.get("collapse_output_transforms") is not None:
        cargs.extend([
            "--collapse-output-transforms",
            str(params.get("collapse_output_transforms"))
        ])
    if params.get("initialize_transforms_per_stage") is not None:
        cargs.extend([
            "-i",
            str(params.get("initialize_transforms_per_stage"))
        ])
    if params.get("interpolation") is not None:
        cargs.extend([
            "--interpolation",
            params.get("interpolation")
        ])
    if params.get("restrict_deformation") is not None:
        cargs.extend([
            "-g",
            "x".join(map(str, params.get("restrict_deformation")))
        ])
    if params.get("initial_fixed_transform") is not None:
        cargs.extend([
            "-q",
            params.get("initial_fixed_transform")
        ])
    if params.get("initial_moving_transform") is not None:
        cargs.extend([
            "--initial-moving-transform",
            *dyn_cargs(params.get("initial_moving_transform")["__STYXTYPE__"])(params.get("initial_moving_transform"), execution)
        ])
    cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("stages")] for a in c])
    if params.get("winsorize_image_intensities") is not None:
        cargs.extend([
            "--winsorize-image-intensities",
            *dyn_cargs(params.get("winsorize_image_intensities")["__STYXTYPE__"])(params.get("winsorize_image_intensities"), execution)
        ])
    if params.get("masks") is not None:
        cargs.extend([
            "--masks",
            *dyn_cargs(params.get("masks")["__STYXTYPE__"])(params.get("masks"), execution)
        ])
    if params.get("minc") is not None:
        cargs.extend([
            "--minc",
            str(params.get("minc"))
        ])
    if params.get("random_seed") is not None:
        cargs.extend([
            "--random-seed",
            str(params.get("random_seed"))
        ])
    if params.get("verbose") is not None:
        cargs.extend([
            "-v",
            str(params.get("verbose"))
        ])
    if params.get("float") is not None:
        cargs.extend([
            "--float",
            str(params.get("float"))
        ])
    return cargs


def ants_registration_outputs(
    params: AntsRegistrationParameters,
    execution: Execution,
) -> AntsRegistrationOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = AntsRegistrationOutputs(
        root=execution.output_file("."),
        generic_affine=execution.output_file(params.get("output") + "0GenericAffine.mat") if (params.get("output") is not None) else None,
        inverse_warped=execution.output_file(params.get("output") + "InverseWarped.nii.gz") if (params.get("output") is not None) else None,
        inverse_warp=execution.output_file(params.get("output") + "1InverseWarp.nii.gz") if (params.get("output") is not None) else None,
        warped=execution.output_file(params.get("output") + "Warped.nii.gz") if (params.get("output") is not None) else None,
        warp=execution.output_file(params.get("output") + "1Warp.nii.gz") if (params.get("output") is not None) else None,
    )
    return ret


def ants_registration_execute(
    params: AntsRegistrationParameters,
    execution: Execution,
) -> AntsRegistrationOutputs:
    """
    This program is a user-level registration application meant to utilize classes
    in ITK v4.0 and later. The user can specify any number of "stages" where a stage
    consists of a transform; an image metric; and iterations, shrink factors, and
    smoothing sigmas for each level. Note that explicitly setting the
    dimensionality, metric, transform, output, convergence, shrink-factors, and
    smoothing-sigmas parameters is mandatory.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        params: The parameters.
        execution: The execution object.
    Returns:
        NamedTuple of outputs (described in `AntsRegistrationOutputs`).
    """
    params = execution.params(params)
    cargs = ants_registration_cargs(params, execution)
    ret = ants_registration_outputs(params, execution)
    execution.run(cargs)
    return ret


def ants_registration(
    stages: list[AntsRegistrationStageParameters],
    dimensionality: typing.Literal[2, 3, 4] | None = None,
    output: str | None = None,
    save_state: str | None = None,
    restore_state: str | None = None,
    write_composite_transform: typing.Literal[0, 1] | None = None,
    print_similarity_measure_interval: int | None = None,
    write_interval_volumes: int | None = None,
    collapse_output_transforms: typing.Literal[1, 0] | None = None,
    initialize_transforms_per_stage: typing.Literal[1, 0] | None = None,
    interpolation: typing.Literal["Linear", "NearestNeighbor", "MultiLabel", "Gaussian", "BSpline", "CosineWindowedSinc", "WelchWindowedSinc", "HammingWindowedSinc", "LanczosWindowedSinc", "GenericLabel"] | None = None,
    restrict_deformation: list[typing.Literal[0, 1]] | None = None,
    initial_fixed_transform: str | None = None,
    initial_moving_transform: typing.Union[AntsRegistrationInitialMovingTransformParameters, AntsRegistrationInitialMovingTransformUseInverseParameters, AntsRegistrationInitialMovingTransformInitializationFeatureParameters] | None = None,
    winsorize_image_intensities: AntsRegistrationWinsorizeImageIntensitiesParameters | None = None,
    masks: AntsRegistrationMasksParameters | None = None,
    minc: typing.Literal[0, 1] | None = None,
    random_seed: int | None = None,
    verbose: typing.Literal[0, 1] | None = None,
    float_: typing.Literal[0, 1] | None = None,
    runner: Runner | None = None,
) -> AntsRegistrationOutputs:
    """
    This program is a user-level registration application meant to utilize classes
    in ITK v4.0 and later. The user can specify any number of "stages" where a stage
    consists of a transform; an image metric; and iterations, shrink factors, and
    smoothing sigmas for each level. Note that explicitly setting the
    dimensionality, metric, transform, output, convergence, shrink-factors, and
    smoothing-sigmas parameters is mandatory.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        stages: Stages of the registration process.
        dimensionality: This option forces the image to be treated as a\
            specified-dimensional image. If not specified, we try to infer the\
            dimensionality from the input image.
        output: Specify the output transform prefix (output format is .nii.gz\
            ). Optionally, one can choose to warp the moving image to the fixed\
            space and, if the inverse transform exists, one can also output the\
            warped fixed image. Note that only the images specified in the first\
            metric call are warped. Use antsApplyTransforms to warp other images\
            using the resultant transform(s). When a composite transform is not\
            specified, linear transforms are specified with a '.mat' suffix and\
            displacement fields with a 'Warp.nii.gz' suffix (and\
            'InverseWarp.nii.gz', when applicable. In addition, for velocity-based\
            transforms, the full velocity field is written to file\
            ('VelocityField.nii.gz') as long as the collapse transforms flag is\
            turned off ('-z 0').
        save_state: Specify the output file for the current state of the\
            registration. The state file is written to an hdf5 composite file. It\
            is specially usefull if we want to save the current state of a SyN\
            registration to the disk, so we can load and restore that later to\
            continue the next registration process directly started from the last\
            saved state. The output file of this flag is the same as the\
            write-composite-transform, unless the last transform is a SyN\
            transform. In that case, the inverse displacement field of the SyN\
            transform is also added to the output composite transform. Again notice\
            that this file cannot be treated as a transform, and restore-state\
            option must be used to load the written file by this flag.
        restore_state: Specify the initial state of the registration which get\
            immediately used to directly initialize the registration process. The\
            flag is mutually exclusive with other intialization flags.If this flag\
            is used, none of the initial-moving-transform and\
            initial-fixed-transform cannot be used.
        write_composite_transform: Boolean specifying whether or not the\
            composite transform (and its inverse, if it exists) should be written\
            to an hdf5 composite file. This is false by default so that only the\
            transform for each stage is written to file.
        print_similarity_measure_interval: Prints out the CC similarity metric\
            measure between the full-size input fixed and the transformed moving\
            images at each iteration a value of 0 (the default) indicates that the\
            full scale computation should not take placeany value greater than 0\
            represents the interval of full scale metric computation.
        write_interval_volumes: Writes out the output volume at each iteration.\
            It helps to present the registration process as a short movie a value\
            of 0 (the default) indicates that this option should not take placeany\
            value greater than 0 represents the interval between the iterations\
            which outputs are written to the disk.
        collapse_output_transforms: Collapse output transforms. Specifically,\
            enabling this option combines all adjacent transforms where possible.\
            All adjacent linear transforms are written to disk in the form of an\
            itk affine transform (called xxxGenericAffine.mat).\
            Similarly, all adjacent displacement field transforms are combined\
            when written to disk (e.g. xxxWarp.nii.gz and xxxInverseWarp.nii.gz\
            (if available)). Also, an output composite transform including the\
            collapsed transforms is written to the disk (called\
            outputCollapsed(Inverse)Composite).
        initialize_transforms_per_stage: Initialize linear transforms from the\
            previous stage. By enabling this option, the current linear stage\
            transform is directly intialized from the previous stage's linear\
            transform; this allows multiple linear stages to be run where each\
            stage directly updates the estimated linear transform from the previous\
            stage. (e.g. Translation -> Rigid -> Affine).
        interpolation: Several interpolation options are available in ITK.\
            These have all been made available. Currently the interpolator choice\
            is only used to warp (and possibly inverse warp) the final output\
            image(s).
        restrict_deformation: This option allows the user to restrict the\
            optimization of the displacement field, translation, rigid or affine\
            transform on a per-component basis. For example, if one wants to limit\
            the deformation or rotation of 3-D volume to the first two dimensions,\
            this is possible by specifying a weight vector of '1x1x0' for a\
            deformation field or '1x1x0x1x1x0' for a rigid transformation.\
            Low-dimensional restriction only works if there are no preceding\
            transformations.All stages up to and including the desired stage must\
            have this option specified,even if they should not be restricted (in\
            which case specify 1x1x1...).
        initial_fixed_transform: Specify the initial fixed transform(s) which\
            get immediately incorporated into the composite transform. The order of\
            the transforms is stack-esque in that the last transform specified on\
            the command line is the first to be applied. In addition to\
            initialization with ITK transforms, the user can perform an initial\
            translation alignment by specifying the fixed and moving images and\
            selecting an initialization feature. These features include using the\
            geometric center of the images (=0), the image intensities (=1), or the\
            origin of the images (=2).
        initial_moving_transform: Specify the initial moving transform(s) which\
            get immediately incorporated into the composite transform. The order of\
            the transforms is stack-esque in that the last transform specified on\
            the command line is the first to be applied. In addition to\
            initialization with ITK transforms, the user can perform an initial\
            translation alignment by specifying the fixed and moving images and\
            selecting an initialization feature. These features include using the\
            geometric center of the images (=0), the image intensities (=1), or the\
            origin of the images (=2).
        winsorize_image_intensities: Winsorize data based on specified\
            quantiles.
        masks: Image masks to limit voxels considered by the metric. Two\
            options are allowed for mask specification: 1) Either the user\
            specifies a single mask to be used for all stages or 2) the user\
            specifies a mask for each stage. With the latter one can select to\
            which stages masks are applied by supplying valid file names. If the\
            file does not exist, a mask will not be used for that stage. Note that\
            we handle the fixed and moving masks separately to enforce this\
            constraint.
        minc: Use MINC file formats for transformations.
        random_seed: Random seed.
        verbose: Verbose output.
        float_: Use 'float' instead of 'double' for computations.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AntsRegistrationOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ANTS_REGISTRATION_METADATA)
    params = ants_registration_params(
        dimensionality=dimensionality,
        output=output,
        save_state=save_state,
        restore_state=restore_state,
        write_composite_transform=write_composite_transform,
        print_similarity_measure_interval=print_similarity_measure_interval,
        write_interval_volumes=write_interval_volumes,
        collapse_output_transforms=collapse_output_transforms,
        initialize_transforms_per_stage=initialize_transforms_per_stage,
        interpolation=interpolation,
        restrict_deformation=restrict_deformation,
        initial_fixed_transform=initial_fixed_transform,
        initial_moving_transform=initial_moving_transform,
        stages=stages,
        winsorize_image_intensities=winsorize_image_intensities,
        masks=masks,
        minc=minc,
        random_seed=random_seed,
        verbose=verbose,
        float_=float_,
    )
    return ants_registration_execute(params, execution)


__all__ = [
    "ANTS_REGISTRATION_METADATA",
    "AntsRegistrationConvergenceParameters",
    "AntsRegistrationInitialMovingTransformInitializationFeatureParameters",
    "AntsRegistrationInitialMovingTransformParameters",
    "AntsRegistrationInitialMovingTransformUseInverseParameters",
    "AntsRegistrationMasksParameters",
    "AntsRegistrationMetricAntsNeighbourhoodCrossCorrelationParameters",
    "AntsRegistrationMetricDemonsParameters",
    "AntsRegistrationMetricEuclideanIcpParameters",
    "AntsRegistrationMetricGlobalCorrelationParameters",
    "AntsRegistrationMetricIgdmParameters",
    "AntsRegistrationMetricJensenHavrdaCharvetTsallisParameters",
    "AntsRegistrationMetricMattesParameters",
    "AntsRegistrationMetricMeanSquaresParameters",
    "AntsRegistrationMetricMutualInformationParameters",
    "AntsRegistrationMetricPointSetExpectationParameters",
    "AntsRegistrationOutputs",
    "AntsRegistrationParameters",
    "AntsRegistrationStageParameters",
    "AntsRegistrationTransformAffineParameters",
    "AntsRegistrationTransformBsplineDisplacementFieldParameters",
    "AntsRegistrationTransformBsplineExponentialParameters",
    "AntsRegistrationTransformBsplineParameters",
    "AntsRegistrationTransformBsplineSynParameters",
    "AntsRegistrationTransformCompositeAffineParameters",
    "AntsRegistrationTransformExponentialParameters",
    "AntsRegistrationTransformGaussianDisplacementFieldParameters",
    "AntsRegistrationTransformRigidParameters",
    "AntsRegistrationTransformSimilarityParameters",
    "AntsRegistrationTransformSynParameters",
    "AntsRegistrationTransformTimeVaryingBsplineVelocityFieldParameters",
    "AntsRegistrationTransformTimeVaryingVelocityFieldParameters",
    "AntsRegistrationTransformTranslationParameters",
    "AntsRegistrationWinsorizeImageIntensitiesParameters",
    "ants_registration",
    "ants_registration_convergence_params",
    "ants_registration_initial_moving_transform_initialization_feature_params",
    "ants_registration_initial_moving_transform_params",
    "ants_registration_initial_moving_transform_use_inverse_params",
    "ants_registration_masks_params",
    "ants_registration_metric_ants_neighbourhood_cross_correlation_params",
    "ants_registration_metric_demons_params",
    "ants_registration_metric_euclidean_icp_params",
    "ants_registration_metric_global_correlation_params",
    "ants_registration_metric_igdm_params",
    "ants_registration_metric_jensen_havrda_charvet_tsallis_params",
    "ants_registration_metric_mattes_params",
    "ants_registration_metric_mean_squares_params",
    "ants_registration_metric_mutual_information_params",
    "ants_registration_metric_point_set_expectation_params",
    "ants_registration_params",
    "ants_registration_stage_params",
    "ants_registration_transform_affine_params",
    "ants_registration_transform_bspline_displacement_field_params",
    "ants_registration_transform_bspline_exponential_params",
    "ants_registration_transform_bspline_params",
    "ants_registration_transform_bspline_syn_params",
    "ants_registration_transform_composite_affine_params",
    "ants_registration_transform_exponential_params",
    "ants_registration_transform_gaussian_displacement_field_params",
    "ants_registration_transform_rigid_params",
    "ants_registration_transform_similarity_params",
    "ants_registration_transform_syn_params",
    "ants_registration_transform_time_varying_bspline_velocity_field_params",
    "ants_registration_transform_time_varying_velocity_field_params",
    "ants_registration_transform_translation_params",
    "ants_registration_winsorize_image_intensities_params",
]
