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

import typing
import pathlib
from styxdefs import *

TCK2FIXEL_METADATA = Metadata(
    id="90f8734af004cf66512561b61fbe57f5bc2f690a.boutiques",
    name="tck2fixel",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


Tck2fixelConfigParameters = typing.TypedDict('Tck2fixelConfigParameters', {
    "@type": typing.NotRequired[typing.Literal["config"]],
    "key": str,
    "value": str,
})
Tck2fixelConfigParametersTagged = typing.TypedDict('Tck2fixelConfigParametersTagged', {
    "@type": typing.Literal["config"],
    "key": str,
    "value": str,
})


Tck2fixelParameters = typing.TypedDict('Tck2fixelParameters', {
    "@type": typing.NotRequired[typing.Literal["mrtrix/tck2fixel"]],
    "angle": typing.NotRequired[float | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Tck2fixelConfigParameters] | None],
    "help": bool,
    "version": bool,
    "tracks": InputPathType,
    "fixel_folder_in": InputPathType,
    "fixel_folder_out": str,
    "fixel_data_out": str,
})
Tck2fixelParametersTagged = typing.TypedDict('Tck2fixelParametersTagged', {
    "@type": typing.Literal["mrtrix/tck2fixel"],
    "angle": typing.NotRequired[float | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Tck2fixelConfigParameters] | None],
    "help": bool,
    "version": bool,
    "tracks": InputPathType,
    "fixel_folder_in": InputPathType,
    "fixel_folder_out": str,
    "fixel_data_out": str,
})


def tck2fixel_config_params(
    key: str,
    value: str,
) -> Tck2fixelConfigParametersTagged:
    """
    Build parameters.
    
    Args:
        key: temporarily set the value of an MRtrix config file entry.
        value: temporarily set the value of an MRtrix config file entry.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "config",
        "key": key,
        "value": value,
    }
    return params


def tck2fixel_config_cargs(
    params: Tck2fixelConfigParameters,
    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("-config")
    cargs.append(params.get("key", None))
    cargs.append(params.get("value", None))
    return cargs


class Tck2fixelOutputs(typing.NamedTuple):
    """
    Output object returned when calling `Tck2fixelParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def tck2fixel_params(
    tracks: InputPathType,
    fixel_folder_in: InputPathType,
    fixel_folder_out: str,
    fixel_data_out: str,
    angle: float | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Tck2fixelConfigParameters] | None = None,
    help_: bool = False,
    version: bool = False,
) -> Tck2fixelParametersTagged:
    """
    Build parameters.
    
    Args:
        tracks: the input tracks.
        fixel_folder_in: the input fixel folder. Used to define the fixels and\
            their directions.
        fixel_folder_out: the fixel folder to which the output will be written.\
            This can be the same as the input folder if desired.
        fixel_data_out: the name of the fixel data image.
        angle: the max angle threshold for assigning streamline tangents to\
            fixels (Default: 45 degrees).
        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.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "mrtrix/tck2fixel",
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "tracks": tracks,
        "fixel_folder_in": fixel_folder_in,
        "fixel_folder_out": fixel_folder_out,
        "fixel_data_out": fixel_data_out,
    }
    if angle is not None:
        params["angle"] = angle
    if nthreads is not None:
        params["nthreads"] = nthreads
    if config is not None:
        params["config"] = config
    return params


def tck2fixel_cargs(
    params: Tck2fixelParameters,
    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("tck2fixel")
    if params.get("angle", None) is not None:
        cargs.extend([
            "-angle",
            str(params.get("angle", None))
        ])
    if params.get("info", False):
        cargs.append("-info")
    if params.get("quiet", False):
        cargs.append("-quiet")
    if params.get("debug", False):
        cargs.append("-debug")
    if params.get("force", False):
        cargs.append("-force")
    if params.get("nthreads", None) is not None:
        cargs.extend([
            "-nthreads",
            str(params.get("nthreads", None))
        ])
    if params.get("config", None) is not None:
        cargs.extend([a for c in [tck2fixel_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
    if params.get("help", False):
        cargs.append("-help")
    if params.get("version", False):
        cargs.append("-version")
    cargs.append(execution.input_file(params.get("tracks", None)))
    cargs.append(execution.input_file(params.get("fixel_folder_in", None)))
    cargs.append(params.get("fixel_folder_out", None))
    cargs.append(params.get("fixel_data_out", None))
    return cargs


def tck2fixel_outputs(
    params: Tck2fixelParameters,
    execution: Execution,
) -> Tck2fixelOutputs:
    """
    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 = Tck2fixelOutputs(
        root=execution.output_file("."),
    )
    return ret


def tck2fixel_execute(
    params: Tck2fixelParameters,
    runner: Runner | None = None,
) -> Tck2fixelOutputs:
    """
    tck2fixel
    
    Compute a fixel TDI map from a tractogram.
    
    
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Tck2fixelOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(TCK2FIXEL_METADATA)
    params = execution.params(params)
    cargs = tck2fixel_cargs(params, execution)
    ret = tck2fixel_outputs(params, execution)
    execution.run(cargs)
    return ret


def tck2fixel(
    tracks: InputPathType,
    fixel_folder_in: InputPathType,
    fixel_folder_out: str,
    fixel_data_out: str,
    angle: float | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Tck2fixelConfigParameters] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> Tck2fixelOutputs:
    """
    tck2fixel
    
    Compute a fixel TDI map from a tractogram.
    
    
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        tracks: the input tracks.
        fixel_folder_in: the input fixel folder. Used to define the fixels and\
            their directions.
        fixel_folder_out: the fixel folder to which the output will be written.\
            This can be the same as the input folder if desired.
        fixel_data_out: the name of the fixel data image.
        angle: the max angle threshold for assigning streamline tangents to\
            fixels (Default: 45 degrees).
        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 `Tck2fixelOutputs`).
    """
    params = tck2fixel_params(
        angle=angle,
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        tracks=tracks,
        fixel_folder_in=fixel_folder_in,
        fixel_folder_out=fixel_folder_out,
        fixel_data_out=fixel_data_out,
    )
    return tck2fixel_execute(params, runner)


__all__ = [
    "TCK2FIXEL_METADATA",
    "Tck2fixelOutputs",
    "tck2fixel",
    "tck2fixel_config_params",
    "tck2fixel_execute",
    "tck2fixel_params",
]
