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

import typing
import pathlib
from styxdefs import *

BORDER_TO_VERTICES_METADATA = Metadata(
    id="da3e39f9997664c91376607d199e377db4a87475.boutiques",
    name="border-to-vertices",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


BorderToVerticesParameters = typing.TypedDict('BorderToVerticesParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/border-to-vertices"]],
    "surface": InputPathType,
    "border_file": InputPathType,
    "metric_out": str,
    "opt_border_name": typing.NotRequired[str | None],
})
BorderToVerticesParametersTagged = typing.TypedDict('BorderToVerticesParametersTagged', {
    "@type": typing.Literal["workbench/border-to-vertices"],
    "surface": InputPathType,
    "border_file": InputPathType,
    "metric_out": str,
    "opt_border_name": typing.NotRequired[str | None],
})


class BorderToVerticesOutputs(typing.NamedTuple):
    """
    Output object returned when calling `BorderToVerticesParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    metric_out: OutputPathType
    """the output metric file"""


def border_to_vertices_params(
    surface: InputPathType,
    border_file: InputPathType,
    metric_out: str,
    opt_border_name: str | None = None,
) -> BorderToVerticesParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface the borders are drawn on.
        border_file: the border file.
        metric_out: the output metric file.
        opt_border_name: create ROI for only one border: the name of the border.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/border-to-vertices",
        "surface": surface,
        "border_file": border_file,
        "metric_out": metric_out,
    }
    if opt_border_name is not None:
        params["opt_border_name"] = opt_border_name
    return params


def border_to_vertices_cargs(
    params: BorderToVerticesParameters,
    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-to-vertices")
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(execution.input_file(params.get("border_file", None)))
    cargs.append(params.get("metric_out", None))
    if params.get("opt_border_name", None) is not None:
        cargs.extend([
            "-border",
            params.get("opt_border_name", None)
        ])
    return cargs


def border_to_vertices_outputs(
    params: BorderToVerticesParameters,
    execution: Execution,
) -> BorderToVerticesOutputs:
    """
    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 = BorderToVerticesOutputs(
        root=execution.output_file("."),
        metric_out=execution.output_file(params.get("metric_out", None)),
    )
    return ret


def border_to_vertices_execute(
    params: BorderToVerticesParameters,
    runner: Runner | None = None,
) -> BorderToVerticesOutputs:
    """
    border-to-vertices
    
    Draw borders as vertices in a metric file.
    
    Outputs a metric with 1s on vertices that follow a border, and 0s elsewhere.
    By default, a separate metric column is created for each border.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BorderToVerticesOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(BORDER_TO_VERTICES_METADATA)
    params = execution.params(params)
    cargs = border_to_vertices_cargs(params, execution)
    ret = border_to_vertices_outputs(params, execution)
    execution.run(cargs)
    return ret


def border_to_vertices(
    surface: InputPathType,
    border_file: InputPathType,
    metric_out: str,
    opt_border_name: str | None = None,
    runner: Runner | None = None,
) -> BorderToVerticesOutputs:
    """
    border-to-vertices
    
    Draw borders as vertices in a metric file.
    
    Outputs a metric with 1s on vertices that follow a border, and 0s elsewhere.
    By default, a separate metric column is created for each border.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface: the surface the borders are drawn on.
        border_file: the border file.
        metric_out: the output metric file.
        opt_border_name: create ROI for only one border: the name of the border.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BorderToVerticesOutputs`).
    """
    params = border_to_vertices_params(
        surface=surface,
        border_file=border_file,
        metric_out=metric_out,
        opt_border_name=opt_border_name,
    )
    return border_to_vertices_execute(params, runner)


__all__ = [
    "BORDER_TO_VERTICES_METADATA",
    "BorderToVerticesOutputs",
    "border_to_vertices",
    "border_to_vertices_execute",
    "border_to_vertices_params",
]
