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

import typing
import pathlib
from styxdefs import *

CIFTI_CREATE_LABEL_METADATA = Metadata(
    id="3a1aca58ce90234c63b19e3c0451b3cb7f90d16b.boutiques",
    name="cifti-create-label",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


CiftiCreateLabelVolumeParameters = typing.TypedDict('CiftiCreateLabelVolumeParameters', {
    "@type": typing.NotRequired[typing.Literal["volume"]],
    "label_volume": InputPathType,
    "structure_label_volume": InputPathType,
})
CiftiCreateLabelVolumeParametersTagged = typing.TypedDict('CiftiCreateLabelVolumeParametersTagged', {
    "@type": typing.Literal["volume"],
    "label_volume": InputPathType,
    "structure_label_volume": InputPathType,
})


CiftiCreateLabelLeftLabelParameters = typing.TypedDict('CiftiCreateLabelLeftLabelParameters', {
    "@type": typing.NotRequired[typing.Literal["left_label"]],
    "label": InputPathType,
    "opt_roi_left_roi_metric": typing.NotRequired[InputPathType | None],
})
CiftiCreateLabelLeftLabelParametersTagged = typing.TypedDict('CiftiCreateLabelLeftLabelParametersTagged', {
    "@type": typing.Literal["left_label"],
    "label": InputPathType,
    "opt_roi_left_roi_metric": typing.NotRequired[InputPathType | None],
})


CiftiCreateLabelRightLabelParameters = typing.TypedDict('CiftiCreateLabelRightLabelParameters', {
    "@type": typing.NotRequired[typing.Literal["right_label"]],
    "label": InputPathType,
    "opt_roi_right_roi_metric": typing.NotRequired[InputPathType | None],
})
CiftiCreateLabelRightLabelParametersTagged = typing.TypedDict('CiftiCreateLabelRightLabelParametersTagged', {
    "@type": typing.Literal["right_label"],
    "label": InputPathType,
    "opt_roi_right_roi_metric": typing.NotRequired[InputPathType | None],
})


CiftiCreateLabelCerebellumLabelParameters = typing.TypedDict('CiftiCreateLabelCerebellumLabelParameters', {
    "@type": typing.NotRequired[typing.Literal["cerebellum_label"]],
    "label": InputPathType,
    "opt_roi_cerebellum_roi_metric": typing.NotRequired[InputPathType | None],
})
CiftiCreateLabelCerebellumLabelParametersTagged = typing.TypedDict('CiftiCreateLabelCerebellumLabelParametersTagged', {
    "@type": typing.Literal["cerebellum_label"],
    "label": InputPathType,
    "opt_roi_cerebellum_roi_metric": typing.NotRequired[InputPathType | None],
})


CiftiCreateLabelParameters = typing.TypedDict('CiftiCreateLabelParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-create-label"]],
    "cifti_out": str,
    "volume": typing.NotRequired[CiftiCreateLabelVolumeParameters | None],
    "left_label": typing.NotRequired[CiftiCreateLabelLeftLabelParameters | None],
    "right_label": typing.NotRequired[CiftiCreateLabelRightLabelParameters | None],
    "cerebellum_label": typing.NotRequired[CiftiCreateLabelCerebellumLabelParameters | None],
})
CiftiCreateLabelParametersTagged = typing.TypedDict('CiftiCreateLabelParametersTagged', {
    "@type": typing.Literal["workbench/cifti-create-label"],
    "cifti_out": str,
    "volume": typing.NotRequired[CiftiCreateLabelVolumeParameters | None],
    "left_label": typing.NotRequired[CiftiCreateLabelLeftLabelParameters | None],
    "right_label": typing.NotRequired[CiftiCreateLabelRightLabelParameters | None],
    "cerebellum_label": typing.NotRequired[CiftiCreateLabelCerebellumLabelParameters | None],
})


def cifti_create_label_volume_params(
    label_volume: InputPathType,
    structure_label_volume: InputPathType,
) -> CiftiCreateLabelVolumeParametersTagged:
    """
    Build parameters.
    
    Args:
        label_volume: label volume file containing the data to be copied.
        structure_label_volume: label volume file that defines which voxels to\
            use.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "volume",
        "label_volume": label_volume,
        "structure_label_volume": structure_label_volume,
    }
    return params


def cifti_create_label_volume_cargs(
    params: CiftiCreateLabelVolumeParameters,
    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("-volume")
    cargs.append(execution.input_file(params.get("label_volume", None)))
    cargs.append(execution.input_file(params.get("structure_label_volume", None)))
    return cargs


def cifti_create_label_left_label_params(
    label: InputPathType,
    opt_roi_left_roi_metric: InputPathType | None = None,
) -> CiftiCreateLabelLeftLabelParametersTagged:
    """
    Build parameters.
    
    Args:
        label: the label file.
        opt_roi_left_roi_metric: roi of vertices to use from left surface: the\
            ROI as a metric file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "left_label",
        "label": label,
    }
    if opt_roi_left_roi_metric is not None:
        params["opt_roi_left_roi_metric"] = opt_roi_left_roi_metric
    return params


def cifti_create_label_left_label_cargs(
    params: CiftiCreateLabelLeftLabelParameters,
    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("-left-label")
    cargs.append(execution.input_file(params.get("label", None)))
    if params.get("opt_roi_left_roi_metric", None) is not None:
        cargs.extend([
            "-roi-left",
            execution.input_file(params.get("opt_roi_left_roi_metric", None))
        ])
    return cargs


def cifti_create_label_right_label_params(
    label: InputPathType,
    opt_roi_right_roi_metric: InputPathType | None = None,
) -> CiftiCreateLabelRightLabelParametersTagged:
    """
    Build parameters.
    
    Args:
        label: the label file.
        opt_roi_right_roi_metric: roi of vertices to use from right surface:\
            the ROI as a metric file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "right_label",
        "label": label,
    }
    if opt_roi_right_roi_metric is not None:
        params["opt_roi_right_roi_metric"] = opt_roi_right_roi_metric
    return params


def cifti_create_label_right_label_cargs(
    params: CiftiCreateLabelRightLabelParameters,
    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("-right-label")
    cargs.append(execution.input_file(params.get("label", None)))
    if params.get("opt_roi_right_roi_metric", None) is not None:
        cargs.extend([
            "-roi-right",
            execution.input_file(params.get("opt_roi_right_roi_metric", None))
        ])
    return cargs


def cifti_create_label_cerebellum_label_params(
    label: InputPathType,
    opt_roi_cerebellum_roi_metric: InputPathType | None = None,
) -> CiftiCreateLabelCerebellumLabelParametersTagged:
    """
    Build parameters.
    
    Args:
        label: the label file.
        opt_roi_cerebellum_roi_metric: roi of vertices to use from right\
            surface: the ROI as a metric file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "cerebellum_label",
        "label": label,
    }
    if opt_roi_cerebellum_roi_metric is not None:
        params["opt_roi_cerebellum_roi_metric"] = opt_roi_cerebellum_roi_metric
    return params


def cifti_create_label_cerebellum_label_cargs(
    params: CiftiCreateLabelCerebellumLabelParameters,
    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("-cerebellum-label")
    cargs.append(execution.input_file(params.get("label", None)))
    if params.get("opt_roi_cerebellum_roi_metric", None) is not None:
        cargs.extend([
            "-roi-cerebellum",
            execution.input_file(params.get("opt_roi_cerebellum_roi_metric", None))
        ])
    return cargs


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


def cifti_create_label_params(
    cifti_out: str,
    volume: CiftiCreateLabelVolumeParameters | None = None,
    left_label: CiftiCreateLabelLeftLabelParameters | None = None,
    right_label: CiftiCreateLabelRightLabelParameters | None = None,
    cerebellum_label: CiftiCreateLabelCerebellumLabelParameters | None = None,
) -> CiftiCreateLabelParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_out: the output cifti file.
        volume: volume component.
        left_label: label file for left surface.
        right_label: label for left surface.
        cerebellum_label: label for the cerebellum.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-create-label",
        "cifti_out": cifti_out,
    }
    if volume is not None:
        params["volume"] = volume
    if left_label is not None:
        params["left_label"] = left_label
    if right_label is not None:
        params["right_label"] = right_label
    if cerebellum_label is not None:
        params["cerebellum_label"] = cerebellum_label
    return params


def cifti_create_label_cargs(
    params: CiftiCreateLabelParameters,
    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-create-label")
    cargs.append(params.get("cifti_out", None))
    if params.get("volume", None) is not None:
        cargs.extend(cifti_create_label_volume_cargs(params.get("volume", None), execution))
    if params.get("left_label", None) is not None:
        cargs.extend(cifti_create_label_left_label_cargs(params.get("left_label", None), execution))
    if params.get("right_label", None) is not None:
        cargs.extend(cifti_create_label_right_label_cargs(params.get("right_label", None), execution))
    if params.get("cerebellum_label", None) is not None:
        cargs.extend(cifti_create_label_cerebellum_label_cargs(params.get("cerebellum_label", None), execution))
    return cargs


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


def cifti_create_label_execute(
    params: CiftiCreateLabelParameters,
    runner: Runner | None = None,
) -> CiftiCreateLabelOutputs:
    """
    cifti-create-label
    
    Create a cifti label file.
    
    All input files must have the same number of columns/subvolumes. Only the
    specified components will be in the output cifti. At least one component
    must be specified.
    
    The -volume option requires two volume arguments, the label-volume argument
    contains all labels you want to display (e.g. nuclei of the thalamus),
    whereas the structure-label-volume argument contains all CIFTI voxel-based
    structures you want to include data within (e.g. THALAMUS_LEFT,
    THALAMUS_RIGHT, etc). See -volume-label-import and -volume-help for format
    details of label volume files. If you just want the labels in voxels to be
    the structure names, you may use the same file for both arguments. The
    structure-label-volume must use some of the label names from this list, all
    other label names in the structure-label-volume will be ignored:
    
    CORTEX_LEFT
    CORTEX_RIGHT
    CEREBELLUM
    ACCUMBENS_LEFT
    ACCUMBENS_RIGHT
    ALL_GREY_MATTER
    ALL_WHITE_MATTER
    AMYGDALA_LEFT
    AMYGDALA_RIGHT
    BRAIN_STEM
    CAUDATE_LEFT
    CAUDATE_RIGHT
    CEREBELLAR_WHITE_MATTER_LEFT
    CEREBELLAR_WHITE_MATTER_RIGHT
    CEREBELLUM_LEFT
    CEREBELLUM_RIGHT
    CEREBRAL_WHITE_MATTER_LEFT
    CEREBRAL_WHITE_MATTER_RIGHT
    CORTEX
    DIENCEPHALON_VENTRAL_LEFT
    DIENCEPHALON_VENTRAL_RIGHT
    HIPPOCAMPUS_LEFT
    HIPPOCAMPUS_RIGHT
    INVALID
    OTHER
    OTHER_GREY_MATTER
    OTHER_WHITE_MATTER
    PALLIDUM_LEFT
    PALLIDUM_RIGHT
    PUTAMEN_LEFT
    PUTAMEN_RIGHT
    THALAMUS_LEFT
    THALAMUS_RIGHT.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiCreateLabelOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_CREATE_LABEL_METADATA)
    params = execution.params(params)
    cargs = cifti_create_label_cargs(params, execution)
    ret = cifti_create_label_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_create_label(
    cifti_out: str,
    volume: CiftiCreateLabelVolumeParameters | None = None,
    left_label: CiftiCreateLabelLeftLabelParameters | None = None,
    right_label: CiftiCreateLabelRightLabelParameters | None = None,
    cerebellum_label: CiftiCreateLabelCerebellumLabelParameters | None = None,
    runner: Runner | None = None,
) -> CiftiCreateLabelOutputs:
    """
    cifti-create-label
    
    Create a cifti label file.
    
    All input files must have the same number of columns/subvolumes. Only the
    specified components will be in the output cifti. At least one component
    must be specified.
    
    The -volume option requires two volume arguments, the label-volume argument
    contains all labels you want to display (e.g. nuclei of the thalamus),
    whereas the structure-label-volume argument contains all CIFTI voxel-based
    structures you want to include data within (e.g. THALAMUS_LEFT,
    THALAMUS_RIGHT, etc). See -volume-label-import and -volume-help for format
    details of label volume files. If you just want the labels in voxels to be
    the structure names, you may use the same file for both arguments. The
    structure-label-volume must use some of the label names from this list, all
    other label names in the structure-label-volume will be ignored:
    
    CORTEX_LEFT
    CORTEX_RIGHT
    CEREBELLUM
    ACCUMBENS_LEFT
    ACCUMBENS_RIGHT
    ALL_GREY_MATTER
    ALL_WHITE_MATTER
    AMYGDALA_LEFT
    AMYGDALA_RIGHT
    BRAIN_STEM
    CAUDATE_LEFT
    CAUDATE_RIGHT
    CEREBELLAR_WHITE_MATTER_LEFT
    CEREBELLAR_WHITE_MATTER_RIGHT
    CEREBELLUM_LEFT
    CEREBELLUM_RIGHT
    CEREBRAL_WHITE_MATTER_LEFT
    CEREBRAL_WHITE_MATTER_RIGHT
    CORTEX
    DIENCEPHALON_VENTRAL_LEFT
    DIENCEPHALON_VENTRAL_RIGHT
    HIPPOCAMPUS_LEFT
    HIPPOCAMPUS_RIGHT
    INVALID
    OTHER
    OTHER_GREY_MATTER
    OTHER_WHITE_MATTER
    PALLIDUM_LEFT
    PALLIDUM_RIGHT
    PUTAMEN_LEFT
    PUTAMEN_RIGHT
    THALAMUS_LEFT
    THALAMUS_RIGHT.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        cifti_out: the output cifti file.
        volume: volume component.
        left_label: label file for left surface.
        right_label: label for left surface.
        cerebellum_label: label for the cerebellum.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiCreateLabelOutputs`).
    """
    params = cifti_create_label_params(
        cifti_out=cifti_out,
        volume=volume,
        left_label=left_label,
        right_label=right_label,
        cerebellum_label=cerebellum_label,
    )
    return cifti_create_label_execute(params, runner)


__all__ = [
    "CIFTI_CREATE_LABEL_METADATA",
    "CiftiCreateLabelOutputs",
    "cifti_create_label",
    "cifti_create_label_cerebellum_label_params",
    "cifti_create_label_execute",
    "cifti_create_label_left_label_params",
    "cifti_create_label_params",
    "cifti_create_label_right_label_params",
    "cifti_create_label_volume_params",
]
