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

import typing
import pathlib
from styxdefs import *

SURFACE_CUT_RESAMPLE_METADATA = Metadata(
    id="3a00cf3f1b235001cfda81c5ab6186879f56a56c.boutiques",
    name="surface-cut-resample",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SurfaceCutResampleParameters = typing.TypedDict('SurfaceCutResampleParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/surface-cut-resample"]],
    "surface_in": InputPathType,
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "surface_out": str,
})
SurfaceCutResampleParametersTagged = typing.TypedDict('SurfaceCutResampleParametersTagged', {
    "@type": typing.Literal["workbench/surface-cut-resample"],
    "surface_in": InputPathType,
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "surface_out": str,
})


class SurfaceCutResampleOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceCutResampleParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    surface_out: OutputPathType
    """the output surface file"""


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


def surface_cut_resample_cargs(
    params: SurfaceCutResampleParameters,
    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("-surface-cut-resample")
    cargs.append(execution.input_file(params.get("surface_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("surface_out", None))
    return cargs


def surface_cut_resample_outputs(
    params: SurfaceCutResampleParameters,
    execution: Execution,
) -> SurfaceCutResampleOutputs:
    """
    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 = SurfaceCutResampleOutputs(
        root=execution.output_file("."),
        surface_out=execution.output_file(params.get("surface_out", None)),
    )
    return ret


def surface_cut_resample_execute(
    params: SurfaceCutResampleParameters,
    runner: Runner | None = None,
) -> SurfaceCutResampleOutputs:
    """
    surface-cut-resample
    
    Resample a cut surface.
    
    Resamples a surface file, given two spherical surfaces that are in register.
    Barycentric resampling is used, because it is usually better for resampling
    surfaces, and because it is needed to figure out the new topology anyway.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceCutResampleOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_CUT_RESAMPLE_METADATA)
    params = execution.params(params)
    cargs = surface_cut_resample_cargs(params, execution)
    ret = surface_cut_resample_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_cut_resample(
    surface_in: InputPathType,
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    surface_out: str,
    runner: Runner | None = None,
) -> SurfaceCutResampleOutputs:
    """
    surface-cut-resample
    
    Resample a cut surface.
    
    Resamples a surface file, given two spherical surfaces that are in register.
    Barycentric resampling is used, because it is usually better for resampling
    surfaces, and because it is needed to figure out the new topology anyway.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface_in: the surface file to resample.
        current_sphere: a sphere surface with the mesh that the input surface\
            is currently on.
        new_sphere: a sphere surface that is in register with <current-sphere>\
            and has the desired output mesh.
        surface_out: the output surface file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceCutResampleOutputs`).
    """
    params = surface_cut_resample_params(
        surface_in=surface_in,
        current_sphere=current_sphere,
        new_sphere=new_sphere,
        surface_out=surface_out,
    )
    return surface_cut_resample_execute(params, runner)


__all__ = [
    "SURFACE_CUT_RESAMPLE_METADATA",
    "SurfaceCutResampleOutputs",
    "surface_cut_resample",
    "surface_cut_resample_execute",
    "surface_cut_resample_params",
]
