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

import typing
import pathlib
from styxdefs import *
import dataclasses

CIFTI_CREATE_PARCELLATED_FROM_TEMPLATE_METADATA = Metadata(
    id="97f1dd5239568c20aee38b5af5601267807ff55f.boutiques",
    name="cifti-create-parcellated-from-template",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


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


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


def cifti_create_parcellated_from_template(
    cifti_template: InputPathType,
    modify_direction: str,
    cifti_out: str,
    opt_fill_value_value: float | None = None,
    cifti: list[CiftiCreateParcellatedFromTemplateCifti] | None = None,
    runner: Runner | None = None,
) -> CiftiCreateParcellatedFromTemplateOutputs:
    """
    Match parcels to template by name.
    
    For each parcel name in the template mapping, find that name in an input
    cifti file and use its data in the output file. All input cifti files must
    have a parcels mapping along <modify-direction> and matching mappings along
    other dimensions. 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:
        cifti_template: a cifti file with the template parcel mapping along\
            column.
        modify_direction: which dimension of the output file should match the\
            template (integer, 'ROW', or 'COLUMN').
        cifti_out: the output cifti file.
        opt_fill_value_value: specify value to be used in parcels that don't\
            match: value to use (default 0).
        cifti: specify an input cifti file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiCreateParcellatedFromTemplateOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_CREATE_PARCELLATED_FROM_TEMPLATE_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-cifti-create-parcellated-from-template")
    cargs.append(execution.input_file(cifti_template))
    cargs.append(modify_direction)
    cargs.append(cifti_out)
    if opt_fill_value_value is not None:
        cargs.extend([
            "-fill-value",
            str(opt_fill_value_value)
        ])
    if cifti is not None:
        cargs.extend([a for c in [s.run(execution) for s in cifti] for a in c])
    ret = CiftiCreateParcellatedFromTemplateOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(cifti_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "CIFTI_CREATE_PARCELLATED_FROM_TEMPLATE_METADATA",
    "CiftiCreateParcellatedFromTemplateCifti",
    "CiftiCreateParcellatedFromTemplateOutputs",
    "cifti_create_parcellated_from_template",
]
