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

import typing
import pathlib
from styxdefs import *

CIFTI_CONVERT_METADATA = Metadata(
    id="70a8b5ced62c481e40ec12dcf2abf0cb66adfb18.boutiques",
    name="cifti-convert",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


CiftiConvertToGiftiExtParameters = typing.TypedDict('CiftiConvertToGiftiExtParameters', {
    "@type": typing.NotRequired[typing.Literal["to_gifti_ext"]],
    "cifti_in": InputPathType,
    "gifti_out": str,
})
CiftiConvertToGiftiExtParametersTagged = typing.TypedDict('CiftiConvertToGiftiExtParametersTagged', {
    "@type": typing.Literal["to_gifti_ext"],
    "cifti_in": InputPathType,
    "gifti_out": str,
})


CiftiConvertResetTimepointsParameters = typing.TypedDict('CiftiConvertResetTimepointsParameters', {
    "@type": typing.NotRequired[typing.Literal["reset_timepoints"]],
    "timestep": float,
    "timestart": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})
CiftiConvertResetTimepointsParametersTagged = typing.TypedDict('CiftiConvertResetTimepointsParametersTagged', {
    "@type": typing.Literal["reset_timepoints"],
    "timestep": float,
    "timestart": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})


CiftiConvertReplaceBinaryParameters = typing.TypedDict('CiftiConvertReplaceBinaryParameters', {
    "@type": typing.NotRequired[typing.Literal["replace_binary"]],
    "binary_in": str,
    "opt_flip_endian": bool,
    "opt_transpose": bool,
})
CiftiConvertReplaceBinaryParametersTagged = typing.TypedDict('CiftiConvertReplaceBinaryParametersTagged', {
    "@type": typing.Literal["replace_binary"],
    "binary_in": str,
    "opt_flip_endian": bool,
    "opt_transpose": bool,
})


CiftiConvertFromGiftiExtParameters = typing.TypedDict('CiftiConvertFromGiftiExtParameters', {
    "@type": typing.NotRequired[typing.Literal["from_gifti_ext"]],
    "gifti_in": str,
    "cifti_out": str,
    "reset_timepoints": typing.NotRequired[CiftiConvertResetTimepointsParameters | None],
    "opt_reset_scalars": bool,
    "opt_column_reset_scalars": bool,
    "replace_binary": typing.NotRequired[CiftiConvertReplaceBinaryParameters | None],
})
CiftiConvertFromGiftiExtParametersTagged = typing.TypedDict('CiftiConvertFromGiftiExtParametersTagged', {
    "@type": typing.Literal["from_gifti_ext"],
    "gifti_in": str,
    "cifti_out": str,
    "reset_timepoints": typing.NotRequired[CiftiConvertResetTimepointsParameters | None],
    "opt_reset_scalars": bool,
    "opt_column_reset_scalars": bool,
    "replace_binary": typing.NotRequired[CiftiConvertReplaceBinaryParameters | None],
})


CiftiConvertToNiftiParameters = typing.TypedDict('CiftiConvertToNiftiParameters', {
    "@type": typing.NotRequired[typing.Literal["to_nifti"]],
    "cifti_in": InputPathType,
    "nifti_out": str,
    "opt_smaller_file": bool,
    "opt_smaller_dims": bool,
})
CiftiConvertToNiftiParametersTagged = typing.TypedDict('CiftiConvertToNiftiParametersTagged', {
    "@type": typing.Literal["to_nifti"],
    "cifti_in": InputPathType,
    "nifti_out": str,
    "opt_smaller_file": bool,
    "opt_smaller_dims": bool,
})


CiftiConvertResetTimepoints1Parameters = typing.TypedDict('CiftiConvertResetTimepoints1Parameters', {
    "@type": typing.NotRequired[typing.Literal["reset_timepoints_1"]],
    "timestep": float,
    "timestart": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})
CiftiConvertResetTimepoints1ParametersTagged = typing.TypedDict('CiftiConvertResetTimepoints1ParametersTagged', {
    "@type": typing.Literal["reset_timepoints_1"],
    "timestep": float,
    "timestart": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})


CiftiConvertFromNiftiParameters = typing.TypedDict('CiftiConvertFromNiftiParameters', {
    "@type": typing.NotRequired[typing.Literal["from_nifti"]],
    "nifti_in": InputPathType,
    "cifti_template": InputPathType,
    "cifti_out": str,
    "reset_timepoints": typing.NotRequired[CiftiConvertResetTimepoints1Parameters | None],
    "opt_reset_scalars": bool,
})
CiftiConvertFromNiftiParametersTagged = typing.TypedDict('CiftiConvertFromNiftiParametersTagged', {
    "@type": typing.Literal["from_nifti"],
    "nifti_in": InputPathType,
    "cifti_template": InputPathType,
    "cifti_out": str,
    "reset_timepoints": typing.NotRequired[CiftiConvertResetTimepoints1Parameters | None],
    "opt_reset_scalars": bool,
})


CiftiConvertToTextParameters = typing.TypedDict('CiftiConvertToTextParameters', {
    "@type": typing.NotRequired[typing.Literal["to_text"]],
    "cifti_in": InputPathType,
    "text_out": str,
    "opt_col_delim_delim_string": typing.NotRequired[str | None],
})
CiftiConvertToTextParametersTagged = typing.TypedDict('CiftiConvertToTextParametersTagged', {
    "@type": typing.Literal["to_text"],
    "cifti_in": InputPathType,
    "text_out": str,
    "opt_col_delim_delim_string": typing.NotRequired[str | None],
})


CiftiConvertResetTimepoints2Parameters = typing.TypedDict('CiftiConvertResetTimepoints2Parameters', {
    "@type": typing.NotRequired[typing.Literal["reset_timepoints_2"]],
    "timestep": float,
    "timestart": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})
CiftiConvertResetTimepoints2ParametersTagged = typing.TypedDict('CiftiConvertResetTimepoints2ParametersTagged', {
    "@type": typing.Literal["reset_timepoints_2"],
    "timestep": float,
    "timestart": float,
    "opt_unit_unit": typing.NotRequired[str | None],
})


CiftiConvertFromTextParameters = typing.TypedDict('CiftiConvertFromTextParameters', {
    "@type": typing.NotRequired[typing.Literal["from_text"]],
    "text_in": str,
    "cifti_template": InputPathType,
    "cifti_out": str,
    "opt_col_delim_delim_string": typing.NotRequired[str | None],
    "reset_timepoints": typing.NotRequired[CiftiConvertResetTimepoints2Parameters | None],
    "opt_reset_scalars": bool,
})
CiftiConvertFromTextParametersTagged = typing.TypedDict('CiftiConvertFromTextParametersTagged', {
    "@type": typing.Literal["from_text"],
    "text_in": str,
    "cifti_template": InputPathType,
    "cifti_out": str,
    "opt_col_delim_delim_string": typing.NotRequired[str | None],
    "reset_timepoints": typing.NotRequired[CiftiConvertResetTimepoints2Parameters | None],
    "opt_reset_scalars": bool,
})


CiftiConvertParameters = typing.TypedDict('CiftiConvertParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-convert"]],
    "to_gifti_ext": typing.NotRequired[CiftiConvertToGiftiExtParameters | None],
    "from_gifti_ext": typing.NotRequired[CiftiConvertFromGiftiExtParameters | None],
    "to_nifti": typing.NotRequired[CiftiConvertToNiftiParameters | None],
    "from_nifti": typing.NotRequired[CiftiConvertFromNiftiParameters | None],
    "to_text": typing.NotRequired[CiftiConvertToTextParameters | None],
    "from_text": typing.NotRequired[CiftiConvertFromTextParameters | None],
})
CiftiConvertParametersTagged = typing.TypedDict('CiftiConvertParametersTagged', {
    "@type": typing.Literal["workbench/cifti-convert"],
    "to_gifti_ext": typing.NotRequired[CiftiConvertToGiftiExtParameters | None],
    "from_gifti_ext": typing.NotRequired[CiftiConvertFromGiftiExtParameters | None],
    "to_nifti": typing.NotRequired[CiftiConvertToNiftiParameters | None],
    "from_nifti": typing.NotRequired[CiftiConvertFromNiftiParameters | None],
    "to_text": typing.NotRequired[CiftiConvertToTextParameters | None],
    "from_text": typing.NotRequired[CiftiConvertFromTextParameters | None],
})


def cifti_convert_to_gifti_ext_params(
    cifti_in: InputPathType,
    gifti_out: str,
) -> CiftiConvertToGiftiExtParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_in: the input cifti file.
        gifti_out: output - the output gifti file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "to_gifti_ext",
        "cifti_in": cifti_in,
        "gifti_out": gifti_out,
    }
    return params


def cifti_convert_to_gifti_ext_cargs(
    params: CiftiConvertToGiftiExtParameters,
    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("-to-gifti-ext")
    cargs.append(execution.input_file(params.get("cifti_in", None)))
    cargs.append(params.get("gifti_out", None))
    return cargs


def cifti_convert_reset_timepoints_params(
    timestep: float,
    timestart: float,
    opt_unit_unit: str | None = None,
) -> CiftiConvertResetTimepointsParametersTagged:
    """
    Build parameters.
    
    Args:
        timestep: the desired time between frames.
        timestart: the desired time offset of the initial frame.
        opt_unit_unit: use a unit other than time: unit identifier (default\
            SECOND).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "reset_timepoints",
        "timestep": timestep,
        "timestart": timestart,
    }
    if opt_unit_unit is not None:
        params["opt_unit_unit"] = opt_unit_unit
    return params


def cifti_convert_reset_timepoints_cargs(
    params: CiftiConvertResetTimepointsParameters,
    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("-reset-timepoints")
    cargs.append(str(params.get("timestep", None)))
    cargs.append(str(params.get("timestart", None)))
    if params.get("opt_unit_unit", None) is not None:
        cargs.extend([
            "-unit",
            params.get("opt_unit_unit", None)
        ])
    return cargs


def cifti_convert_replace_binary_params(
    binary_in: str,
    opt_flip_endian: bool = False,
    opt_transpose: bool = False,
) -> CiftiConvertReplaceBinaryParametersTagged:
    """
    Build parameters.
    
    Args:
        binary_in: the binary file that contains replacement data.
        opt_flip_endian: byteswap the binary file.
        opt_transpose: transpose the binary file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "replace_binary",
        "binary_in": binary_in,
        "opt_flip_endian": opt_flip_endian,
        "opt_transpose": opt_transpose,
    }
    return params


def cifti_convert_replace_binary_cargs(
    params: CiftiConvertReplaceBinaryParameters,
    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("-replace-binary")
    cargs.append(params.get("binary_in", None))
    if params.get("opt_flip_endian", False):
        cargs.append("-flip-endian")
    if params.get("opt_transpose", False):
        cargs.append("-transpose")
    return cargs


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


def cifti_convert_from_gifti_ext_params(
    gifti_in: str,
    cifti_out: str,
    reset_timepoints: CiftiConvertResetTimepointsParameters | None = None,
    opt_reset_scalars: bool = False,
    opt_column_reset_scalars: bool = False,
    replace_binary: CiftiConvertReplaceBinaryParameters | None = None,
) -> CiftiConvertFromGiftiExtParametersTagged:
    """
    Build parameters.
    
    Args:
        gifti_in: the input gifti file.
        cifti_out: the output cifti file.
        reset_timepoints: reset the mapping along rows to timepoints, taking\
            length from the gifti file.
        opt_reset_scalars: reset mapping along rows to scalars, taking length\
            from the gifti file.
        opt_column_reset_scalars: reset mapping along columns to scalar (useful\
            for changing number of series in a sdseries file).
        replace_binary: replace data with a binary file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "from_gifti_ext",
        "gifti_in": gifti_in,
        "cifti_out": cifti_out,
        "opt_reset_scalars": opt_reset_scalars,
        "opt_column_reset_scalars": opt_column_reset_scalars,
    }
    if reset_timepoints is not None:
        params["reset_timepoints"] = reset_timepoints
    if replace_binary is not None:
        params["replace_binary"] = replace_binary
    return params


def cifti_convert_from_gifti_ext_cargs(
    params: CiftiConvertFromGiftiExtParameters,
    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-gifti-ext")
    cargs.append(params.get("gifti_in", None))
    cargs.append(params.get("cifti_out", None))
    if params.get("reset_timepoints", None) is not None:
        cargs.extend(cifti_convert_reset_timepoints_cargs(params.get("reset_timepoints", None), execution))
    if params.get("opt_reset_scalars", False):
        cargs.append("-reset-scalars")
    if params.get("opt_column_reset_scalars", False):
        cargs.append("-column-reset-scalars")
    if params.get("replace_binary", None) is not None:
        cargs.extend(cifti_convert_replace_binary_cargs(params.get("replace_binary", None), execution))
    return cargs


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


class CiftiConvertToNiftiOutputs(typing.NamedTuple):
    """
    Output object returned when calling `CiftiConvertToNiftiParameters | None(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    nifti_out: OutputPathType
    """the output nifti file"""


def cifti_convert_to_nifti_params(
    cifti_in: InputPathType,
    nifti_out: str,
    opt_smaller_file: bool = False,
    opt_smaller_dims: bool = False,
) -> CiftiConvertToNiftiParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_in: the input cifti file.
        nifti_out: the output nifti file.
        opt_smaller_file: use better-fitting dimension lengths.
        opt_smaller_dims: minimize the largest dimension, for tools that don't\
            like large indices.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "to_nifti",
        "cifti_in": cifti_in,
        "nifti_out": nifti_out,
        "opt_smaller_file": opt_smaller_file,
        "opt_smaller_dims": opt_smaller_dims,
    }
    return params


def cifti_convert_to_nifti_cargs(
    params: CiftiConvertToNiftiParameters,
    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("-to-nifti")
    cargs.append(execution.input_file(params.get("cifti_in", None)))
    cargs.append(params.get("nifti_out", None))
    if params.get("opt_smaller_file", False):
        cargs.append("-smaller-file")
    if params.get("opt_smaller_dims", False):
        cargs.append("-smaller-dims")
    return cargs


def cifti_convert_to_nifti_outputs(
    params: CiftiConvertToNiftiParameters,
    execution: Execution,
) -> CiftiConvertToNiftiOutputs:
    """
    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 = CiftiConvertToNiftiOutputs(
        root=execution.output_file("."),
        nifti_out=execution.output_file(params.get("nifti_out", None)),
    )
    return ret


def cifti_convert_reset_timepoints_1_params(
    timestep: float,
    timestart: float,
    opt_unit_unit: str | None = None,
) -> CiftiConvertResetTimepoints1ParametersTagged:
    """
    Build parameters.
    
    Args:
        timestep: the desired time between frames.
        timestart: the desired time offset of the initial frame.
        opt_unit_unit: use a unit other than time: unit identifier (default\
            SECOND).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "reset_timepoints_1",
        "timestep": timestep,
        "timestart": timestart,
    }
    if opt_unit_unit is not None:
        params["opt_unit_unit"] = opt_unit_unit
    return params


def cifti_convert_reset_timepoints_1_cargs(
    params: CiftiConvertResetTimepoints1Parameters,
    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("-reset-timepoints")
    cargs.append(str(params.get("timestep", None)))
    cargs.append(str(params.get("timestart", None)))
    if params.get("opt_unit_unit", None) is not None:
        cargs.extend([
            "-unit",
            params.get("opt_unit_unit", None)
        ])
    return cargs


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


def cifti_convert_from_nifti_params(
    nifti_in: InputPathType,
    cifti_template: InputPathType,
    cifti_out: str,
    reset_timepoints: CiftiConvertResetTimepoints1Parameters | None = None,
    opt_reset_scalars: bool = False,
) -> CiftiConvertFromNiftiParametersTagged:
    """
    Build parameters.
    
    Args:
        nifti_in: the input nifti file.
        cifti_template: a cifti file with the dimension(s) and mapping(s) that\
            should be used.
        cifti_out: the output cifti file.
        reset_timepoints: reset the mapping along rows to timepoints, taking\
            length from the nifti file.
        opt_reset_scalars: reset mapping along rows to scalars, taking length\
            from the nifti file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "from_nifti",
        "nifti_in": nifti_in,
        "cifti_template": cifti_template,
        "cifti_out": cifti_out,
        "opt_reset_scalars": opt_reset_scalars,
    }
    if reset_timepoints is not None:
        params["reset_timepoints"] = reset_timepoints
    return params


def cifti_convert_from_nifti_cargs(
    params: CiftiConvertFromNiftiParameters,
    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-nifti")
    cargs.append(execution.input_file(params.get("nifti_in", None)))
    cargs.append(execution.input_file(params.get("cifti_template", None)))
    cargs.append(params.get("cifti_out", None))
    if params.get("reset_timepoints", None) is not None:
        cargs.extend(cifti_convert_reset_timepoints_1_cargs(params.get("reset_timepoints", None), execution))
    if params.get("opt_reset_scalars", False):
        cargs.append("-reset-scalars")
    return cargs


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


def cifti_convert_to_text_params(
    cifti_in: InputPathType,
    text_out: str,
    opt_col_delim_delim_string: str | None = None,
) -> CiftiConvertToTextParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_in: the input cifti file.
        text_out: output - the output text file.
        opt_col_delim_delim_string: choose string to put between elements in a\
            row: the string to use (default is a tab character).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "to_text",
        "cifti_in": cifti_in,
        "text_out": text_out,
    }
    if opt_col_delim_delim_string is not None:
        params["opt_col_delim_delim_string"] = opt_col_delim_delim_string
    return params


def cifti_convert_to_text_cargs(
    params: CiftiConvertToTextParameters,
    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("-to-text")
    cargs.append(execution.input_file(params.get("cifti_in", None)))
    cargs.append(params.get("text_out", None))
    if params.get("opt_col_delim_delim_string", None) is not None:
        cargs.extend([
            "-col-delim",
            params.get("opt_col_delim_delim_string", None)
        ])
    return cargs


def cifti_convert_reset_timepoints_2_params(
    timestep: float,
    timestart: float,
    opt_unit_unit: str | None = None,
) -> CiftiConvertResetTimepoints2ParametersTagged:
    """
    Build parameters.
    
    Args:
        timestep: the desired time between frames.
        timestart: the desired time offset of the initial frame.
        opt_unit_unit: use a unit other than time: unit identifier (default\
            SECOND).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "reset_timepoints_2",
        "timestep": timestep,
        "timestart": timestart,
    }
    if opt_unit_unit is not None:
        params["opt_unit_unit"] = opt_unit_unit
    return params


def cifti_convert_reset_timepoints_2_cargs(
    params: CiftiConvertResetTimepoints2Parameters,
    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("-reset-timepoints")
    cargs.append(str(params.get("timestep", None)))
    cargs.append(str(params.get("timestart", None)))
    if params.get("opt_unit_unit", None) is not None:
        cargs.extend([
            "-unit",
            params.get("opt_unit_unit", None)
        ])
    return cargs


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


def cifti_convert_from_text_params(
    text_in: str,
    cifti_template: InputPathType,
    cifti_out: str,
    opt_col_delim_delim_string: str | None = None,
    reset_timepoints: CiftiConvertResetTimepoints2Parameters | None = None,
    opt_reset_scalars: bool = False,
) -> CiftiConvertFromTextParametersTagged:
    """
    Build parameters.
    
    Args:
        text_in: the input text file.
        cifti_template: a cifti file with the dimension(s) and mapping(s) that\
            should be used.
        cifti_out: the output cifti file.
        opt_col_delim_delim_string: specify string that is between elements in\
            a row: the string to use (default is any whitespace).
        reset_timepoints: reset the mapping along rows to timepoints, taking\
            length from the text file.
        opt_reset_scalars: reset mapping along rows to scalars, taking length\
            from the text file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "from_text",
        "text_in": text_in,
        "cifti_template": cifti_template,
        "cifti_out": cifti_out,
        "opt_reset_scalars": opt_reset_scalars,
    }
    if opt_col_delim_delim_string is not None:
        params["opt_col_delim_delim_string"] = opt_col_delim_delim_string
    if reset_timepoints is not None:
        params["reset_timepoints"] = reset_timepoints
    return params


def cifti_convert_from_text_cargs(
    params: CiftiConvertFromTextParameters,
    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-text")
    cargs.append(params.get("text_in", None))
    cargs.append(execution.input_file(params.get("cifti_template", None)))
    cargs.append(params.get("cifti_out", None))
    if params.get("opt_col_delim_delim_string", None) is not None:
        cargs.extend([
            "-col-delim",
            params.get("opt_col_delim_delim_string", None)
        ])
    if params.get("reset_timepoints", None) is not None:
        cargs.extend(cifti_convert_reset_timepoints_2_cargs(params.get("reset_timepoints", None), execution))
    if params.get("opt_reset_scalars", False):
        cargs.append("-reset-scalars")
    return cargs


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


class CiftiConvertOutputs(typing.NamedTuple):
    """
    Output object returned when calling `CiftiConvertParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    from_gifti_ext: CiftiConvertFromGiftiExtOutputs | None
    """Outputs from `cifti_convert_from_gifti_ext_outputs`."""
    to_nifti: CiftiConvertToNiftiOutputs | None
    """Outputs from `cifti_convert_to_nifti_outputs`."""
    from_nifti: CiftiConvertFromNiftiOutputs | None
    """Outputs from `cifti_convert_from_nifti_outputs`."""
    from_text: CiftiConvertFromTextOutputs | None
    """Outputs from `cifti_convert_from_text_outputs`."""


def cifti_convert_params(
    to_gifti_ext: CiftiConvertToGiftiExtParameters | None = None,
    from_gifti_ext: CiftiConvertFromGiftiExtParameters | None = None,
    to_nifti: CiftiConvertToNiftiParameters | None = None,
    from_nifti: CiftiConvertFromNiftiParameters | None = None,
    to_text: CiftiConvertToTextParameters | None = None,
    from_text: CiftiConvertFromTextParameters | None = None,
) -> CiftiConvertParametersTagged:
    """
    Build parameters.
    
    Args:
        to_gifti_ext: convert to GIFTI external binary.
        from_gifti_ext: convert a GIFTI made with this command back into a\
            CIFTI.
        to_nifti: convert to NIFTI1.
        from_nifti: convert a NIFTI (1 or 2) file made with this command back\
            into CIFTI.
        to_text: convert to a plain text file.
        from_text: convert from plain text to cifti.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-convert",
    }
    if to_gifti_ext is not None:
        params["to_gifti_ext"] = to_gifti_ext
    if from_gifti_ext is not None:
        params["from_gifti_ext"] = from_gifti_ext
    if to_nifti is not None:
        params["to_nifti"] = to_nifti
    if from_nifti is not None:
        params["from_nifti"] = from_nifti
    if to_text is not None:
        params["to_text"] = to_text
    if from_text is not None:
        params["from_text"] = from_text
    return params


def cifti_convert_cargs(
    params: CiftiConvertParameters,
    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-convert")
    if params.get("to_gifti_ext", None) is not None:
        cargs.extend(cifti_convert_to_gifti_ext_cargs(params.get("to_gifti_ext", None), execution))
    if params.get("from_gifti_ext", None) is not None:
        cargs.extend(cifti_convert_from_gifti_ext_cargs(params.get("from_gifti_ext", None), execution))
    if params.get("to_nifti", None) is not None:
        cargs.extend(cifti_convert_to_nifti_cargs(params.get("to_nifti", None), execution))
    if params.get("from_nifti", None) is not None:
        cargs.extend(cifti_convert_from_nifti_cargs(params.get("from_nifti", None), execution))
    if params.get("to_text", None) is not None:
        cargs.extend(cifti_convert_to_text_cargs(params.get("to_text", None), execution))
    if params.get("from_text", None) is not None:
        cargs.extend(cifti_convert_from_text_cargs(params.get("from_text", None), execution))
    return cargs


def cifti_convert_outputs(
    params: CiftiConvertParameters,
    execution: Execution,
) -> CiftiConvertOutputs:
    """
    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 = CiftiConvertOutputs(
        root=execution.output_file("."),
        from_gifti_ext=cifti_convert_from_gifti_ext_outputs(params.get("from_gifti_ext"), execution) if params.get("from_gifti_ext") else None,
        to_nifti=cifti_convert_to_nifti_outputs(params.get("to_nifti"), execution) if params.get("to_nifti") else None,
        from_nifti=cifti_convert_from_nifti_outputs(params.get("from_nifti"), execution) if params.get("from_nifti") else None,
        from_text=cifti_convert_from_text_outputs(params.get("from_text"), execution) if params.get("from_text") else None,
    )
    return ret


def cifti_convert_execute(
    params: CiftiConvertParameters,
    runner: Runner | None = None,
) -> CiftiConvertOutputs:
    """
    cifti-convert
    
    Dump cifti matrix into other formats.
    
    This command is used to convert a full CIFTI matrix to/from formats that can
    be used by programs that don't understand CIFTI. You must specify exactly
    one of -to-gifti-ext, -from-gifti-ext, -to-nifti, -from-nifti, -to-text, or
    -from-text.
    
    If you want to write an existing CIFTI file with a different CIFTI version,
    see -file-convert, and its -cifti-version-convert option.
    
    If you want part of the CIFTI file as a metric, label, or volume file, see
    -cifti-separate. If you want to create a CIFTI file from metric and/or
    volume files, see the -cifti-create-* commands.
    
    If you want to import a matrix that is restricted to an ROI, first create a
    template CIFTI file matching that ROI using a -cifti-create-* command. After
    importing to CIFTI, you can then expand the file into a standard
    brainordinates space with -cifti-create-dense-from-template. If you want to
    export only part of a CIFTI file, first create an roi-restricted CIFTI file
    with -cifti-restrict-dense-mapping.
    
    The -transpose option to -from-gifti-ext is needed if the replacement binary
    file is in column-major order.
    
    The -unit options accept these values:
    
    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 `CiftiConvertOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_CONVERT_METADATA)
    params = execution.params(params)
    cargs = cifti_convert_cargs(params, execution)
    ret = cifti_convert_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_convert(
    to_gifti_ext: CiftiConvertToGiftiExtParameters | None = None,
    from_gifti_ext: CiftiConvertFromGiftiExtParameters | None = None,
    to_nifti: CiftiConvertToNiftiParameters | None = None,
    from_nifti: CiftiConvertFromNiftiParameters | None = None,
    to_text: CiftiConvertToTextParameters | None = None,
    from_text: CiftiConvertFromTextParameters | None = None,
    runner: Runner | None = None,
) -> CiftiConvertOutputs:
    """
    cifti-convert
    
    Dump cifti matrix into other formats.
    
    This command is used to convert a full CIFTI matrix to/from formats that can
    be used by programs that don't understand CIFTI. You must specify exactly
    one of -to-gifti-ext, -from-gifti-ext, -to-nifti, -from-nifti, -to-text, or
    -from-text.
    
    If you want to write an existing CIFTI file with a different CIFTI version,
    see -file-convert, and its -cifti-version-convert option.
    
    If you want part of the CIFTI file as a metric, label, or volume file, see
    -cifti-separate. If you want to create a CIFTI file from metric and/or
    volume files, see the -cifti-create-* commands.
    
    If you want to import a matrix that is restricted to an ROI, first create a
    template CIFTI file matching that ROI using a -cifti-create-* command. After
    importing to CIFTI, you can then expand the file into a standard
    brainordinates space with -cifti-create-dense-from-template. If you want to
    export only part of a CIFTI file, first create an roi-restricted CIFTI file
    with -cifti-restrict-dense-mapping.
    
    The -transpose option to -from-gifti-ext is needed if the replacement binary
    file is in column-major order.
    
    The -unit options accept these values:
    
    SECOND
    HERTZ
    METER
    RADIAN.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        to_gifti_ext: convert to GIFTI external binary.
        from_gifti_ext: convert a GIFTI made with this command back into a\
            CIFTI.
        to_nifti: convert to NIFTI1.
        from_nifti: convert a NIFTI (1 or 2) file made with this command back\
            into CIFTI.
        to_text: convert to a plain text file.
        from_text: convert from plain text to cifti.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiConvertOutputs`).
    """
    params = cifti_convert_params(
        to_gifti_ext=to_gifti_ext,
        from_gifti_ext=from_gifti_ext,
        to_nifti=to_nifti,
        from_nifti=from_nifti,
        to_text=to_text,
        from_text=from_text,
    )
    return cifti_convert_execute(params, runner)


__all__ = [
    "CIFTI_CONVERT_METADATA",
    "CiftiConvertFromGiftiExtOutputs",
    "CiftiConvertFromNiftiOutputs",
    "CiftiConvertFromTextOutputs",
    "CiftiConvertOutputs",
    "CiftiConvertToNiftiOutputs",
    "cifti_convert",
    "cifti_convert_execute",
    "cifti_convert_from_gifti_ext_params",
    "cifti_convert_from_nifti_params",
    "cifti_convert_from_text_params",
    "cifti_convert_params",
    "cifti_convert_replace_binary_params",
    "cifti_convert_reset_timepoints_1_params",
    "cifti_convert_reset_timepoints_2_params",
    "cifti_convert_reset_timepoints_params",
    "cifti_convert_to_gifti_ext_params",
    "cifti_convert_to_nifti_params",
    "cifti_convert_to_text_params",
]
