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

import typing
import pathlib
from styxdefs import *

MESH2VOXEL_METADATA = Metadata(
    id="75e8f4f5578fd6f6ca18cc54925c6087e0adc3bc.boutiques",
    name="mesh2voxel",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


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


Mesh2voxelParameters = typing.TypedDict('Mesh2voxelParameters', {
    "@type": typing.NotRequired[typing.Literal["mrtrix/mesh2voxel"]],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Mesh2voxelConfigParameters] | None],
    "help": bool,
    "version": bool,
    "source": InputPathType,
    "template": InputPathType,
    "output": str,
})
Mesh2voxelParametersTagged = typing.TypedDict('Mesh2voxelParametersTagged', {
    "@type": typing.Literal["mrtrix/mesh2voxel"],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Mesh2voxelConfigParameters] | None],
    "help": bool,
    "version": bool,
    "source": InputPathType,
    "template": InputPathType,
    "output": str,
})


def mesh2voxel_config_params(
    key: str,
    value: str,
) -> Mesh2voxelConfigParametersTagged:
    """
    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 mesh2voxel_config_cargs(
    params: Mesh2voxelConfigParameters,
    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 Mesh2voxelOutputs(typing.NamedTuple):
    """
    Output object returned when calling `Mesh2voxelParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output: OutputPathType
    """the output image"""


def mesh2voxel_params(
    source: InputPathType,
    template: InputPathType,
    output: str,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Mesh2voxelConfigParameters] | None = None,
    help_: bool = False,
    version: bool = False,
) -> Mesh2voxelParametersTagged:
    """
    Build parameters.
    
    Args:
        source: the mesh file; note vertices must be defined in realspace\
            coordinates.
        template: the template image.
        output: the output image.
        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/mesh2voxel",
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "source": source,
        "template": template,
        "output": output,
    }
    if nthreads is not None:
        params["nthreads"] = nthreads
    if config is not None:
        params["config"] = config
    return params


def mesh2voxel_cargs(
    params: Mesh2voxelParameters,
    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("mesh2voxel")
    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 [mesh2voxel_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("source", None)))
    cargs.append(execution.input_file(params.get("template", None)))
    cargs.append(params.get("output", None))
    return cargs


def mesh2voxel_outputs(
    params: Mesh2voxelParameters,
    execution: Execution,
) -> Mesh2voxelOutputs:
    """
    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 = Mesh2voxelOutputs(
        root=execution.output_file("."),
        output=execution.output_file(params.get("output", None)),
    )
    return ret


def mesh2voxel_execute(
    params: Mesh2voxelParameters,
    runner: Runner | None = None,
) -> Mesh2voxelOutputs:
    """
    mesh2voxel
    
    Convert a mesh surface to a partial volume estimation image.
    
    
    
    References:
    
    Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A.
    Anatomically-constrained tractography: Improved diffusion MRI streamlines
    tractography through effective use of anatomical information. NeuroImage,
    2012, 62, 1924-1938.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Mesh2voxelOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MESH2VOXEL_METADATA)
    params = execution.params(params)
    cargs = mesh2voxel_cargs(params, execution)
    ret = mesh2voxel_outputs(params, execution)
    execution.run(cargs)
    return ret


def mesh2voxel(
    source: InputPathType,
    template: InputPathType,
    output: str,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Mesh2voxelConfigParameters] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> Mesh2voxelOutputs:
    """
    mesh2voxel
    
    Convert a mesh surface to a partial volume estimation image.
    
    
    
    References:
    
    Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A.
    Anatomically-constrained tractography: Improved diffusion MRI streamlines
    tractography through effective use of anatomical information. NeuroImage,
    2012, 62, 1924-1938.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        source: the mesh file; note vertices must be defined in realspace\
            coordinates.
        template: the template image.
        output: the output image.
        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 `Mesh2voxelOutputs`).
    """
    params = mesh2voxel_params(
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        source=source,
        template=template,
        output=output,
    )
    return mesh2voxel_execute(params, runner)


__all__ = [
    "MESH2VOXEL_METADATA",
    "Mesh2voxelOutputs",
    "mesh2voxel",
    "mesh2voxel_config_params",
    "mesh2voxel_execute",
    "mesh2voxel_params",
]
