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

import typing
import pathlib
from styxdefs import *

SURFACE_SMOOTHING_METADATA = Metadata(
    id="637bed2038ffd3c4196fb7689a2277fcbe539159.boutiques",
    name="surface-smoothing",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SurfaceSmoothingParameters = typing.TypedDict('SurfaceSmoothingParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/surface-smoothing"]],
    "surface_in": InputPathType,
    "smoothing_strength": float,
    "smoothing_iterations": int,
    "surface_out": str,
})
SurfaceSmoothingParametersTagged = typing.TypedDict('SurfaceSmoothingParametersTagged', {
    "@type": typing.Literal["workbench/surface-smoothing"],
    "surface_in": InputPathType,
    "smoothing_strength": float,
    "smoothing_iterations": int,
    "surface_out": str,
})


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


def surface_smoothing_params(
    surface_in: InputPathType,
    smoothing_strength: float,
    smoothing_iterations: int,
    surface_out: str,
) -> SurfaceSmoothingParametersTagged:
    """
    Build parameters.
    
    Args:
        surface_in: the surface file to smooth.
        smoothing_strength: smoothing strength (ranges [0.0 - 1.0]).
        smoothing_iterations: smoothing iterations.
        surface_out: output surface file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-smoothing",
        "surface_in": surface_in,
        "smoothing_strength": smoothing_strength,
        "smoothing_iterations": smoothing_iterations,
        "surface_out": surface_out,
    }
    return params


def surface_smoothing_cargs(
    params: SurfaceSmoothingParameters,
    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-smoothing")
    cargs.append(execution.input_file(params.get("surface_in", None)))
    cargs.append(str(params.get("smoothing_strength", None)))
    cargs.append(str(params.get("smoothing_iterations", None)))
    cargs.append(params.get("surface_out", None))
    return cargs


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


def surface_smoothing_execute(
    params: SurfaceSmoothingParameters,
    runner: Runner | None = None,
) -> SurfaceSmoothingOutputs:
    """
    surface-smoothing
    
    Surface smoothing.
    
    Smooths a surface by averaging vertex coordinates with those of the
    neighboring vertices.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceSmoothingOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_SMOOTHING_METADATA)
    params = execution.params(params)
    cargs = surface_smoothing_cargs(params, execution)
    ret = surface_smoothing_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_smoothing(
    surface_in: InputPathType,
    smoothing_strength: float,
    smoothing_iterations: int,
    surface_out: str,
    runner: Runner | None = None,
) -> SurfaceSmoothingOutputs:
    """
    surface-smoothing
    
    Surface smoothing.
    
    Smooths a surface by averaging vertex coordinates with those of the
    neighboring vertices.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface_in: the surface file to smooth.
        smoothing_strength: smoothing strength (ranges [0.0 - 1.0]).
        smoothing_iterations: smoothing iterations.
        surface_out: output surface file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceSmoothingOutputs`).
    """
    params = surface_smoothing_params(
        surface_in=surface_in,
        smoothing_strength=smoothing_strength,
        smoothing_iterations=smoothing_iterations,
        surface_out=surface_out,
    )
    return surface_smoothing_execute(params, runner)


__all__ = [
    "SURFACE_SMOOTHING_METADATA",
    "SurfaceSmoothingOutputs",
    "surface_smoothing",
    "surface_smoothing_execute",
    "surface_smoothing_params",
]
