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

import typing
import pathlib
from styxdefs import *
import dataclasses

CIFTI_MERGE_PARCELS_METADATA = Metadata(
    id="248d8b5bb78af2ce84baa7231e1eaa83a19fda9b.boutiques",
    name="cifti-merge-parcels",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


@dataclasses.dataclass
class CiftiMergeParcelsCifti:
    """
    specify an input cifti file.
    """
    cifti_in: InputPathType
    """a cifti file to merge"""
    
    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("-cifti")
        cargs.append(execution.input_file(self.cifti_in))
        return cargs


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


def cifti_merge_parcels(
    direction: str,
    cifti_out: str,
    cifti: list[CiftiMergeParcelsCifti] | None = None,
    runner: Runner | None = None,
) -> CiftiMergeParcelsOutputs:
    """
    Merge cifti files along parcels dimension.
    
    The input cifti files must have matching mappings along the direction not
    specified, and the mapping along the specified direction must be parcels.
    The direction can be either an integer starting from 1, or the strings 'ROW'
    or 'COLUMN'.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        direction: which dimension to merge along (integer, 'ROW', or 'COLUMN').
        cifti_out: the output cifti file.
        cifti: specify an input cifti file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiMergeParcelsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_MERGE_PARCELS_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-cifti-merge-parcels")
    cargs.append(direction)
    cargs.append(cifti_out)
    if cifti is not None:
        cargs.extend([a for c in [s.run(execution) for s in cifti] for a in c])
    ret = CiftiMergeParcelsOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(cifti_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "CIFTI_MERGE_PARCELS_METADATA",
    "CiftiMergeParcelsCifti",
    "CiftiMergeParcelsOutputs",
    "cifti_merge_parcels",
]
