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

import typing
import pathlib
from styxdefs import *

CIFTI_CORRELATION_GRADIENT_METADATA = Metadata(
    id="ee61d770d1b0dbf0c964ee821bf79b84aaac30f5.workbench",
    name="cifti-correlation-gradient",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_CiftiCorrelationGradientLeftSurfaceParamsDictNoTag = typing.TypedDict('_CiftiCorrelationGradientLeftSurfaceParamsDictNoTag', {
    "surface": InputPathType,
    "area-metric": typing.NotRequired[InputPathType | None],
})
CiftiCorrelationGradientLeftSurfaceParamsDictTagged = typing.TypedDict('CiftiCorrelationGradientLeftSurfaceParamsDictTagged', {
    "@type": typing.Literal["left-surface"],
    "surface": InputPathType,
    "area-metric": typing.NotRequired[InputPathType | None],
})
CiftiCorrelationGradientLeftSurfaceParamsDict = _CiftiCorrelationGradientLeftSurfaceParamsDictNoTag | CiftiCorrelationGradientLeftSurfaceParamsDictTagged


_CiftiCorrelationGradientRightSurfaceParamsDictNoTag = typing.TypedDict('_CiftiCorrelationGradientRightSurfaceParamsDictNoTag', {
    "surface": InputPathType,
    "area-metric": typing.NotRequired[InputPathType | None],
})
CiftiCorrelationGradientRightSurfaceParamsDictTagged = typing.TypedDict('CiftiCorrelationGradientRightSurfaceParamsDictTagged', {
    "@type": typing.Literal["right-surface"],
    "surface": InputPathType,
    "area-metric": typing.NotRequired[InputPathType | None],
})
CiftiCorrelationGradientRightSurfaceParamsDict = _CiftiCorrelationGradientRightSurfaceParamsDictNoTag | CiftiCorrelationGradientRightSurfaceParamsDictTagged


_CiftiCorrelationGradientCerebellumSurfaceParamsDictNoTag = typing.TypedDict('_CiftiCorrelationGradientCerebellumSurfaceParamsDictNoTag', {
    "surface": InputPathType,
    "area-metric": typing.NotRequired[InputPathType | None],
})
CiftiCorrelationGradientCerebellumSurfaceParamsDictTagged = typing.TypedDict('CiftiCorrelationGradientCerebellumSurfaceParamsDictTagged', {
    "@type": typing.Literal["cerebellum-surface"],
    "surface": InputPathType,
    "area-metric": typing.NotRequired[InputPathType | None],
})
CiftiCorrelationGradientCerebellumSurfaceParamsDict = _CiftiCorrelationGradientCerebellumSurfaceParamsDictNoTag | CiftiCorrelationGradientCerebellumSurfaceParamsDictTagged


_CiftiCorrelationGradientDoubleCorrelationParamsDictNoTag = typing.TypedDict('_CiftiCorrelationGradientDoubleCorrelationParamsDictNoTag', {
    "covariance-first": bool,
    "no-demean-first": bool,
    "fisher-z-first": bool,
})
CiftiCorrelationGradientDoubleCorrelationParamsDictTagged = typing.TypedDict('CiftiCorrelationGradientDoubleCorrelationParamsDictTagged', {
    "@type": typing.Literal["double-correlation"],
    "covariance-first": bool,
    "no-demean-first": bool,
    "fisher-z-first": bool,
})
CiftiCorrelationGradientDoubleCorrelationParamsDict = _CiftiCorrelationGradientDoubleCorrelationParamsDictNoTag | CiftiCorrelationGradientDoubleCorrelationParamsDictTagged


_CiftiCorrelationGradientParamsDictNoTag = typing.TypedDict('_CiftiCorrelationGradientParamsDictNoTag', {
    "cifti": InputPathType,
    "cifti-out": str,
    "left-surface": typing.NotRequired[CiftiCorrelationGradientLeftSurfaceParamsDict | None],
    "right-surface": typing.NotRequired[CiftiCorrelationGradientRightSurfaceParamsDict | None],
    "cerebellum-surface": typing.NotRequired[CiftiCorrelationGradientCerebellumSurfaceParamsDict | None],
    "double-correlation": typing.NotRequired[CiftiCorrelationGradientDoubleCorrelationParamsDict | None],
    "limit-GB": typing.NotRequired[float | None],
    "distance": typing.NotRequired[float | None],
    "distance": typing.NotRequired[float | None],
    "volume-kernel": typing.NotRequired[float | None],
    "surface-kernel": typing.NotRequired[float | None],
    "covariance": bool,
    "fisher-z": bool,
    "undo-fisher-z": bool,
    "presmooth-fwhm": bool,
})
CiftiCorrelationGradientParamsDictTagged = typing.TypedDict('CiftiCorrelationGradientParamsDictTagged', {
    "@type": typing.Literal["workbench/cifti-correlation-gradient"],
    "cifti": InputPathType,
    "cifti-out": str,
    "left-surface": typing.NotRequired[CiftiCorrelationGradientLeftSurfaceParamsDict | None],
    "right-surface": typing.NotRequired[CiftiCorrelationGradientRightSurfaceParamsDict | None],
    "cerebellum-surface": typing.NotRequired[CiftiCorrelationGradientCerebellumSurfaceParamsDict | None],
    "double-correlation": typing.NotRequired[CiftiCorrelationGradientDoubleCorrelationParamsDict | None],
    "limit-GB": typing.NotRequired[float | None],
    "distance": typing.NotRequired[float | None],
    "distance": typing.NotRequired[float | None],
    "volume-kernel": typing.NotRequired[float | None],
    "surface-kernel": typing.NotRequired[float | None],
    "covariance": bool,
    "fisher-z": bool,
    "undo-fisher-z": bool,
    "presmooth-fwhm": bool,
})
CiftiCorrelationGradientParamsDict = _CiftiCorrelationGradientParamsDictNoTag | CiftiCorrelationGradientParamsDictTagged


def cifti_correlation_gradient_left_surface(
    surface: InputPathType,
    area_metric: InputPathType | None = None,
) -> CiftiCorrelationGradientLeftSurfaceParamsDictTagged:
    """
    Build parameters.
    
    Args:
        surface: the left surface file.
        area_metric: vertex areas to use instead of computing them from the\
            left surface\
            \
            the corrected vertex areas, as a metric.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "left-surface",
        "surface": surface,
    }
    if area_metric is not None:
        params["area-metric"] = area_metric
    return params


def cifti_correlation_gradient_left_surface_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiCorrelationGradientLeftSurfaceParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("surface", None) is None:
        raise StyxValidationError("`surface` must not be None")
    if not isinstance(params["surface"], (pathlib.Path, str)):
        raise StyxValidationError(f'`surface` has the wrong type: Received `{type(params.get("surface", None))}` expected `InputPathType`')
    if params.get("area-metric", None) is not None:
        if not isinstance(params["area-metric"], (pathlib.Path, str)):
            raise StyxValidationError(f'`area-metric` has the wrong type: Received `{type(params.get("area-metric", None))}` expected `InputPathType | None`')


def cifti_correlation_gradient_left_surface_cargs(
    params: CiftiCorrelationGradientLeftSurfaceParamsDict,
    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.extend([
        "-left-surface",
        execution.input_file(params.get("surface", None))
    ])
    if params.get("area-metric", None) is not None:
        cargs.extend([
            "-left-corrected-areas",
            execution.input_file(params.get("area-metric", None))
        ])
    return cargs


def cifti_correlation_gradient_right_surface(
    surface: InputPathType,
    area_metric: InputPathType | None = None,
) -> CiftiCorrelationGradientRightSurfaceParamsDictTagged:
    """
    Build parameters.
    
    Args:
        surface: the right surface file.
        area_metric: vertex areas to use instead of computing them from the\
            right surface\
            \
            the corrected vertex areas, as a metric.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "right-surface",
        "surface": surface,
    }
    if area_metric is not None:
        params["area-metric"] = area_metric
    return params


def cifti_correlation_gradient_right_surface_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiCorrelationGradientRightSurfaceParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("surface", None) is None:
        raise StyxValidationError("`surface` must not be None")
    if not isinstance(params["surface"], (pathlib.Path, str)):
        raise StyxValidationError(f'`surface` has the wrong type: Received `{type(params.get("surface", None))}` expected `InputPathType`')
    if params.get("area-metric", None) is not None:
        if not isinstance(params["area-metric"], (pathlib.Path, str)):
            raise StyxValidationError(f'`area-metric` has the wrong type: Received `{type(params.get("area-metric", None))}` expected `InputPathType | None`')


def cifti_correlation_gradient_right_surface_cargs(
    params: CiftiCorrelationGradientRightSurfaceParamsDict,
    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.extend([
        "-right-surface",
        execution.input_file(params.get("surface", None))
    ])
    if params.get("area-metric", None) is not None:
        cargs.extend([
            "-right-corrected-areas",
            execution.input_file(params.get("area-metric", None))
        ])
    return cargs


def cifti_correlation_gradient_cerebellum_surface(
    surface: InputPathType,
    area_metric: InputPathType | None = None,
) -> CiftiCorrelationGradientCerebellumSurfaceParamsDictTagged:
    """
    Build parameters.
    
    Args:
        surface: the cerebellum surface file.
        area_metric: vertex areas to use instead of computing them from the\
            cerebellum surface\
            \
            the corrected vertex areas, as a metric.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "cerebellum-surface",
        "surface": surface,
    }
    if area_metric is not None:
        params["area-metric"] = area_metric
    return params


def cifti_correlation_gradient_cerebellum_surface_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiCorrelationGradientCerebellumSurfaceParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("surface", None) is None:
        raise StyxValidationError("`surface` must not be None")
    if not isinstance(params["surface"], (pathlib.Path, str)):
        raise StyxValidationError(f'`surface` has the wrong type: Received `{type(params.get("surface", None))}` expected `InputPathType`')
    if params.get("area-metric", None) is not None:
        if not isinstance(params["area-metric"], (pathlib.Path, str)):
            raise StyxValidationError(f'`area-metric` has the wrong type: Received `{type(params.get("area-metric", None))}` expected `InputPathType | None`')


def cifti_correlation_gradient_cerebellum_surface_cargs(
    params: CiftiCorrelationGradientCerebellumSurfaceParamsDict,
    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.extend([
        "-cerebellum-surface",
        execution.input_file(params.get("surface", None))
    ])
    if params.get("area-metric", None) is not None:
        cargs.extend([
            "-cerebellum-corrected-areas",
            execution.input_file(params.get("area-metric", None))
        ])
    return cargs


def cifti_correlation_gradient_double_correlation(
    covariance_first: bool = False,
    no_demean_first: bool = False,
    fisher_z_first: bool = False,
) -> CiftiCorrelationGradientDoubleCorrelationParamsDictTagged:
    """
    Build parameters.
    
    Args:
        covariance_first: instead of correlation for the FIRST operation,\
            compute covariance.
        no_demean_first: instead of correlation for the FIRST operation, do dot\
            product of rows, then normalize by diagonal.
        fisher_z_first: after the FIRST correlation, apply fisher small z\
            transform (ie, artanh).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "double-correlation",
        "covariance-first": covariance_first,
        "no-demean-first": no_demean_first,
        "fisher-z-first": fisher_z_first,
    }
    return params


def cifti_correlation_gradient_double_correlation_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiCorrelationGradientDoubleCorrelationParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("covariance-first", False) is None:
        raise StyxValidationError("`covariance-first` must not be None")
    if not isinstance(params["covariance-first"], bool):
        raise StyxValidationError(f'`covariance-first` has the wrong type: Received `{type(params.get("covariance-first", False))}` expected `bool`')
    if params.get("no-demean-first", False) is None:
        raise StyxValidationError("`no-demean-first` must not be None")
    if not isinstance(params["no-demean-first"], bool):
        raise StyxValidationError(f'`no-demean-first` has the wrong type: Received `{type(params.get("no-demean-first", False))}` expected `bool`')
    if params.get("fisher-z-first", False) is None:
        raise StyxValidationError("`fisher-z-first` must not be None")
    if not isinstance(params["fisher-z-first"], bool):
        raise StyxValidationError(f'`fisher-z-first` has the wrong type: Received `{type(params.get("fisher-z-first", False))}` expected `bool`')


def cifti_correlation_gradient_double_correlation_cargs(
    params: CiftiCorrelationGradientDoubleCorrelationParamsDict,
    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("-double-correlation")
    if params.get("covariance-first", False):
        cargs.append("-covariance-first")
    if params.get("no-demean-first", False):
        cargs.append("-no-demean-first")
    if params.get("fisher-z-first", False):
        cargs.append("-fisher-z-first")
    return cargs


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


def cifti_correlation_gradient_params(
    cifti: InputPathType,
    cifti_out: str,
    left_surface: CiftiCorrelationGradientLeftSurfaceParamsDict | None = None,
    right_surface: CiftiCorrelationGradientRightSurfaceParamsDict | None = None,
    cerebellum_surface: CiftiCorrelationGradientCerebellumSurfaceParamsDict | None = None,
    double_correlation: CiftiCorrelationGradientDoubleCorrelationParamsDict | None = None,
    limit_gb: float | None = None,
    distance: float | None = None,
    distance_: float | None = None,
    volume_kernel: float | None = None,
    surface_kernel: float | None = None,
    covariance: bool = False,
    fisher_z: bool = False,
    undo_fisher_z: bool = False,
    presmooth_fwhm: bool = False,
) -> CiftiCorrelationGradientParamsDictTagged:
    """
    Build parameters.
    
    Args:
        cifti: the input cifti.
        cifti_out: the output cifti.
        left_surface: specify the left surface to use.
        right_surface: specify the right surface to use.
        cerebellum_surface: specify the cerebellum surface to use.
        double_correlation: do two correlations before taking the gradient.
        limit_gb: restrict memory usage\
            \
            memory limit in gigabytes.
        distance: exclude voxels near each seed voxel from computation\
            \
            distance from seed voxel for the exclusion zone, in mm.
        distance_: exclude vertices near each seed vertex from computation\
            \
            geodesic distance from seed vertex for the exclusion zone, in mm.
        volume_kernel: smooth the volume before computing the gradient\
            \
            the size of the gaussian volume smoothing kernel in mm, as sigma by\
            default.
        surface_kernel: smooth on the surface before computing the gradient\
            \
            the size of the gaussian surface smoothing kernel in mm, as sigma\
            by default.
        covariance: compute covariance instead of correlation.
        fisher_z: apply the fisher small z transform to the correlations before\
            taking the gradient.
        undo_fisher_z: apply the inverse fisher small z transform to the input.
        presmooth_fwhm: smoothing kernel sizes are FWHM, not sigma.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-correlation-gradient",
        "cifti": cifti,
        "cifti-out": cifti_out,
        "covariance": covariance,
        "fisher-z": fisher_z,
        "undo-fisher-z": undo_fisher_z,
        "presmooth-fwhm": presmooth_fwhm,
    }
    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
    if double_correlation is not None:
        params["double-correlation"] = double_correlation
    if limit_gb is not None:
        params["limit-GB"] = limit_gb
    if distance is not None:
        params["distance"] = distance
    if distance_ is not None:
        params["distance"] = distance_
    if volume_kernel is not None:
        params["volume-kernel"] = volume_kernel
    if surface_kernel is not None:
        params["surface-kernel"] = surface_kernel
    return params


def cifti_correlation_gradient_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiCorrelationGradientParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("cifti", None) is None:
        raise StyxValidationError("`cifti` must not be None")
    if not isinstance(params["cifti"], (pathlib.Path, str)):
        raise StyxValidationError(f'`cifti` has the wrong type: Received `{type(params.get("cifti", None))}` expected `InputPathType`')
    if params.get("cifti-out", None) is None:
        raise StyxValidationError("`cifti-out` must not be None")
    if not isinstance(params["cifti-out"], str):
        raise StyxValidationError(f'`cifti-out` has the wrong type: Received `{type(params.get("cifti-out", None))}` expected `str`')
    if params.get("left-surface", None) is not None:
        cifti_correlation_gradient_left_surface_validate(params["left-surface"])
    if params.get("right-surface", None) is not None:
        cifti_correlation_gradient_right_surface_validate(params["right-surface"])
    if params.get("cerebellum-surface", None) is not None:
        cifti_correlation_gradient_cerebellum_surface_validate(params["cerebellum-surface"])
    if params.get("double-correlation", None) is not None:
        cifti_correlation_gradient_double_correlation_validate(params["double-correlation"])
    if params.get("limit-GB", None) is not None:
        if not isinstance(params["limit-GB"], (float, int)):
            raise StyxValidationError(f'`limit-GB` has the wrong type: Received `{type(params.get("limit-GB", None))}` expected `float | None`')
    if params.get("distance", None) is not None:
        if not isinstance(params["distance"], (float, int)):
            raise StyxValidationError(f'`distance` has the wrong type: Received `{type(params.get("distance", None))}` expected `float | None`')
    if params.get("distance", None) is not None:
        if not isinstance(params["distance"], (float, int)):
            raise StyxValidationError(f'`distance` has the wrong type: Received `{type(params.get("distance", None))}` expected `float | None`')
    if params.get("volume-kernel", None) is not None:
        if not isinstance(params["volume-kernel"], (float, int)):
            raise StyxValidationError(f'`volume-kernel` has the wrong type: Received `{type(params.get("volume-kernel", None))}` expected `float | None`')
    if params.get("surface-kernel", None) is not None:
        if not isinstance(params["surface-kernel"], (float, int)):
            raise StyxValidationError(f'`surface-kernel` has the wrong type: Received `{type(params.get("surface-kernel", None))}` expected `float | None`')
    if params.get("covariance", False) is None:
        raise StyxValidationError("`covariance` must not be None")
    if not isinstance(params["covariance"], bool):
        raise StyxValidationError(f'`covariance` has the wrong type: Received `{type(params.get("covariance", False))}` expected `bool`')
    if params.get("fisher-z", False) is None:
        raise StyxValidationError("`fisher-z` must not be None")
    if not isinstance(params["fisher-z"], bool):
        raise StyxValidationError(f'`fisher-z` has the wrong type: Received `{type(params.get("fisher-z", False))}` expected `bool`')
    if params.get("undo-fisher-z", False) is None:
        raise StyxValidationError("`undo-fisher-z` must not be None")
    if not isinstance(params["undo-fisher-z"], bool):
        raise StyxValidationError(f'`undo-fisher-z` has the wrong type: Received `{type(params.get("undo-fisher-z", False))}` expected `bool`')
    if params.get("presmooth-fwhm", False) is None:
        raise StyxValidationError("`presmooth-fwhm` must not be None")
    if not isinstance(params["presmooth-fwhm"], bool):
        raise StyxValidationError(f'`presmooth-fwhm` has the wrong type: Received `{type(params.get("presmooth-fwhm", False))}` expected `bool`')


def cifti_correlation_gradient_cargs(
    params: CiftiCorrelationGradientParamsDict,
    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.extend([
        "wb_command",
        "-cifti-correlation-gradient"
    ])
    cargs.append(execution.input_file(params.get("cifti", None)))
    cargs.append(params.get("cifti-out", None))
    if params.get("left-surface", None) is not None or params.get("right-surface", None) is not None or params.get("cerebellum-surface", None) is not None or params.get("double-correlation", None) is not None:
        cargs.extend([
            *(cifti_correlation_gradient_left_surface_cargs(params.get("left-surface", None), execution) if (params.get("left-surface", None) is not None) else []),
            *(cifti_correlation_gradient_right_surface_cargs(params.get("right-surface", None), execution) if (params.get("right-surface", None) is not None) else []),
            *(cifti_correlation_gradient_cerebellum_surface_cargs(params.get("cerebellum-surface", None), execution) if (params.get("cerebellum-surface", None) is not None) else []),
            *(cifti_correlation_gradient_double_correlation_cargs(params.get("double-correlation", None), execution) if (params.get("double-correlation", None) is not None) else [])
        ])
    if params.get("limit-GB", None) is not None:
        cargs.extend([
            "-mem-limit",
            str(params.get("limit-GB", None))
        ])
    if params.get("distance", None) is not None:
        cargs.extend([
            "-volume-exclude",
            str(params.get("distance", None))
        ])
    if params.get("distance", None) is not None:
        cargs.extend([
            "-surface-exclude",
            str(params.get("distance", None))
        ])
    if params.get("volume-kernel", None) is not None:
        cargs.extend([
            "-volume-presmooth",
            str(params.get("volume-kernel", None))
        ])
    if params.get("surface-kernel", None) is not None:
        cargs.extend([
            "-surface-presmooth",
            str(params.get("surface-kernel", None))
        ])
    if params.get("covariance", False):
        cargs.append("-covariance")
    if params.get("fisher-z", False):
        cargs.append("-fisher-z")
    if params.get("undo-fisher-z", False):
        cargs.append("-undo-fisher-z")
    if params.get("presmooth-fwhm", False):
        cargs.append("-presmooth-fwhm")
    return cargs


def cifti_correlation_gradient_outputs(
    params: CiftiCorrelationGradientParamsDict,
    execution: Execution,
) -> CiftiCorrelationGradientOutputs:
    """
    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 = CiftiCorrelationGradientOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(params.get("cifti-out", None)),
    )
    return ret


def cifti_correlation_gradient_execute(
    params: CiftiCorrelationGradientParamsDict,
    runner: Runner | None = None,
) -> CiftiCorrelationGradientOutputs:
    """
    CORRELATE CIFTI ROWS AND TAKE GRADIENT.
    
    For each structure, compute the correlation of the rows in the structure,
    and take the gradients of the resulting rows, then average them. Memory
    limit does not need to be an integer, you may also specify 0 to use as
    little memory as possible (this may be very slow).
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiCorrelationGradientOutputs`).
    """
    cifti_correlation_gradient_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_CORRELATION_GRADIENT_METADATA)
    params = execution.params(params)
    cargs = cifti_correlation_gradient_cargs(params, execution)
    ret = cifti_correlation_gradient_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_correlation_gradient(
    cifti: InputPathType,
    cifti_out: str,
    left_surface: CiftiCorrelationGradientLeftSurfaceParamsDict | None = None,
    right_surface: CiftiCorrelationGradientRightSurfaceParamsDict | None = None,
    cerebellum_surface: CiftiCorrelationGradientCerebellumSurfaceParamsDict | None = None,
    double_correlation: CiftiCorrelationGradientDoubleCorrelationParamsDict | None = None,
    limit_gb: float | None = None,
    distance: float | None = None,
    distance_: float | None = None,
    volume_kernel: float | None = None,
    surface_kernel: float | None = None,
    covariance: bool = False,
    fisher_z: bool = False,
    undo_fisher_z: bool = False,
    presmooth_fwhm: bool = False,
    runner: Runner | None = None,
) -> CiftiCorrelationGradientOutputs:
    """
    CORRELATE CIFTI ROWS AND TAKE GRADIENT.
    
    For each structure, compute the correlation of the rows in the structure,
    and take the gradients of the resulting rows, then average them. Memory
    limit does not need to be an integer, you may also specify 0 to use as
    little memory as possible (this may be very slow).
    
    Args:
        cifti: the input cifti.
        cifti_out: the output cifti.
        left_surface: specify the left surface to use.
        right_surface: specify the right surface to use.
        cerebellum_surface: specify the cerebellum surface to use.
        double_correlation: do two correlations before taking the gradient.
        limit_gb: restrict memory usage\
            \
            memory limit in gigabytes.
        distance: exclude voxels near each seed voxel from computation\
            \
            distance from seed voxel for the exclusion zone, in mm.
        distance_: exclude vertices near each seed vertex from computation\
            \
            geodesic distance from seed vertex for the exclusion zone, in mm.
        volume_kernel: smooth the volume before computing the gradient\
            \
            the size of the gaussian volume smoothing kernel in mm, as sigma by\
            default.
        surface_kernel: smooth on the surface before computing the gradient\
            \
            the size of the gaussian surface smoothing kernel in mm, as sigma\
            by default.
        covariance: compute covariance instead of correlation.
        fisher_z: apply the fisher small z transform to the correlations before\
            taking the gradient.
        undo_fisher_z: apply the inverse fisher small z transform to the input.
        presmooth_fwhm: smoothing kernel sizes are FWHM, not sigma.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiCorrelationGradientOutputs`).
    """
    params = cifti_correlation_gradient_params(
        cifti=cifti,
        cifti_out=cifti_out,
        left_surface=left_surface,
        right_surface=right_surface,
        cerebellum_surface=cerebellum_surface,
        double_correlation=double_correlation,
        limit_gb=limit_gb,
        distance=distance,
        distance_=distance_,
        volume_kernel=volume_kernel,
        surface_kernel=surface_kernel,
        covariance=covariance,
        fisher_z=fisher_z,
        undo_fisher_z=undo_fisher_z,
        presmooth_fwhm=presmooth_fwhm,
    )
    return cifti_correlation_gradient_execute(params, runner)


__all__ = [
    "CIFTI_CORRELATION_GRADIENT_METADATA",
    "CiftiCorrelationGradientCerebellumSurfaceParamsDict",
    "CiftiCorrelationGradientCerebellumSurfaceParamsDictTagged",
    "CiftiCorrelationGradientDoubleCorrelationParamsDict",
    "CiftiCorrelationGradientDoubleCorrelationParamsDictTagged",
    "CiftiCorrelationGradientLeftSurfaceParamsDict",
    "CiftiCorrelationGradientLeftSurfaceParamsDictTagged",
    "CiftiCorrelationGradientOutputs",
    "CiftiCorrelationGradientParamsDict",
    "CiftiCorrelationGradientParamsDictTagged",
    "CiftiCorrelationGradientRightSurfaceParamsDict",
    "CiftiCorrelationGradientRightSurfaceParamsDictTagged",
    "cifti_correlation_gradient",
    "cifti_correlation_gradient_cerebellum_surface",
    "cifti_correlation_gradient_double_correlation",
    "cifti_correlation_gradient_execute",
    "cifti_correlation_gradient_left_surface",
    "cifti_correlation_gradient_params",
    "cifti_correlation_gradient_right_surface",
]
