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

import typing
import pathlib
from styxdefs import *

SURFACE_TO_SURFACE_3D_DISTANCE_METADATA = Metadata(
    id="c626cddf06128e06492b24180056cbbcb098a4c4.boutiques",
    name="surface-to-surface-3d-distance",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SurfaceToSurface3dDistanceParameters = typing.TypedDict('SurfaceToSurface3dDistanceParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/surface-to-surface-3d-distance"]],
    "surface_comp": InputPathType,
    "surface_ref": InputPathType,
    "dists_out": str,
    "opt_vectors_vectors_out": typing.NotRequired[str | None],
})
SurfaceToSurface3dDistanceParametersTagged = typing.TypedDict('SurfaceToSurface3dDistanceParametersTagged', {
    "@type": typing.Literal["workbench/surface-to-surface-3d-distance"],
    "surface_comp": InputPathType,
    "surface_ref": InputPathType,
    "dists_out": str,
    "opt_vectors_vectors_out": typing.NotRequired[str | None],
})


class SurfaceToSurface3dDistanceOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceToSurface3dDistanceParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    dists_out: OutputPathType
    """the output distances"""
    opt_vectors_vectors_out: OutputPathType | None
    """output the displacement vectors: the output vectors"""


def surface_to_surface_3d_distance_params(
    surface_comp: InputPathType,
    surface_ref: InputPathType,
    dists_out: str,
    opt_vectors_vectors_out: str | None = None,
) -> SurfaceToSurface3dDistanceParametersTagged:
    """
    Build parameters.
    
    Args:
        surface_comp: the surface to compare to the reference.
        surface_ref: the surface to use as the reference.
        dists_out: the output distances.
        opt_vectors_vectors_out: output the displacement vectors: the output\
            vectors.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-to-surface-3d-distance",
        "surface_comp": surface_comp,
        "surface_ref": surface_ref,
        "dists_out": dists_out,
    }
    if opt_vectors_vectors_out is not None:
        params["opt_vectors_vectors_out"] = opt_vectors_vectors_out
    return params


def surface_to_surface_3d_distance_cargs(
    params: SurfaceToSurface3dDistanceParameters,
    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("-surface-to-surface-3d-distance")
    cargs.append(execution.input_file(params.get("surface_comp", None)))
    cargs.append(execution.input_file(params.get("surface_ref", None)))
    cargs.append(params.get("dists_out", None))
    if params.get("opt_vectors_vectors_out", None) is not None:
        cargs.extend([
            "-vectors",
            params.get("opt_vectors_vectors_out", None)
        ])
    return cargs


def surface_to_surface_3d_distance_outputs(
    params: SurfaceToSurface3dDistanceParameters,
    execution: Execution,
) -> SurfaceToSurface3dDistanceOutputs:
    """
    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 = SurfaceToSurface3dDistanceOutputs(
        root=execution.output_file("."),
        dists_out=execution.output_file(params.get("dists_out", None)),
        opt_vectors_vectors_out=execution.output_file(params.get("opt_vectors_vectors_out", None)) if (params.get("opt_vectors_vectors_out") is not None) else None,
    )
    return ret


def surface_to_surface_3d_distance_execute(
    params: SurfaceToSurface3dDistanceParameters,
    runner: Runner | None = None,
) -> SurfaceToSurface3dDistanceOutputs:
    """
    surface-to-surface-3d-distance
    
    Compute distance between corresponding vertices.
    
    Computes the vector difference between the vertices of each surface with the
    same index, as (comp - ref), and output the magnitudes, and optionally the
    displacement vectors.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceToSurface3dDistanceOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_TO_SURFACE_3D_DISTANCE_METADATA)
    params = execution.params(params)
    cargs = surface_to_surface_3d_distance_cargs(params, execution)
    ret = surface_to_surface_3d_distance_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_to_surface_3d_distance(
    surface_comp: InputPathType,
    surface_ref: InputPathType,
    dists_out: str,
    opt_vectors_vectors_out: str | None = None,
    runner: Runner | None = None,
) -> SurfaceToSurface3dDistanceOutputs:
    """
    surface-to-surface-3d-distance
    
    Compute distance between corresponding vertices.
    
    Computes the vector difference between the vertices of each surface with the
    same index, as (comp - ref), and output the magnitudes, and optionally the
    displacement vectors.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface_comp: the surface to compare to the reference.
        surface_ref: the surface to use as the reference.
        dists_out: the output distances.
        opt_vectors_vectors_out: output the displacement vectors: the output\
            vectors.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceToSurface3dDistanceOutputs`).
    """
    params = surface_to_surface_3d_distance_params(
        surface_comp=surface_comp,
        surface_ref=surface_ref,
        dists_out=dists_out,
        opt_vectors_vectors_out=opt_vectors_vectors_out,
    )
    return surface_to_surface_3d_distance_execute(params, runner)


__all__ = [
    "SURFACE_TO_SURFACE_3D_DISTANCE_METADATA",
    "SurfaceToSurface3dDistanceOutputs",
    "surface_to_surface_3d_distance",
    "surface_to_surface_3d_distance_execute",
    "surface_to_surface_3d_distance_params",
]
