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

import typing
import pathlib
from styxdefs import *

SURFACE_CURVATURE_METADATA = Metadata(
    id="959b1a4fb2add4507cd3f4cc23eb187ef2dc3681.boutiques",
    name="surface-curvature",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SurfaceCurvatureParameters = typing.TypedDict('SurfaceCurvatureParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/surface-curvature"]],
    "surface": InputPathType,
    "opt_mean_mean_out": typing.NotRequired[str | None],
    "opt_gauss_gauss_out": typing.NotRequired[str | None],
})
SurfaceCurvatureParametersTagged = typing.TypedDict('SurfaceCurvatureParametersTagged', {
    "@type": typing.Literal["workbench/surface-curvature"],
    "surface": InputPathType,
    "opt_mean_mean_out": typing.NotRequired[str | None],
    "opt_gauss_gauss_out": typing.NotRequired[str | None],
})


class SurfaceCurvatureOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceCurvatureParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    opt_mean_mean_out: OutputPathType | None
    """output mean curvature: mean curvature metric"""
    opt_gauss_gauss_out: OutputPathType | None
    """output gaussian curvature: gaussian curvature metric"""


def surface_curvature_params(
    surface: InputPathType,
    opt_mean_mean_out: str | None = None,
    opt_gauss_gauss_out: str | None = None,
) -> SurfaceCurvatureParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to compute the curvature of.
        opt_mean_mean_out: output mean curvature: mean curvature metric.
        opt_gauss_gauss_out: output gaussian curvature: gaussian curvature\
            metric.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-curvature",
        "surface": surface,
    }
    if opt_mean_mean_out is not None:
        params["opt_mean_mean_out"] = opt_mean_mean_out
    if opt_gauss_gauss_out is not None:
        params["opt_gauss_gauss_out"] = opt_gauss_gauss_out
    return params


def surface_curvature_cargs(
    params: SurfaceCurvatureParameters,
    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-curvature")
    cargs.append(execution.input_file(params.get("surface", None)))
    if params.get("opt_mean_mean_out", None) is not None:
        cargs.extend([
            "-mean",
            params.get("opt_mean_mean_out", None)
        ])
    if params.get("opt_gauss_gauss_out", None) is not None:
        cargs.extend([
            "-gauss",
            params.get("opt_gauss_gauss_out", None)
        ])
    return cargs


def surface_curvature_outputs(
    params: SurfaceCurvatureParameters,
    execution: Execution,
) -> SurfaceCurvatureOutputs:
    """
    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 = SurfaceCurvatureOutputs(
        root=execution.output_file("."),
        opt_mean_mean_out=execution.output_file(params.get("opt_mean_mean_out", None)) if (params.get("opt_mean_mean_out") is not None) else None,
        opt_gauss_gauss_out=execution.output_file(params.get("opt_gauss_gauss_out", None)) if (params.get("opt_gauss_gauss_out") is not None) else None,
    )
    return ret


def surface_curvature_execute(
    params: SurfaceCurvatureParameters,
    runner: Runner | None = None,
) -> SurfaceCurvatureOutputs:
    """
    surface-curvature
    
    Calculate curvature of surface.
    
    Compute the curvature of the surface, using the method from:
    Interactive Texture Mapping by J. Maillot, Yahia, and Verroust, 1993.
    ACM-0-98791-601-8/93/008.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceCurvatureOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_CURVATURE_METADATA)
    params = execution.params(params)
    cargs = surface_curvature_cargs(params, execution)
    ret = surface_curvature_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_curvature(
    surface: InputPathType,
    opt_mean_mean_out: str | None = None,
    opt_gauss_gauss_out: str | None = None,
    runner: Runner | None = None,
) -> SurfaceCurvatureOutputs:
    """
    surface-curvature
    
    Calculate curvature of surface.
    
    Compute the curvature of the surface, using the method from:
    Interactive Texture Mapping by J. Maillot, Yahia, and Verroust, 1993.
    ACM-0-98791-601-8/93/008.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface: the surface to compute the curvature of.
        opt_mean_mean_out: output mean curvature: mean curvature metric.
        opt_gauss_gauss_out: output gaussian curvature: gaussian curvature\
            metric.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceCurvatureOutputs`).
    """
    params = surface_curvature_params(
        surface=surface,
        opt_mean_mean_out=opt_mean_mean_out,
        opt_gauss_gauss_out=opt_gauss_gauss_out,
    )
    return surface_curvature_execute(params, runner)


__all__ = [
    "SURFACE_CURVATURE_METADATA",
    "SurfaceCurvatureOutputs",
    "surface_curvature",
    "surface_curvature_execute",
    "surface_curvature_params",
]
