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

import typing
import pathlib
from styxdefs import *

CIFTI_FALSE_CORRELATION_METADATA = Metadata(
    id="1eacf54b399e5ccb46fa2416a02ea0a697253276.boutiques",
    name="cifti-false-correlation",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


CiftiFalseCorrelationLeftSurfaceParameters = typing.TypedDict('CiftiFalseCorrelationLeftSurfaceParameters', {
    "@type": typing.NotRequired[typing.Literal["left_surface"]],
    "surface": InputPathType,
    "opt_dump_text_text_out": typing.NotRequired[str | None],
})
CiftiFalseCorrelationLeftSurfaceParametersTagged = typing.TypedDict('CiftiFalseCorrelationLeftSurfaceParametersTagged', {
    "@type": typing.Literal["left_surface"],
    "surface": InputPathType,
    "opt_dump_text_text_out": typing.NotRequired[str | None],
})


CiftiFalseCorrelationRightSurfaceParameters = typing.TypedDict('CiftiFalseCorrelationRightSurfaceParameters', {
    "@type": typing.NotRequired[typing.Literal["right_surface"]],
    "surface": InputPathType,
    "opt_dump_text_text_out": typing.NotRequired[str | None],
})
CiftiFalseCorrelationRightSurfaceParametersTagged = typing.TypedDict('CiftiFalseCorrelationRightSurfaceParametersTagged', {
    "@type": typing.Literal["right_surface"],
    "surface": InputPathType,
    "opt_dump_text_text_out": typing.NotRequired[str | None],
})


CiftiFalseCorrelationCerebellumSurfaceParameters = typing.TypedDict('CiftiFalseCorrelationCerebellumSurfaceParameters', {
    "@type": typing.NotRequired[typing.Literal["cerebellum_surface"]],
    "surface": InputPathType,
    "opt_dump_text_text_out": typing.NotRequired[str | None],
})
CiftiFalseCorrelationCerebellumSurfaceParametersTagged = typing.TypedDict('CiftiFalseCorrelationCerebellumSurfaceParametersTagged', {
    "@type": typing.Literal["cerebellum_surface"],
    "surface": InputPathType,
    "opt_dump_text_text_out": typing.NotRequired[str | None],
})


CiftiFalseCorrelationParameters = typing.TypedDict('CiftiFalseCorrelationParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-false-correlation"]],
    "cifti_in": InputPathType,
    "3d_dist": float,
    "geo_outer": float,
    "geo_inner": float,
    "cifti_out": str,
    "left_surface": typing.NotRequired[CiftiFalseCorrelationLeftSurfaceParameters | None],
    "right_surface": typing.NotRequired[CiftiFalseCorrelationRightSurfaceParameters | None],
    "cerebellum_surface": typing.NotRequired[CiftiFalseCorrelationCerebellumSurfaceParameters | None],
})
CiftiFalseCorrelationParametersTagged = typing.TypedDict('CiftiFalseCorrelationParametersTagged', {
    "@type": typing.Literal["workbench/cifti-false-correlation"],
    "cifti_in": InputPathType,
    "3d_dist": float,
    "geo_outer": float,
    "geo_inner": float,
    "cifti_out": str,
    "left_surface": typing.NotRequired[CiftiFalseCorrelationLeftSurfaceParameters | None],
    "right_surface": typing.NotRequired[CiftiFalseCorrelationRightSurfaceParameters | None],
    "cerebellum_surface": typing.NotRequired[CiftiFalseCorrelationCerebellumSurfaceParameters | None],
})


def cifti_false_correlation_left_surface_params(
    surface: InputPathType,
    opt_dump_text_text_out: str | None = None,
) -> CiftiFalseCorrelationLeftSurfaceParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the left surface file.
        opt_dump_text_text_out: dump the raw measures used to a text file: the\
            output text file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "left_surface",
        "surface": surface,
    }
    if opt_dump_text_text_out is not None:
        params["opt_dump_text_text_out"] = opt_dump_text_text_out
    return params


def cifti_false_correlation_left_surface_cargs(
    params: CiftiFalseCorrelationLeftSurfaceParameters,
    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("-left-surface")
    cargs.append(execution.input_file(params.get("surface", None)))
    if params.get("opt_dump_text_text_out", None) is not None:
        cargs.extend([
            "-dump-text",
            params.get("opt_dump_text_text_out", None)
        ])
    return cargs


def cifti_false_correlation_right_surface_params(
    surface: InputPathType,
    opt_dump_text_text_out: str | None = None,
) -> CiftiFalseCorrelationRightSurfaceParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the right surface file.
        opt_dump_text_text_out: dump the raw measures used to a text file: the\
            output text file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "right_surface",
        "surface": surface,
    }
    if opt_dump_text_text_out is not None:
        params["opt_dump_text_text_out"] = opt_dump_text_text_out
    return params


def cifti_false_correlation_right_surface_cargs(
    params: CiftiFalseCorrelationRightSurfaceParameters,
    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("-right-surface")
    cargs.append(execution.input_file(params.get("surface", None)))
    if params.get("opt_dump_text_text_out", None) is not None:
        cargs.extend([
            "-dump-text",
            params.get("opt_dump_text_text_out", None)
        ])
    return cargs


def cifti_false_correlation_cerebellum_surface_params(
    surface: InputPathType,
    opt_dump_text_text_out: str | None = None,
) -> CiftiFalseCorrelationCerebellumSurfaceParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the cerebellum surface file.
        opt_dump_text_text_out: dump the raw measures used to a text file: the\
            output text file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "cerebellum_surface",
        "surface": surface,
    }
    if opt_dump_text_text_out is not None:
        params["opt_dump_text_text_out"] = opt_dump_text_text_out
    return params


def cifti_false_correlation_cerebellum_surface_cargs(
    params: CiftiFalseCorrelationCerebellumSurfaceParameters,
    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("-cerebellum-surface")
    cargs.append(execution.input_file(params.get("surface", None)))
    if params.get("opt_dump_text_text_out", None) is not None:
        cargs.extend([
            "-dump-text",
            params.get("opt_dump_text_text_out", None)
        ])
    return cargs


class CiftiFalseCorrelationOutputs(typing.NamedTuple):
    """
    Output object returned when calling `CiftiFalseCorrelationParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    cifti_out: OutputPathType
    """the output cifti dscalar file"""


def cifti_false_correlation_params(
    cifti_in: InputPathType,
    v_3d_dist: float,
    geo_outer: float,
    geo_inner: float,
    cifti_out: str,
    left_surface: CiftiFalseCorrelationLeftSurfaceParameters | None = None,
    right_surface: CiftiFalseCorrelationRightSurfaceParameters | None = None,
    cerebellum_surface: CiftiFalseCorrelationCerebellumSurfaceParameters | None = None,
) -> CiftiFalseCorrelationParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_in: the cifti file to use for correlation.
        v_3d_dist: maximum 3D distance to check around each vertex.
        geo_outer: maximum geodesic distance to use for neighboring correlation.
        geo_inner: minimum geodesic distance to use for neighboring correlation.
        cifti_out: the output cifti dscalar file.
        left_surface: specify the left surface to use.
        right_surface: specify the right surface to use.
        cerebellum_surface: specify the cerebellum surface to use.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-false-correlation",
        "cifti_in": cifti_in,
        "3d_dist": v_3d_dist,
        "geo_outer": geo_outer,
        "geo_inner": geo_inner,
        "cifti_out": cifti_out,
    }
    if left_surface is not None:
        params["left_surface"] = left_surface
    if right_surface is not None:
        params["right_surface"] = right_surface
    if cerebellum_surface is not None:
        params["cerebellum_surface"] = cerebellum_surface
    return params


def cifti_false_correlation_cargs(
    params: CiftiFalseCorrelationParameters,
    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-false-correlation")
    cargs.append(execution.input_file(params.get("cifti_in", None)))
    cargs.append(str(params.get("3d_dist", None)))
    cargs.append(str(params.get("geo_outer", None)))
    cargs.append(str(params.get("geo_inner", None)))
    cargs.append(params.get("cifti_out", None))
    if params.get("left_surface", None) is not None:
        cargs.extend(cifti_false_correlation_left_surface_cargs(params.get("left_surface", None), execution))
    if params.get("right_surface", None) is not None:
        cargs.extend(cifti_false_correlation_right_surface_cargs(params.get("right_surface", None), execution))
    if params.get("cerebellum_surface", None) is not None:
        cargs.extend(cifti_false_correlation_cerebellum_surface_cargs(params.get("cerebellum_surface", None), execution))
    return cargs


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


def cifti_false_correlation_execute(
    params: CiftiFalseCorrelationParameters,
    runner: Runner | None = None,
) -> CiftiFalseCorrelationOutputs:
    """
    cifti-false-correlation
    
    Compare correlation locally and across/through sulci/gyri.
    
    For each vertex, compute the average correlation within a range of geodesic
    distances that don't cross a sulcus/gyrus, and the correlation to the
    closest vertex crossing a sulcus/gyrus. A vertex is considered to cross a
    sulcus/gyrus if the 3D distance is less than a third of the geodesic
    distance. The output file contains the ratio between these correlations, and
    some additional maps to help explain the ratio.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiFalseCorrelationOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_FALSE_CORRELATION_METADATA)
    params = execution.params(params)
    cargs = cifti_false_correlation_cargs(params, execution)
    ret = cifti_false_correlation_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_false_correlation(
    cifti_in: InputPathType,
    v_3d_dist: float,
    geo_outer: float,
    geo_inner: float,
    cifti_out: str,
    left_surface: CiftiFalseCorrelationLeftSurfaceParameters | None = None,
    right_surface: CiftiFalseCorrelationRightSurfaceParameters | None = None,
    cerebellum_surface: CiftiFalseCorrelationCerebellumSurfaceParameters | None = None,
    runner: Runner | None = None,
) -> CiftiFalseCorrelationOutputs:
    """
    cifti-false-correlation
    
    Compare correlation locally and across/through sulci/gyri.
    
    For each vertex, compute the average correlation within a range of geodesic
    distances that don't cross a sulcus/gyrus, and the correlation to the
    closest vertex crossing a sulcus/gyrus. A vertex is considered to cross a
    sulcus/gyrus if the 3D distance is less than a third of the geodesic
    distance. The output file contains the ratio between these correlations, and
    some additional maps to help explain the ratio.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        cifti_in: the cifti file to use for correlation.
        v_3d_dist: maximum 3D distance to check around each vertex.
        geo_outer: maximum geodesic distance to use for neighboring correlation.
        geo_inner: minimum geodesic distance to use for neighboring correlation.
        cifti_out: the output cifti dscalar file.
        left_surface: specify the left surface to use.
        right_surface: specify the right surface to use.
        cerebellum_surface: specify the cerebellum surface to use.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiFalseCorrelationOutputs`).
    """
    params = cifti_false_correlation_params(
        cifti_in=cifti_in,
        v_3d_dist=v_3d_dist,
        geo_outer=geo_outer,
        geo_inner=geo_inner,
        cifti_out=cifti_out,
        left_surface=left_surface,
        right_surface=right_surface,
        cerebellum_surface=cerebellum_surface,
    )
    return cifti_false_correlation_execute(params, runner)


__all__ = [
    "CIFTI_FALSE_CORRELATION_METADATA",
    "CiftiFalseCorrelationOutputs",
    "cifti_false_correlation",
    "cifti_false_correlation_cerebellum_surface_params",
    "cifti_false_correlation_execute",
    "cifti_false_correlation_left_surface_params",
    "cifti_false_correlation_params",
    "cifti_false_correlation_right_surface_params",
]
