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

import typing
import pathlib
from styxdefs import *
import dataclasses

LABELCONVERT_METADATA = Metadata(
    id="70b1b32bfcb741c07b8d256b92dbe12ed0418e5f.boutiques",
    name="labelconvert",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


@dataclasses.dataclass
class LabelconvertConfig:
    """
    temporarily set the value of an MRtrix config file entry.
    """
    key: str
    """temporarily set the value of an MRtrix config file entry."""
    value: str
    """temporarily set the value of an MRtrix config file entry."""
    
    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("-config")
        cargs.append(self.key)
        cargs.append(self.value)
        return cargs


class LabelconvertOutputs(typing.NamedTuple):
    """
    Output object returned when calling `labelconvert(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    image_out: OutputPathType
    """the output image"""


def labelconvert(
    path_in: InputPathType,
    lut_in: InputPathType,
    lut_out: InputPathType,
    image_out: str,
    spine: InputPathType | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[LabelconvertConfig] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> LabelconvertOutputs:
    """
    Convert a connectome node image from one lookup table to another.
    
    Typical usage is to convert a parcellation image provided by some other
    software, based on the lookup table provided by that software, to conform to
    a new lookup table, particularly one where the node indices increment from
    1, in preparation for connectome construction; examples of such target
    lookup table files are provided in share//mrtrix3//labelconvert//, but can
    be created by the user to provide the desired node set // ordering //
    colours.
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        path_in: the input image.
        lut_in: the connectome lookup table corresponding to the input image.
        lut_out: the target connectome lookup table for the output image.
        image_out: the output image.
        spine: provide a manually-defined segmentation of the base of the spine\
            where the streamlines terminate, so that this can become a node in the\
            connection matrix.
        info: display information messages.
        quiet: do not display information messages or progress status;\
            alternatively, this can be achieved by setting the MRTRIX_QUIET\
            environment variable to a non-empty string.
        debug: display debugging messages.
        force: force overwrite of output files (caution: using the same file as\
            input and output might cause unexpected behaviour).
        nthreads: use this number of threads in multi-threaded applications\
            (set to 0 to disable multi-threading).
        config: temporarily set the value of an MRtrix config file entry.
        help_: display this information page and exit.
        version: display version information and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `LabelconvertOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(LABELCONVERT_METADATA)
    cargs = []
    cargs.append("labelconvert")
    if spine is not None:
        cargs.extend([
            "-spine",
            execution.input_file(spine)
        ])
    if info:
        cargs.append("-info")
    if quiet:
        cargs.append("-quiet")
    if debug:
        cargs.append("-debug")
    if force:
        cargs.append("-force")
    if nthreads is not None:
        cargs.extend([
            "-nthreads",
            str(nthreads)
        ])
    if config is not None:
        cargs.extend([a for c in [s.run(execution) for s in config] for a in c])
    if help_:
        cargs.append("-help")
    if version:
        cargs.append("-version")
    cargs.append(execution.input_file(path_in))
    cargs.append(execution.input_file(lut_in))
    cargs.append(execution.input_file(lut_out))
    cargs.append(image_out)
    ret = LabelconvertOutputs(
        root=execution.output_file("."),
        image_out=execution.output_file(image_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "LABELCONVERT_METADATA",
    "LabelconvertConfig",
    "LabelconvertOutputs",
    "labelconvert",
]
