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

import typing
import pathlib
from styxdefs import *
import dataclasses

CIFTI_CHANGE_MAPPING_METADATA = Metadata(
    id="53f8c510829c70200ad060f067b228f1aa52da65.boutiques",
    name="cifti-change-mapping",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


@dataclasses.dataclass
class CiftiChangeMappingSeries:
    """
    set the mapping to series.
    """
    step: float
    """increment between series points"""
    start: float
    """start value of the series"""
    opt_unit_unit: str | None = None
    """select unit for series (default SECOND): unit identifier"""
    
    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("-series")
        cargs.append(str(self.step))
        cargs.append(str(self.start))
        if self.opt_unit_unit is not None:
            cargs.extend([
                "-unit",
                self.opt_unit_unit
            ])
        return cargs


@dataclasses.dataclass
class CiftiChangeMappingScalar:
    """
    set the mapping to scalar.
    """
    opt_name_file_file: str | None = None
    """specify names for the maps: text file containing map names, one per
    line"""
    
    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("-scalar")
        if self.opt_name_file_file is not None:
            cargs.extend([
                "-name-file",
                self.opt_name_file_file
            ])
        return cargs


@dataclasses.dataclass
class CiftiChangeMappingFromCifti:
    """
    copy mapping from another cifti file.
    """
    template_cifti: InputPathType
    """a cifti file containing the desired mapping"""
    direction: str
    """which direction to copy the mapping from"""
    
    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("-from-cifti")
        cargs.append(execution.input_file(self.template_cifti))
        cargs.append(self.direction)
        return cargs


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


def cifti_change_mapping(
    data_cifti: InputPathType,
    direction: str,
    cifti_out: str,
    series: CiftiChangeMappingSeries | None = None,
    scalar: CiftiChangeMappingScalar | None = None,
    from_cifti: CiftiChangeMappingFromCifti | None = None,
    runner: Runner | None = None,
) -> CiftiChangeMappingOutputs:
    """
    Convert to scalar, copy mapping, etc.
    
    Take an existing cifti file and change one of the mappings. Exactly one of
    -series, -scalar, or -from-cifti must be specified. The direction can be
    either an integer starting from 1, or the strings 'ROW' or 'COLUMN'.
    
    The argument to -unit must be one of the following:
    
    SECOND
    HERTZ
    METER
    RADIAN.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        data_cifti: the cifti file to use the data from.
        direction: which direction on <data-cifti> to replace the mapping.
        cifti_out: the output cifti file.
        series: set the mapping to series.
        scalar: set the mapping to scalar.
        from_cifti: copy mapping from another cifti file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiChangeMappingOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_CHANGE_MAPPING_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-cifti-change-mapping")
    cargs.append(execution.input_file(data_cifti))
    cargs.append(direction)
    cargs.append(cifti_out)
    if series is not None:
        cargs.extend(series.run(execution))
    if scalar is not None:
        cargs.extend(scalar.run(execution))
    if from_cifti is not None:
        cargs.extend(from_cifti.run(execution))
    ret = CiftiChangeMappingOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(cifti_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "CIFTI_CHANGE_MAPPING_METADATA",
    "CiftiChangeMappingFromCifti",
    "CiftiChangeMappingOutputs",
    "CiftiChangeMappingScalar",
    "CiftiChangeMappingSeries",
    "cifti_change_mapping",
]
