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

import typing
import pathlib
from styxdefs import *

BORDER_RESAMPLE_METADATA = Metadata(
    id="9be294dad7cdf118a17d5ba9c35d2223b1ababca.boutiques",
    name="border-resample",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


BorderResampleParameters = typing.TypedDict('BorderResampleParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/border-resample"]],
    "border_in": InputPathType,
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "border_out": str,
})
BorderResampleParametersTagged = typing.TypedDict('BorderResampleParametersTagged', {
    "@type": typing.Literal["workbench/border-resample"],
    "border_in": InputPathType,
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "border_out": str,
})


class BorderResampleOutputs(typing.NamedTuple):
    """
    Output object returned when calling `BorderResampleParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    border_out: OutputPathType
    """the output border file"""


def border_resample_params(
    border_in: InputPathType,
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    border_out: str,
) -> BorderResampleParametersTagged:
    """
    Build parameters.
    
    Args:
        border_in: the border file to resample.
        current_sphere: a sphere surface with the mesh that the metric is\
            currently on.
        new_sphere: a sphere surface that is in register with <current-sphere>\
            and has the desired output mesh.
        border_out: the output border file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/border-resample",
        "border_in": border_in,
        "current_sphere": current_sphere,
        "new_sphere": new_sphere,
        "border_out": border_out,
    }
    return params


def border_resample_cargs(
    params: BorderResampleParameters,
    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("wb_command")
    cargs.append("-border-resample")
    cargs.append(execution.input_file(params.get("border_in", None)))
    cargs.append(execution.input_file(params.get("current_sphere", None)))
    cargs.append(execution.input_file(params.get("new_sphere", None)))
    cargs.append(params.get("border_out", None))
    return cargs


def border_resample_outputs(
    params: BorderResampleParameters,
    execution: Execution,
) -> BorderResampleOutputs:
    """
    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 = BorderResampleOutputs(
        root=execution.output_file("."),
        border_out=execution.output_file(params.get("border_out", None)),
    )
    return ret


def border_resample_execute(
    params: BorderResampleParameters,
    runner: Runner | None = None,
) -> BorderResampleOutputs:
    """
    border-resample
    
    Resample a border file to a different mesh.
    
    Resamples a border file, given two spherical surfaces that are in register.
    Only borders that have the same structure as current-sphere will be
    resampled.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BorderResampleOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(BORDER_RESAMPLE_METADATA)
    params = execution.params(params)
    cargs = border_resample_cargs(params, execution)
    ret = border_resample_outputs(params, execution)
    execution.run(cargs)
    return ret


def border_resample(
    border_in: InputPathType,
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    border_out: str,
    runner: Runner | None = None,
) -> BorderResampleOutputs:
    """
    border-resample
    
    Resample a border file to a different mesh.
    
    Resamples a border file, given two spherical surfaces that are in register.
    Only borders that have the same structure as current-sphere will be
    resampled.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        border_in: the border file to resample.
        current_sphere: a sphere surface with the mesh that the metric is\
            currently on.
        new_sphere: a sphere surface that is in register with <current-sphere>\
            and has the desired output mesh.
        border_out: the output border file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BorderResampleOutputs`).
    """
    params = border_resample_params(
        border_in=border_in,
        current_sphere=current_sphere,
        new_sphere=new_sphere,
        border_out=border_out,
    )
    return border_resample_execute(params, runner)


__all__ = [
    "BORDER_RESAMPLE_METADATA",
    "BorderResampleOutputs",
    "border_resample",
    "border_resample_execute",
    "border_resample_params",
]
