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

import typing
import pathlib
from styxdefs import *

CIFTI_VECTOR_OPERATION_METADATA = Metadata(
    id="f2e48c5e90ab1fc3469efcc7e302453fee58fb58.boutiques",
    name="cifti-vector-operation",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


CiftiVectorOperationParameters = typing.TypedDict('CiftiVectorOperationParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-vector-operation"]],
    "vectors_a": InputPathType,
    "vectors_b": InputPathType,
    "operation": str,
    "cifti_out": str,
    "opt_normalize_a": bool,
    "opt_normalize_b": bool,
    "opt_normalize_output": bool,
    "opt_magnitude": bool,
})
CiftiVectorOperationParametersTagged = typing.TypedDict('CiftiVectorOperationParametersTagged', {
    "@type": typing.Literal["workbench/cifti-vector-operation"],
    "vectors_a": InputPathType,
    "vectors_b": InputPathType,
    "operation": str,
    "cifti_out": str,
    "opt_normalize_a": bool,
    "opt_normalize_b": bool,
    "opt_normalize_output": bool,
    "opt_magnitude": bool,
})


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


def cifti_vector_operation_params(
    vectors_a: InputPathType,
    vectors_b: InputPathType,
    operation: str,
    cifti_out: str,
    opt_normalize_a: bool = False,
    opt_normalize_b: bool = False,
    opt_normalize_output: bool = False,
    opt_magnitude: bool = False,
) -> CiftiVectorOperationParametersTagged:
    """
    Build parameters.
    
    Args:
        vectors_a: first vector input file.
        vectors_b: second vector input file.
        operation: what vector operation to do.
        cifti_out: the output file.
        opt_normalize_a: normalize vectors of first input.
        opt_normalize_b: normalize vectors of second input.
        opt_normalize_output: normalize output vectors (not valid for dot\
            product).
        opt_magnitude: output the magnitude of the result (not valid for dot\
            product).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-vector-operation",
        "vectors_a": vectors_a,
        "vectors_b": vectors_b,
        "operation": operation,
        "cifti_out": cifti_out,
        "opt_normalize_a": opt_normalize_a,
        "opt_normalize_b": opt_normalize_b,
        "opt_normalize_output": opt_normalize_output,
        "opt_magnitude": opt_magnitude,
    }
    return params


def cifti_vector_operation_cargs(
    params: CiftiVectorOperationParameters,
    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-vector-operation")
    cargs.append(execution.input_file(params.get("vectors_a", None)))
    cargs.append(execution.input_file(params.get("vectors_b", None)))
    cargs.append(params.get("operation", None))
    cargs.append(params.get("cifti_out", None))
    if params.get("opt_normalize_a", False):
        cargs.append("-normalize-a")
    if params.get("opt_normalize_b", False):
        cargs.append("-normalize-b")
    if params.get("opt_normalize_output", False):
        cargs.append("-normalize-output")
    if params.get("opt_magnitude", False):
        cargs.append("-magnitude")
    return cargs


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


def cifti_vector_operation_execute(
    params: CiftiVectorOperationParameters,
    runner: Runner | None = None,
) -> CiftiVectorOperationOutputs:
    """
    cifti-vector-operation
    
    Do a vector operation on cifti files.
    
    Does a vector operation on two cifti files (that must have a multiple of 3
    columns). Either of the inputs may have multiple vectors (more than 3
    columns), but not both (at least one must have exactly 3 columns). The
    -magnitude and -normalize-output options may not be specified together, or
    with an operation that returns a scalar (dot product). The <operation>
    parameter must be one of the following:
    
    DOT
    CROSS
    ADD
    SUBTRACT.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiVectorOperationOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_VECTOR_OPERATION_METADATA)
    params = execution.params(params)
    cargs = cifti_vector_operation_cargs(params, execution)
    ret = cifti_vector_operation_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_vector_operation(
    vectors_a: InputPathType,
    vectors_b: InputPathType,
    operation: str,
    cifti_out: str,
    opt_normalize_a: bool = False,
    opt_normalize_b: bool = False,
    opt_normalize_output: bool = False,
    opt_magnitude: bool = False,
    runner: Runner | None = None,
) -> CiftiVectorOperationOutputs:
    """
    cifti-vector-operation
    
    Do a vector operation on cifti files.
    
    Does a vector operation on two cifti files (that must have a multiple of 3
    columns). Either of the inputs may have multiple vectors (more than 3
    columns), but not both (at least one must have exactly 3 columns). The
    -magnitude and -normalize-output options may not be specified together, or
    with an operation that returns a scalar (dot product). The <operation>
    parameter must be one of the following:
    
    DOT
    CROSS
    ADD
    SUBTRACT.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        vectors_a: first vector input file.
        vectors_b: second vector input file.
        operation: what vector operation to do.
        cifti_out: the output file.
        opt_normalize_a: normalize vectors of first input.
        opt_normalize_b: normalize vectors of second input.
        opt_normalize_output: normalize output vectors (not valid for dot\
            product).
        opt_magnitude: output the magnitude of the result (not valid for dot\
            product).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiVectorOperationOutputs`).
    """
    params = cifti_vector_operation_params(
        vectors_a=vectors_a,
        vectors_b=vectors_b,
        operation=operation,
        cifti_out=cifti_out,
        opt_normalize_a=opt_normalize_a,
        opt_normalize_b=opt_normalize_b,
        opt_normalize_output=opt_normalize_output,
        opt_magnitude=opt_magnitude,
    )
    return cifti_vector_operation_execute(params, runner)


__all__ = [
    "CIFTI_VECTOR_OPERATION_METADATA",
    "CiftiVectorOperationOutputs",
    "cifti_vector_operation",
    "cifti_vector_operation_execute",
    "cifti_vector_operation_params",
]
