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

import typing
import pathlib
from styxdefs import *

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


CiftiLabelToBorderBorderParameters = typing.TypedDict('CiftiLabelToBorderBorderParameters', {
    "@type": typing.NotRequired[typing.Literal["border"]],
    "surface": InputPathType,
    "border_out": str,
})
CiftiLabelToBorderBorderParametersTagged = typing.TypedDict('CiftiLabelToBorderBorderParametersTagged', {
    "@type": typing.Literal["border"],
    "surface": InputPathType,
    "border_out": str,
})


CiftiLabelToBorderParameters = typing.TypedDict('CiftiLabelToBorderParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-label-to-border"]],
    "cifti_in": InputPathType,
    "opt_placement_fraction": typing.NotRequired[float | None],
    "opt_column_column": typing.NotRequired[str | None],
    "border": typing.NotRequired[list[CiftiLabelToBorderBorderParameters] | None],
})
CiftiLabelToBorderParametersTagged = typing.TypedDict('CiftiLabelToBorderParametersTagged', {
    "@type": typing.Literal["workbench/cifti-label-to-border"],
    "cifti_in": InputPathType,
    "opt_placement_fraction": typing.NotRequired[float | None],
    "opt_column_column": typing.NotRequired[str | None],
    "border": typing.NotRequired[list[CiftiLabelToBorderBorderParameters] | None],
})


class CiftiLabelToBorderBorderOutputs(typing.NamedTuple):
    """
    Output object returned when calling `list[CiftiLabelToBorderBorderParameters] | None(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    border_out: OutputPathType
    """the output border file"""


def cifti_label_to_border_border_params(
    surface: InputPathType,
    border_out: str,
) -> CiftiLabelToBorderBorderParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to use for neighbor and structure information.
        border_out: the output border file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "border",
        "surface": surface,
        "border_out": border_out,
    }
    return params


def cifti_label_to_border_border_cargs(
    params: CiftiLabelToBorderBorderParameters,
    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("-border")
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(params.get("border_out", None))
    return cargs


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


class CiftiLabelToBorderOutputs(typing.NamedTuple):
    """
    Output object returned when calling `CiftiLabelToBorderParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    border: list[CiftiLabelToBorderBorderOutputs] | None
    """Outputs from `cifti_label_to_border_border_outputs`.This is a list of
    outputs with the same length and order as the inputs."""


def cifti_label_to_border_params(
    cifti_in: InputPathType,
    opt_placement_fraction: float | None = None,
    opt_column_column: str | None = None,
    border: list[CiftiLabelToBorderBorderParameters] | None = None,
) -> CiftiLabelToBorderParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_in: the input cifti dlabel 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.
        border: specify output file for a surface structure.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-label-to-border",
        "cifti_in": cifti_in,
    }
    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
    if border is not None:
        params["border"] = border
    return params


def cifti_label_to_border_cargs(
    params: CiftiLabelToBorderParameters,
    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("-cifti-label-to-border")
    cargs.append(execution.input_file(params.get("cifti_in", 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)
        ])
    if params.get("border", None) is not None:
        cargs.extend([a for c in [cifti_label_to_border_border_cargs(s, execution) for s in params.get("border", None)] for a in c])
    return cargs


def cifti_label_to_border_outputs(
    params: CiftiLabelToBorderParameters,
    execution: Execution,
) -> CiftiLabelToBorderOutputs:
    """
    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 = CiftiLabelToBorderOutputs(
        root=execution.output_file("."),
        border=[cifti_label_to_border_border_outputs(i, execution) if cifti_label_to_border_border_outputs else None for i in params.get("border")] if params.get("border") else None,
    )
    return ret


def cifti_label_to_border_execute(
    params: CiftiLabelToBorderParameters,
    runner: Runner | None = None,
) -> CiftiLabelToBorderOutputs:
    """
    cifti-label-to-border
    
    Draw borders around cifti labels.
    
    For each surface, takes the labels on the matching structure and draws
    borders around the labels. Use -column to only draw borders around one label
    map.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiLabelToBorderOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_LABEL_TO_BORDER_METADATA)
    params = execution.params(params)
    cargs = cifti_label_to_border_cargs(params, execution)
    ret = cifti_label_to_border_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_label_to_border(
    cifti_in: InputPathType,
    opt_placement_fraction: float | None = None,
    opt_column_column: str | None = None,
    border: list[CiftiLabelToBorderBorderParameters] | None = None,
    runner: Runner | None = None,
) -> CiftiLabelToBorderOutputs:
    """
    cifti-label-to-border
    
    Draw borders around cifti labels.
    
    For each surface, takes the labels on the matching structure and draws
    borders around the labels. Use -column to only draw borders around one label
    map.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        cifti_in: the input cifti dlabel 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.
        border: specify output file for a surface structure.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiLabelToBorderOutputs`).
    """
    params = cifti_label_to_border_params(
        cifti_in=cifti_in,
        opt_placement_fraction=opt_placement_fraction,
        opt_column_column=opt_column_column,
        border=border,
    )
    return cifti_label_to_border_execute(params, runner)


__all__ = [
    "CIFTI_LABEL_TO_BORDER_METADATA",
    "CiftiLabelToBorderBorderOutputs",
    "CiftiLabelToBorderOutputs",
    "cifti_label_to_border",
    "cifti_label_to_border_border_params",
    "cifti_label_to_border_execute",
    "cifti_label_to_border_params",
]
