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

import typing
import pathlib
from styxdefs import *

LABEL_TO_BORDER_METADATA = Metadata(
    id="d4004186995df7f49b52041b9843cbc52cd71c97.boutiques",
    name="label-to-border",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


LabelToBorderParameters = typing.TypedDict('LabelToBorderParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/label-to-border"]],
    "surface": InputPathType,
    "label_in": InputPathType,
    "border_out": str,
    "opt_placement_fraction": typing.NotRequired[float | None],
    "opt_column_column": typing.NotRequired[str | None],
})
LabelToBorderParametersTagged = typing.TypedDict('LabelToBorderParametersTagged', {
    "@type": typing.Literal["workbench/label-to-border"],
    "surface": InputPathType,
    "label_in": InputPathType,
    "border_out": str,
    "opt_placement_fraction": typing.NotRequired[float | None],
    "opt_column_column": typing.NotRequired[str | None],
})


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


def label_to_border_params(
    surface: InputPathType,
    label_in: InputPathType,
    border_out: str,
    opt_placement_fraction: float | None = None,
    opt_column_column: str | None = None,
) -> LabelToBorderParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to use for neighbor information.
        label_in: the input label file.
        border_out: the output border file.
        opt_placement_fraction: set how far along the edge border points are\
            drawn: fraction along edge from inside vertex (default 0.33).
        opt_column_column: select a single column: the column number or name.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/label-to-border",
        "surface": surface,
        "label_in": label_in,
        "border_out": border_out,
    }
    if opt_placement_fraction is not None:
        params["opt_placement_fraction"] = opt_placement_fraction
    if opt_column_column is not None:
        params["opt_column_column"] = opt_column_column
    return params


def label_to_border_cargs(
    params: LabelToBorderParameters,
    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("-label-to-border")
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(execution.input_file(params.get("label_in", None)))
    cargs.append(params.get("border_out", None))
    if params.get("opt_placement_fraction", None) is not None:
        cargs.extend([
            "-placement",
            str(params.get("opt_placement_fraction", None))
        ])
    if params.get("opt_column_column", None) is not None:
        cargs.extend([
            "-column",
            params.get("opt_column_column", None)
        ])
    return cargs


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


def label_to_border_execute(
    params: LabelToBorderParameters,
    runner: Runner | None = None,
) -> LabelToBorderOutputs:
    """
    label-to-border
    
    Draw borders around labels.
    
    For each label, finds all edges on the mesh that cross the boundary of the
    label, and draws borders through them. By default, this is done on all
    columns in the input file, using the map name as the class name for the
    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 `LabelToBorderOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(LABEL_TO_BORDER_METADATA)
    params = execution.params(params)
    cargs = label_to_border_cargs(params, execution)
    ret = label_to_border_outputs(params, execution)
    execution.run(cargs)
    return ret


def label_to_border(
    surface: InputPathType,
    label_in: InputPathType,
    border_out: str,
    opt_placement_fraction: float | None = None,
    opt_column_column: str | None = None,
    runner: Runner | None = None,
) -> LabelToBorderOutputs:
    """
    label-to-border
    
    Draw borders around labels.
    
    For each label, finds all edges on the mesh that cross the boundary of the
    label, and draws borders through them. By default, this is done on all
    columns in the input file, using the map name as the class name for the
    border.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface: the surface to use for neighbor information.
        label_in: the input label file.
        border_out: the output border file.
        opt_placement_fraction: set how far along the edge border points are\
            drawn: fraction along edge from inside vertex (default 0.33).
        opt_column_column: select a single column: the column number or name.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `LabelToBorderOutputs`).
    """
    params = label_to_border_params(
        surface=surface,
        label_in=label_in,
        border_out=border_out,
        opt_placement_fraction=opt_placement_fraction,
        opt_column_column=opt_column_column,
    )
    return label_to_border_execute(params, runner)


__all__ = [
    "LABEL_TO_BORDER_METADATA",
    "LabelToBorderOutputs",
    "label_to_border",
    "label_to_border_execute",
    "label_to_border_params",
]
