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

import typing
import pathlib
from styxdefs import *

SURFACE_GEODESIC_DISTANCE_ALL_TO_ALL_METADATA = Metadata(
    id="7198c6400471913047c2af5e7257561969e48b2a.boutiques",
    name="surface-geodesic-distance-all-to-all",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SurfaceGeodesicDistanceAllToAllParameters = typing.TypedDict('SurfaceGeodesicDistanceAllToAllParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/surface-geodesic-distance-all-to-all"]],
    "surface": InputPathType,
    "cifti_out": str,
    "opt_roi_roi_metric": typing.NotRequired[InputPathType | None],
    "opt_limit_limit_mm": typing.NotRequired[float | None],
    "opt_corrected_areas_area_metric": typing.NotRequired[InputPathType | None],
    "opt_naive": bool,
})
SurfaceGeodesicDistanceAllToAllParametersTagged = typing.TypedDict('SurfaceGeodesicDistanceAllToAllParametersTagged', {
    "@type": typing.Literal["workbench/surface-geodesic-distance-all-to-all"],
    "surface": InputPathType,
    "cifti_out": str,
    "opt_roi_roi_metric": typing.NotRequired[InputPathType | None],
    "opt_limit_limit_mm": typing.NotRequired[float | None],
    "opt_corrected_areas_area_metric": typing.NotRequired[InputPathType | None],
    "opt_naive": bool,
})


class SurfaceGeodesicDistanceAllToAllOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceGeodesicDistanceAllToAllParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    cifti_out: OutputPathType
    """single-hemisphere dconn containing the distances"""


def surface_geodesic_distance_all_to_all_params(
    surface: InputPathType,
    cifti_out: str,
    opt_roi_roi_metric: InputPathType | None = None,
    opt_limit_limit_mm: float | None = None,
    opt_corrected_areas_area_metric: InputPathType | None = None,
    opt_naive: bool = False,
) -> SurfaceGeodesicDistanceAllToAllParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to compute on.
        cifti_out: single-hemisphere dconn containing the distances.
        opt_roi_roi_metric: only output distances for vertices inside an ROI:\
            the ROI as a metric file.
        opt_limit_limit_mm: stop at a specified distance: distance in mm to\
            stop at.
        opt_corrected_areas_area_metric: vertex areas to use instead of\
            computing them from the surface: the corrected vertex areas, as a\
            metric.
        opt_naive: use only neighbors, don't crawl triangles (not recommended).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-geodesic-distance-all-to-all",
        "surface": surface,
        "cifti_out": cifti_out,
        "opt_naive": opt_naive,
    }
    if opt_roi_roi_metric is not None:
        params["opt_roi_roi_metric"] = opt_roi_roi_metric
    if opt_limit_limit_mm is not None:
        params["opt_limit_limit_mm"] = opt_limit_limit_mm
    if opt_corrected_areas_area_metric is not None:
        params["opt_corrected_areas_area_metric"] = opt_corrected_areas_area_metric
    return params


def surface_geodesic_distance_all_to_all_cargs(
    params: SurfaceGeodesicDistanceAllToAllParameters,
    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-geodesic-distance-all-to-all")
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(params.get("cifti_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))
        ])
    if params.get("opt_limit_limit_mm", None) is not None:
        cargs.extend([
            "-limit",
            str(params.get("opt_limit_limit_mm", None))
        ])
    if params.get("opt_corrected_areas_area_metric", None) is not None:
        cargs.extend([
            "-corrected-areas",
            execution.input_file(params.get("opt_corrected_areas_area_metric", None))
        ])
    if params.get("opt_naive", False):
        cargs.append("-naive")
    return cargs


def surface_geodesic_distance_all_to_all_outputs(
    params: SurfaceGeodesicDistanceAllToAllParameters,
    execution: Execution,
) -> SurfaceGeodesicDistanceAllToAllOutputs:
    """
    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 = SurfaceGeodesicDistanceAllToAllOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(params.get("cifti_out", None)),
    )
    return ret


def surface_geodesic_distance_all_to_all_execute(
    params: SurfaceGeodesicDistanceAllToAllParameters,
    runner: Runner | None = None,
) -> SurfaceGeodesicDistanceAllToAllOutputs:
    """
    surface-geodesic-distance-all-to-all
    
    Compute geodesic distances from all vertices.
    
    Computes geodesic distance from every vertex to every vertex, outputting a
    single-hemisphere dconn file. If you are only interested in a few vertices,
    see -surface-geodesic-distance. When -limit is specified, any vertex beyond
    the limit is assigned the value -1.
    
    The -roi option makes the output file smaller by not outputting distances to
    or from vertices outside the ROI, but paths are still allowed to go outside
    the ROI when finding distances to other vertices.
    
    The -corrected-areas option should be used when the input is a group average
    surface - group average surfaces have significantly less surface area than
    individual surfaces do, and therefore distances measured on them would be
    smaller than measuring them on individual surfaces. In this case, the input
    to this option should be a group average of the output of
    -surface-vertex-areas for each subject.
    
    If -naive is not specified, the algorithm uses not just immediate neighbors,
    but also neighbors derived from crawling across pairs of triangles that
    share an edge.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceGeodesicDistanceAllToAllOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_GEODESIC_DISTANCE_ALL_TO_ALL_METADATA)
    params = execution.params(params)
    cargs = surface_geodesic_distance_all_to_all_cargs(params, execution)
    ret = surface_geodesic_distance_all_to_all_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_geodesic_distance_all_to_all(
    surface: InputPathType,
    cifti_out: str,
    opt_roi_roi_metric: InputPathType | None = None,
    opt_limit_limit_mm: float | None = None,
    opt_corrected_areas_area_metric: InputPathType | None = None,
    opt_naive: bool = False,
    runner: Runner | None = None,
) -> SurfaceGeodesicDistanceAllToAllOutputs:
    """
    surface-geodesic-distance-all-to-all
    
    Compute geodesic distances from all vertices.
    
    Computes geodesic distance from every vertex to every vertex, outputting a
    single-hemisphere dconn file. If you are only interested in a few vertices,
    see -surface-geodesic-distance. When -limit is specified, any vertex beyond
    the limit is assigned the value -1.
    
    The -roi option makes the output file smaller by not outputting distances to
    or from vertices outside the ROI, but paths are still allowed to go outside
    the ROI when finding distances to other vertices.
    
    The -corrected-areas option should be used when the input is a group average
    surface - group average surfaces have significantly less surface area than
    individual surfaces do, and therefore distances measured on them would be
    smaller than measuring them on individual surfaces. In this case, the input
    to this option should be a group average of the output of
    -surface-vertex-areas for each subject.
    
    If -naive is not specified, the algorithm uses not just immediate neighbors,
    but also neighbors derived from crawling across pairs of triangles that
    share an edge.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface: the surface to compute on.
        cifti_out: single-hemisphere dconn containing the distances.
        opt_roi_roi_metric: only output distances for vertices inside an ROI:\
            the ROI as a metric file.
        opt_limit_limit_mm: stop at a specified distance: distance in mm to\
            stop at.
        opt_corrected_areas_area_metric: vertex areas to use instead of\
            computing them from the surface: the corrected vertex areas, as a\
            metric.
        opt_naive: use only neighbors, don't crawl triangles (not recommended).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceGeodesicDistanceAllToAllOutputs`).
    """
    params = surface_geodesic_distance_all_to_all_params(
        surface=surface,
        cifti_out=cifti_out,
        opt_roi_roi_metric=opt_roi_roi_metric,
        opt_limit_limit_mm=opt_limit_limit_mm,
        opt_corrected_areas_area_metric=opt_corrected_areas_area_metric,
        opt_naive=opt_naive,
    )
    return surface_geodesic_distance_all_to_all_execute(params, runner)


__all__ = [
    "SURFACE_GEODESIC_DISTANCE_ALL_TO_ALL_METADATA",
    "SurfaceGeodesicDistanceAllToAllOutputs",
    "surface_geodesic_distance_all_to_all",
    "surface_geodesic_distance_all_to_all_execute",
    "surface_geodesic_distance_all_to_all_params",
]
