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

import typing
import pathlib
from styxdefs import *

METRIC_VECTOR_TOWARD_ROI_METADATA = Metadata(
    id="6787be48822358a7213f746f7be34a018067adb3.boutiques",
    name="metric-vector-toward-roi",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


MetricVectorTowardRoiParameters = typing.TypedDict('MetricVectorTowardRoiParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/metric-vector-toward-roi"]],
    "surface": InputPathType,
    "target_roi": InputPathType,
    "metric_out": str,
    "opt_roi_roi_metric": typing.NotRequired[InputPathType | None],
})
MetricVectorTowardRoiParametersTagged = typing.TypedDict('MetricVectorTowardRoiParametersTagged', {
    "@type": typing.Literal["workbench/metric-vector-toward-roi"],
    "surface": InputPathType,
    "target_roi": InputPathType,
    "metric_out": str,
    "opt_roi_roi_metric": typing.NotRequired[InputPathType | None],
})


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


def metric_vector_toward_roi_params(
    surface: InputPathType,
    target_roi: InputPathType,
    metric_out: str,
    opt_roi_roi_metric: InputPathType | None = None,
) -> MetricVectorTowardRoiParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to compute on.
        target_roi: the roi to find the shortest path to.
        metric_out: the output metric.
        opt_roi_roi_metric: don't compute for vertices outside an roi: the\
            region to compute inside, as a metric.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/metric-vector-toward-roi",
        "surface": surface,
        "target_roi": target_roi,
        "metric_out": metric_out,
    }
    if opt_roi_roi_metric is not None:
        params["opt_roi_roi_metric"] = opt_roi_roi_metric
    return params


def metric_vector_toward_roi_cargs(
    params: MetricVectorTowardRoiParameters,
    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("-metric-vector-toward-roi")
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(execution.input_file(params.get("target_roi", None)))
    cargs.append(params.get("metric_out", None))
    if params.get("opt_roi_roi_metric", None) is not None:
        cargs.extend([
            "-roi",
            execution.input_file(params.get("opt_roi_roi_metric", None))
        ])
    return cargs


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


def metric_vector_toward_roi_execute(
    params: MetricVectorTowardRoiParameters,
    runner: Runner | None = None,
) -> MetricVectorTowardRoiOutputs:
    """
    metric-vector-toward-roi
    
    Find if vectors point toward an roi.
    
    At each vertex, compute the vector along the start of the shortest path to
    the ROI.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MetricVectorTowardRoiOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(METRIC_VECTOR_TOWARD_ROI_METADATA)
    params = execution.params(params)
    cargs = metric_vector_toward_roi_cargs(params, execution)
    ret = metric_vector_toward_roi_outputs(params, execution)
    execution.run(cargs)
    return ret


def metric_vector_toward_roi(
    surface: InputPathType,
    target_roi: InputPathType,
    metric_out: str,
    opt_roi_roi_metric: InputPathType | None = None,
    runner: Runner | None = None,
) -> MetricVectorTowardRoiOutputs:
    """
    metric-vector-toward-roi
    
    Find if vectors point toward an roi.
    
    At each vertex, compute the vector along the start of the shortest path to
    the ROI.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface: the surface to compute on.
        target_roi: the roi to find the shortest path to.
        metric_out: the output metric.
        opt_roi_roi_metric: don't compute for vertices outside an roi: the\
            region to compute inside, as a metric.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MetricVectorTowardRoiOutputs`).
    """
    params = metric_vector_toward_roi_params(
        surface=surface,
        target_roi=target_roi,
        metric_out=metric_out,
        opt_roi_roi_metric=opt_roi_roi_metric,
    )
    return metric_vector_toward_roi_execute(params, runner)


__all__ = [
    "METRIC_VECTOR_TOWARD_ROI_METADATA",
    "MetricVectorTowardRoiOutputs",
    "metric_vector_toward_roi",
    "metric_vector_toward_roi_execute",
    "metric_vector_toward_roi_params",
]
