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

import typing
import pathlib
from styxdefs import *
import dataclasses

ANTSUSE_LANDMARK_IMAGES_TO_GET_BSPLINE_DISPLACEMENT_FIELD_METADATA = Metadata(
    id="7af4a9a784989ddd8ff76f3225c25b7355e86a75.boutiques",
    name="ANTSUseLandmarkImagesToGetBSplineDisplacementField",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


class AntsuseLandmarkImagesToGetBsplineDisplacementFieldOutputs(typing.NamedTuple):
    """
    Output object returned when calling `antsuse_landmark_images_to_get_bspline_displacement_field(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    displacement_field: OutputPathType
    """The resultant displacement field for the registration process."""


def antsuse_landmark_images_to_get_bspline_displacement_field(
    fixed_image_with_labeled_landmarks: InputPathType,
    moving_image_with_labeled_landmarks: InputPathType,
    output_displacement_field: str,
    mesh_size: str,
    number_of_levels: int,
    order: int | None = 3,
    enforce_stationary_boundaries: int | None = 1,
    landmark_weights: InputPathType | None = None,
    runner: Runner | None = None,
) -> AntsuseLandmarkImagesToGetBsplineDisplacementFieldOutputs:
    """
    We expect the input images to be (1) N-ary (2) in the same physical space as the
    images you want to register and (3) to have the same landmark points defined
    within them. Landmarks will be defined from the center of mass of the labels in
    the input images. You can use ITK-snap to generate the label images. The
    optional landmarks weights are read from a text file where each row is either:
    "label,labelWeight" or "labelWeight". If the latter format is used, the label
    weights are assumed to be arranged in ascending order by label.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        fixed_image_with_labeled_landmarks: The fixed image with labeled\
            landmarks.
        moving_image_with_labeled_landmarks: The moving image with labeled\
            landmarks.
        output_displacement_field: The output displacement field file.
        mesh_size: The mesh size specified as meshSize[0]xmeshSize[1]x...
        number_of_levels: The number of levels in the B-spline hierarchy.
        order: The order of the B-spline (default is 3).
        enforce_stationary_boundaries: Whether to enforce stationary boundaries\
            (default is 1).
        landmark_weights: Optional text file containing landmark weights. Each\
            row is either "label,labelWeight" or "labelWeight". If the latter\
            format is used, the weights are assumed to be arranged in ascending\
            order by label.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AntsuseLandmarkImagesToGetBsplineDisplacementFieldOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ANTSUSE_LANDMARK_IMAGES_TO_GET_BSPLINE_DISPLACEMENT_FIELD_METADATA)
    cargs = []
    cargs.append("ANTSUseLandmarkImagesToGetBSplineDisplacementField")
    cargs.append(execution.input_file(fixed_image_with_labeled_landmarks))
    cargs.append(execution.input_file(moving_image_with_labeled_landmarks))
    cargs.append(output_displacement_field)
    cargs.append(mesh_size)
    cargs.append(str(number_of_levels))
    if order is not None:
        cargs.append(str(order))
    if enforce_stationary_boundaries is not None:
        cargs.append(str(enforce_stationary_boundaries))
    if landmark_weights is not None:
        cargs.append(execution.input_file(landmark_weights))
    ret = AntsuseLandmarkImagesToGetBsplineDisplacementFieldOutputs(
        root=execution.output_file("."),
        displacement_field=execution.output_file(output_displacement_field),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ANTSUSE_LANDMARK_IMAGES_TO_GET_BSPLINE_DISPLACEMENT_FIELD_METADATA",
    "AntsuseLandmarkImagesToGetBsplineDisplacementFieldOutputs",
    "antsuse_landmark_images_to_get_bspline_displacement_field",
]
