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

import typing
import pathlib
from styxdefs import *

BORDER_FILE_EXPORT_TO_CARET5_METADATA = Metadata(
    id="5bdb523cf35c997b31a3b9033a83e1125033b032.boutiques",
    name="border-file-export-to-caret5",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


BorderFileExportToCaret5SurfaceParameters = typing.TypedDict('BorderFileExportToCaret5SurfaceParameters', {
    "@type": typing.NotRequired[typing.Literal["surface"]],
    "surface_in": InputPathType,
})
BorderFileExportToCaret5SurfaceParametersTagged = typing.TypedDict('BorderFileExportToCaret5SurfaceParametersTagged', {
    "@type": typing.Literal["surface"],
    "surface_in": InputPathType,
})


BorderFileExportToCaret5Parameters = typing.TypedDict('BorderFileExportToCaret5Parameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/border-file-export-to-caret5"]],
    "border_file": str,
    "output_file_prefix": str,
    "surface": typing.NotRequired[list[BorderFileExportToCaret5SurfaceParameters] | None],
})
BorderFileExportToCaret5ParametersTagged = typing.TypedDict('BorderFileExportToCaret5ParametersTagged', {
    "@type": typing.Literal["workbench/border-file-export-to-caret5"],
    "border_file": str,
    "output_file_prefix": str,
    "surface": typing.NotRequired[list[BorderFileExportToCaret5SurfaceParameters] | None],
})


def border_file_export_to_caret5_surface_params(
    surface_in: InputPathType,
) -> BorderFileExportToCaret5SurfaceParametersTagged:
    """
    Build parameters.
    
    Args:
        surface_in: a surface file for unprojection of borders.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "surface",
        "surface_in": surface_in,
    }
    return params


def border_file_export_to_caret5_surface_cargs(
    params: BorderFileExportToCaret5SurfaceParameters,
    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("-surface")
    cargs.append(execution.input_file(params.get("surface_in", None)))
    return cargs


class BorderFileExportToCaret5Outputs(typing.NamedTuple):
    """
    Output object returned when calling `BorderFileExportToCaret5Parameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def border_file_export_to_caret5_params(
    border_file: str,
    output_file_prefix: str,
    surface: list[BorderFileExportToCaret5SurfaceParameters] | None = None,
) -> BorderFileExportToCaret5ParametersTagged:
    """
    Build parameters.
    
    Args:
        border_file: workbench border file.
        output_file_prefix: prefix for name of output caret5\
            border/borderproj/bordercolor files.
        surface: specify an input surface.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/border-file-export-to-caret5",
        "border_file": border_file,
        "output_file_prefix": output_file_prefix,
    }
    if surface is not None:
        params["surface"] = surface
    return params


def border_file_export_to_caret5_cargs(
    params: BorderFileExportToCaret5Parameters,
    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-file-export-to-caret5")
    cargs.append(params.get("border_file", None))
    cargs.append(params.get("output_file_prefix", None))
    if params.get("surface", None) is not None:
        cargs.extend([a for c in [border_file_export_to_caret5_surface_cargs(s, execution) for s in params.get("surface", None)] for a in c])
    return cargs


def border_file_export_to_caret5_outputs(
    params: BorderFileExportToCaret5Parameters,
    execution: Execution,
) -> BorderFileExportToCaret5Outputs:
    """
    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 = BorderFileExportToCaret5Outputs(
        root=execution.output_file("."),
    )
    return ret


def border_file_export_to_caret5_execute(
    params: BorderFileExportToCaret5Parameters,
    runner: Runner | None = None,
) -> BorderFileExportToCaret5Outputs:
    """
    border-file-export-to-caret5
    
    Export border file to caret5 file format.
    
    A Workbench border file may contain borders for multiple structures and
    borders that are both projected and unprojected. It also contains a color
    table for the borders.
    
    Caret5 has both border (unprojected) and border projection (projected)
    files. In addition, each Caret5 border or border projection file typically
    contains data for a single structure. Caret5 also uses a border color file
    that associates colors with the names of the borders.
    
    This command will try to output both Caret5 border and border projection
    files. Each output border/border projection file will contains data for one
    structure so there may be many files created. The structure name is included
    in the name of each border or border projection file that is created.
    
    One Caret5 border color file will also be produced by this command.
    
    Providing surface(s) as input parameters is optional, but recommended.
    Surfaces may be needed to create both projected and/or unprojected
    coordinates of borders. If there is a failure to produce an output border or
    border projection due to a missing surface with the matching structure, an
    error message will be displayed and some output files will not be created.
    
    When writing new files, this command will overwrite a file with the same
    name. .
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BorderFileExportToCaret5Outputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(BORDER_FILE_EXPORT_TO_CARET5_METADATA)
    params = execution.params(params)
    cargs = border_file_export_to_caret5_cargs(params, execution)
    ret = border_file_export_to_caret5_outputs(params, execution)
    execution.run(cargs)
    return ret


def border_file_export_to_caret5(
    border_file: str,
    output_file_prefix: str,
    surface: list[BorderFileExportToCaret5SurfaceParameters] | None = None,
    runner: Runner | None = None,
) -> BorderFileExportToCaret5Outputs:
    """
    border-file-export-to-caret5
    
    Export border file to caret5 file format.
    
    A Workbench border file may contain borders for multiple structures and
    borders that are both projected and unprojected. It also contains a color
    table for the borders.
    
    Caret5 has both border (unprojected) and border projection (projected)
    files. In addition, each Caret5 border or border projection file typically
    contains data for a single structure. Caret5 also uses a border color file
    that associates colors with the names of the borders.
    
    This command will try to output both Caret5 border and border projection
    files. Each output border/border projection file will contains data for one
    structure so there may be many files created. The structure name is included
    in the name of each border or border projection file that is created.
    
    One Caret5 border color file will also be produced by this command.
    
    Providing surface(s) as input parameters is optional, but recommended.
    Surfaces may be needed to create both projected and/or unprojected
    coordinates of borders. If there is a failure to produce an output border or
    border projection due to a missing surface with the matching structure, an
    error message will be displayed and some output files will not be created.
    
    When writing new files, this command will overwrite a file with the same
    name. .
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        border_file: workbench border file.
        output_file_prefix: prefix for name of output caret5\
            border/borderproj/bordercolor files.
        surface: specify an input surface.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BorderFileExportToCaret5Outputs`).
    """
    params = border_file_export_to_caret5_params(
        border_file=border_file,
        output_file_prefix=output_file_prefix,
        surface=surface,
    )
    return border_file_export_to_caret5_execute(params, runner)


__all__ = [
    "BORDER_FILE_EXPORT_TO_CARET5_METADATA",
    "BorderFileExportToCaret5Outputs",
    "border_file_export_to_caret5",
    "border_file_export_to_caret5_execute",
    "border_file_export_to_caret5_params",
    "border_file_export_to_caret5_surface_params",
]
