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

import typing
import pathlib
from styxdefs import *

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


CiftiChangeMappingSeriesParameters = typing.TypedDict('CiftiChangeMappingSeriesParameters', {
    "@type": typing.NotRequired[typing.Literal["series"]],
    "step": float,
    "start": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})
CiftiChangeMappingSeriesParametersTagged = typing.TypedDict('CiftiChangeMappingSeriesParametersTagged', {
    "@type": typing.Literal["series"],
    "step": float,
    "start": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})


CiftiChangeMappingScalarParameters = typing.TypedDict('CiftiChangeMappingScalarParameters', {
    "@type": typing.NotRequired[typing.Literal["scalar"]],
    "opt_name_file_file": typing.NotRequired[str | None],
})
CiftiChangeMappingScalarParametersTagged = typing.TypedDict('CiftiChangeMappingScalarParametersTagged', {
    "@type": typing.Literal["scalar"],
    "opt_name_file_file": typing.NotRequired[str | None],
})


CiftiChangeMappingFromCiftiParameters = typing.TypedDict('CiftiChangeMappingFromCiftiParameters', {
    "@type": typing.NotRequired[typing.Literal["from_cifti"]],
    "template_cifti": InputPathType,
    "direction": str,
})
CiftiChangeMappingFromCiftiParametersTagged = typing.TypedDict('CiftiChangeMappingFromCiftiParametersTagged', {
    "@type": typing.Literal["from_cifti"],
    "template_cifti": InputPathType,
    "direction": str,
})


CiftiChangeMappingParameters = typing.TypedDict('CiftiChangeMappingParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-change-mapping"]],
    "data_cifti": InputPathType,
    "direction": str,
    "cifti_out": str,
    "series": typing.NotRequired[CiftiChangeMappingSeriesParameters | None],
    "scalar": typing.NotRequired[CiftiChangeMappingScalarParameters | None],
    "from_cifti": typing.NotRequired[CiftiChangeMappingFromCiftiParameters | None],
})
CiftiChangeMappingParametersTagged = typing.TypedDict('CiftiChangeMappingParametersTagged', {
    "@type": typing.Literal["workbench/cifti-change-mapping"],
    "data_cifti": InputPathType,
    "direction": str,
    "cifti_out": str,
    "series": typing.NotRequired[CiftiChangeMappingSeriesParameters | None],
    "scalar": typing.NotRequired[CiftiChangeMappingScalarParameters | None],
    "from_cifti": typing.NotRequired[CiftiChangeMappingFromCiftiParameters | None],
})


def cifti_change_mapping_series_params(
    step: float,
    start: float,
    opt_unit_unit: str | None = None,
) -> CiftiChangeMappingSeriesParametersTagged:
    """
    Build parameters.
    
    Args:
        step: increment between series points.
        start: start value of the series.
        opt_unit_unit: select unit for series (default SECOND): unit identifier.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "series",
        "step": step,
        "start": start,
    }
    if opt_unit_unit is not None:
        params["opt_unit_unit"] = opt_unit_unit
    return params


def cifti_change_mapping_series_cargs(
    params: CiftiChangeMappingSeriesParameters,
    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("-series")
    cargs.append(str(params.get("step", None)))
    cargs.append(str(params.get("start", None)))
    if params.get("opt_unit_unit", None) is not None:
        cargs.extend([
            "-unit",
            params.get("opt_unit_unit", None)
        ])
    return cargs


def cifti_change_mapping_scalar_params(
    opt_name_file_file: str | None = None,
) -> CiftiChangeMappingScalarParametersTagged:
    """
    Build parameters.
    
    Args:
        opt_name_file_file: specify names for the maps: text file containing\
            map names, one per line.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "scalar",
    }
    if opt_name_file_file is not None:
        params["opt_name_file_file"] = opt_name_file_file
    return params


def cifti_change_mapping_scalar_cargs(
    params: CiftiChangeMappingScalarParameters,
    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("-scalar")
    if params.get("opt_name_file_file", None) is not None:
        cargs.extend([
            "-name-file",
            params.get("opt_name_file_file", None)
        ])
    return cargs


def cifti_change_mapping_from_cifti_params(
    template_cifti: InputPathType,
    direction: str,
) -> CiftiChangeMappingFromCiftiParametersTagged:
    """
    Build parameters.
    
    Args:
        template_cifti: a cifti file containing the desired mapping.
        direction: which direction to copy the mapping from.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "from_cifti",
        "template_cifti": template_cifti,
        "direction": direction,
    }
    return params


def cifti_change_mapping_from_cifti_cargs(
    params: CiftiChangeMappingFromCiftiParameters,
    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("-from-cifti")
    cargs.append(execution.input_file(params.get("template_cifti", None)))
    cargs.append(params.get("direction", None))
    return cargs


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


def cifti_change_mapping_params(
    data_cifti: InputPathType,
    direction: str,
    cifti_out: str,
    series: CiftiChangeMappingSeriesParameters | None = None,
    scalar: CiftiChangeMappingScalarParameters | None = None,
    from_cifti: CiftiChangeMappingFromCiftiParameters | None = None,
) -> CiftiChangeMappingParametersTagged:
    """
    Build parameters.
    
    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.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-change-mapping",
        "data_cifti": data_cifti,
        "direction": direction,
        "cifti_out": cifti_out,
    }
    if series is not None:
        params["series"] = series
    if scalar is not None:
        params["scalar"] = scalar
    if from_cifti is not None:
        params["from_cifti"] = from_cifti
    return params


def cifti_change_mapping_cargs(
    params: CiftiChangeMappingParameters,
    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-change-mapping")
    cargs.append(execution.input_file(params.get("data_cifti", None)))
    cargs.append(params.get("direction", None))
    cargs.append(params.get("cifti_out", None))
    if params.get("series", None) is not None:
        cargs.extend(cifti_change_mapping_series_cargs(params.get("series", None), execution))
    if params.get("scalar", None) is not None:
        cargs.extend(cifti_change_mapping_scalar_cargs(params.get("scalar", None), execution))
    if params.get("from_cifti", None) is not None:
        cargs.extend(cifti_change_mapping_from_cifti_cargs(params.get("from_cifti", None), execution))
    return cargs


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


def cifti_change_mapping_execute(
    params: CiftiChangeMappingParameters,
    runner: Runner | None = None,
) -> CiftiChangeMappingOutputs:
    """
    cifti-change-mapping
    
    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:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiChangeMappingOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_CHANGE_MAPPING_METADATA)
    params = execution.params(params)
    cargs = cifti_change_mapping_cargs(params, execution)
    ret = cifti_change_mapping_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_change_mapping(
    data_cifti: InputPathType,
    direction: str,
    cifti_out: str,
    series: CiftiChangeMappingSeriesParameters | None = None,
    scalar: CiftiChangeMappingScalarParameters | None = None,
    from_cifti: CiftiChangeMappingFromCiftiParameters | None = None,
    runner: Runner | None = None,
) -> CiftiChangeMappingOutputs:
    """
    cifti-change-mapping
    
    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`).
    """
    params = cifti_change_mapping_params(
        data_cifti=data_cifti,
        direction=direction,
        cifti_out=cifti_out,
        series=series,
        scalar=scalar,
        from_cifti=from_cifti,
    )
    return cifti_change_mapping_execute(params, runner)


__all__ = [
    "CIFTI_CHANGE_MAPPING_METADATA",
    "CiftiChangeMappingOutputs",
    "cifti_change_mapping",
    "cifti_change_mapping_execute",
    "cifti_change_mapping_from_cifti_params",
    "cifti_change_mapping_params",
    "cifti_change_mapping_scalar_params",
    "cifti_change_mapping_series_params",
]
