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

import typing
import pathlib
from styxdefs import *

CIFTI_PAIRWISE_CORRELATION_METADATA = Metadata(
    id="028724c21d89b563d8ea997344bbbb94f43f23a0.boutiques",
    name="cifti-pairwise-correlation",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


CiftiPairwiseCorrelationParameters = typing.TypedDict('CiftiPairwiseCorrelationParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-pairwise-correlation"]],
    "cifti_a": InputPathType,
    "cifti_b": InputPathType,
    "cifti_out": str,
    "opt_fisher_z": bool,
    "opt_override_mapping_check": bool,
})
CiftiPairwiseCorrelationParametersTagged = typing.TypedDict('CiftiPairwiseCorrelationParametersTagged', {
    "@type": typing.Literal["workbench/cifti-pairwise-correlation"],
    "cifti_a": InputPathType,
    "cifti_b": InputPathType,
    "cifti_out": str,
    "opt_fisher_z": bool,
    "opt_override_mapping_check": bool,
})


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


def cifti_pairwise_correlation_params(
    cifti_a: InputPathType,
    cifti_b: InputPathType,
    cifti_out: str,
    opt_fisher_z: bool = False,
    opt_override_mapping_check: bool = False,
) -> CiftiPairwiseCorrelationParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_a: first input cifti file.
        cifti_b: second input cifti file.
        cifti_out: output cifti file.
        opt_fisher_z: apply fisher small z transform (ie, artanh) to\
            correlation.
        opt_override_mapping_check: don't check the mappings for compatibility,\
            only check length.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-pairwise-correlation",
        "cifti_a": cifti_a,
        "cifti_b": cifti_b,
        "cifti_out": cifti_out,
        "opt_fisher_z": opt_fisher_z,
        "opt_override_mapping_check": opt_override_mapping_check,
    }
    return params


def cifti_pairwise_correlation_cargs(
    params: CiftiPairwiseCorrelationParameters,
    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-pairwise-correlation")
    cargs.append(execution.input_file(params.get("cifti_a", None)))
    cargs.append(execution.input_file(params.get("cifti_b", None)))
    cargs.append(params.get("cifti_out", None))
    if params.get("opt_fisher_z", False):
        cargs.append("-fisher-z")
    if params.get("opt_override_mapping_check", False):
        cargs.append("-override-mapping-check")
    return cargs


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


def cifti_pairwise_correlation_execute(
    params: CiftiPairwiseCorrelationParameters,
    runner: Runner | None = None,
) -> CiftiPairwiseCorrelationOutputs:
    """
    cifti-pairwise-correlation
    
    Correlate paired rows between two cifti files.
    
    For each row in <cifti-a>, correlate it with the same row in <cifti-b>, and
    put the result in the same row of <cifti-out>, which has only one column.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiPairwiseCorrelationOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_PAIRWISE_CORRELATION_METADATA)
    params = execution.params(params)
    cargs = cifti_pairwise_correlation_cargs(params, execution)
    ret = cifti_pairwise_correlation_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_pairwise_correlation(
    cifti_a: InputPathType,
    cifti_b: InputPathType,
    cifti_out: str,
    opt_fisher_z: bool = False,
    opt_override_mapping_check: bool = False,
    runner: Runner | None = None,
) -> CiftiPairwiseCorrelationOutputs:
    """
    cifti-pairwise-correlation
    
    Correlate paired rows between two cifti files.
    
    For each row in <cifti-a>, correlate it with the same row in <cifti-b>, and
    put the result in the same row of <cifti-out>, which has only one column.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        cifti_a: first input cifti file.
        cifti_b: second input cifti file.
        cifti_out: output cifti file.
        opt_fisher_z: apply fisher small z transform (ie, artanh) to\
            correlation.
        opt_override_mapping_check: don't check the mappings for compatibility,\
            only check length.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiPairwiseCorrelationOutputs`).
    """
    params = cifti_pairwise_correlation_params(
        cifti_a=cifti_a,
        cifti_b=cifti_b,
        cifti_out=cifti_out,
        opt_fisher_z=opt_fisher_z,
        opt_override_mapping_check=opt_override_mapping_check,
    )
    return cifti_pairwise_correlation_execute(params, runner)


__all__ = [
    "CIFTI_PAIRWISE_CORRELATION_METADATA",
    "CiftiPairwiseCorrelationOutputs",
    "cifti_pairwise_correlation",
    "cifti_pairwise_correlation_execute",
    "cifti_pairwise_correlation_params",
]
