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

import typing
import pathlib
from styxdefs import *
import dataclasses

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


@dataclasses.dataclass
class CiftiFalseCorrelationLeftSurface:
    """
    specify the left surface to use.
    """
    surface: InputPathType
    """the left surface file"""
    opt_dump_text_text_out: str | None = None
    """dump the raw measures used to a text file: the output text file"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-left-surface")
        cargs.append(execution.input_file(self.surface))
        if self.opt_dump_text_text_out is not None:
            cargs.extend([
                "-dump-text",
                self.opt_dump_text_text_out
            ])
        return cargs


@dataclasses.dataclass
class CiftiFalseCorrelationRightSurface:
    """
    specify the right surface to use.
    """
    surface: InputPathType
    """the right surface file"""
    opt_dump_text_text_out: str | None = None
    """dump the raw measures used to a text file: the output text file"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-right-surface")
        cargs.append(execution.input_file(self.surface))
        if self.opt_dump_text_text_out is not None:
            cargs.extend([
                "-dump-text",
                self.opt_dump_text_text_out
            ])
        return cargs


@dataclasses.dataclass
class CiftiFalseCorrelationCerebellumSurface:
    """
    specify the cerebellum surface to use.
    """
    surface: InputPathType
    """the cerebellum surface file"""
    opt_dump_text_text_out: str | None = None
    """dump the raw measures used to a text file: the output text file"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-cerebellum-surface")
        cargs.append(execution.input_file(self.surface))
        if self.opt_dump_text_text_out is not None:
            cargs.extend([
                "-dump-text",
                self.opt_dump_text_text_out
            ])
        return cargs


class CiftiFalseCorrelationOutputs(typing.NamedTuple):
    """
    Output object returned when calling `cifti_false_correlation(...)`.
    """
    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(
    cifti_in: InputPathType,
    v_3d_dist: float,
    geo_outer: float,
    geo_inner: float,
    cifti_out: str,
    left_surface: CiftiFalseCorrelationLeftSurface | None = None,
    right_surface: CiftiFalseCorrelationRightSurface | None = None,
    cerebellum_surface: CiftiFalseCorrelationCerebellumSurface | None = None,
    runner: Runner | None = None,
) -> CiftiFalseCorrelationOutputs:
    """
    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: Washington University School of Medicin
    
    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`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_FALSE_CORRELATION_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-cifti-false-correlation")
    cargs.append(execution.input_file(cifti_in))
    cargs.append(str(v_3d_dist))
    cargs.append(str(geo_outer))
    cargs.append(str(geo_inner))
    cargs.append(cifti_out)
    if left_surface is not None:
        cargs.extend(left_surface.run(execution))
    if right_surface is not None:
        cargs.extend(right_surface.run(execution))
    if cerebellum_surface is not None:
        cargs.extend(cerebellum_surface.run(execution))
    ret = CiftiFalseCorrelationOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(cifti_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "CIFTI_FALSE_CORRELATION_METADATA",
    "CiftiFalseCorrelationCerebellumSurface",
    "CiftiFalseCorrelationLeftSurface",
    "CiftiFalseCorrelationOutputs",
    "CiftiFalseCorrelationRightSurface",
    "cifti_false_correlation",
]
