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

import typing
import pathlib
from styxdefs import *

MRAVERAGEHEADER_METADATA = Metadata(
    id="157f0794eeda94318eeaa422b5298c388c67f70c.boutiques",
    name="mraverageheader",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


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


MraverageheaderParameters = typing.TypedDict('MraverageheaderParameters', {
    "@type": typing.NotRequired[typing.Literal["mrtrix/mraverageheader"]],
    "padding": typing.NotRequired[float | None],
    "resolution": typing.NotRequired[str | None],
    "fill": bool,
    "datatype": typing.NotRequired[str | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MraverageheaderConfigParameters] | None],
    "help": bool,
    "version": bool,
    "input": list[InputPathType],
    "output": str,
})
MraverageheaderParametersTagged = typing.TypedDict('MraverageheaderParametersTagged', {
    "@type": typing.Literal["mrtrix/mraverageheader"],
    "padding": typing.NotRequired[float | None],
    "resolution": typing.NotRequired[str | None],
    "fill": bool,
    "datatype": typing.NotRequired[str | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MraverageheaderConfigParameters] | None],
    "help": bool,
    "version": bool,
    "input": list[InputPathType],
    "output": str,
})


def mraverageheader_config_params(
    key: str,
    value: str,
) -> MraverageheaderConfigParametersTagged:
    """
    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 mraverageheader_config_cargs(
    params: MraverageheaderConfigParameters,
    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 MraverageheaderOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MraverageheaderParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output: OutputPathType
    """the output image"""


def mraverageheader_params(
    input_: list[InputPathType],
    output: str,
    padding: float | None = None,
    resolution: str | None = None,
    fill: bool = False,
    datatype: str | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MraverageheaderConfigParameters] | None = None,
    help_: bool = False,
    version: bool = False,
) -> MraverageheaderParametersTagged:
    """
    Build parameters.
    
    Args:
        input_: the input image(s).
        output: the output image.
        padding: boundary box padding in voxels. Default: 0.
        resolution: subsampling of template compared to smallest voxel size in\
            any input image. Valid options are 'mean': unbiased but loss of\
            resolution for individual images possible, and 'max': smallest voxel\
            size of any input image defines the resolution. Default: mean.
        fill: set the intensity in the first volume of the average space to 1.
        datatype: specify output image data type. Valid choices are: float32,\
            float32le, float32be, float64, float64le, float64be, int64, uint64,\
            int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
            int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
            cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
            int8, uint8, bit.
        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/mraverageheader",
        "fill": fill,
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "input": input_,
        "output": output,
    }
    if padding is not None:
        params["padding"] = padding
    if resolution is not None:
        params["resolution"] = resolution
    if datatype is not None:
        params["datatype"] = datatype
    if nthreads is not None:
        params["nthreads"] = nthreads
    if config is not None:
        params["config"] = config
    return params


def mraverageheader_cargs(
    params: MraverageheaderParameters,
    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("mraverageheader")
    if params.get("padding", None) is not None:
        cargs.extend([
            "-padding",
            str(params.get("padding", None))
        ])
    if params.get("resolution", None) is not None:
        cargs.extend([
            "-resolution",
            params.get("resolution", None)
        ])
    if params.get("fill", False):
        cargs.append("-fill")
    if params.get("datatype", None) is not None:
        cargs.extend([
            "-datatype",
            params.get("datatype", 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 [mraverageheader_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.extend([execution.input_file(f) for f in params.get("input", None)])
    cargs.append(params.get("output", None))
    return cargs


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


def mraverageheader_execute(
    params: MraverageheaderParameters,
    runner: Runner | None = None,
) -> MraverageheaderOutputs:
    """
    mraverageheader
    
    Calculate the average (unbiased) coordinate space of all input images.
    
    
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MraverageheaderOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRAVERAGEHEADER_METADATA)
    params = execution.params(params)
    cargs = mraverageheader_cargs(params, execution)
    ret = mraverageheader_outputs(params, execution)
    execution.run(cargs)
    return ret


def mraverageheader(
    input_: list[InputPathType],
    output: str,
    padding: float | None = None,
    resolution: str | None = None,
    fill: bool = False,
    datatype: str | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MraverageheaderConfigParameters] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> MraverageheaderOutputs:
    """
    mraverageheader
    
    Calculate the average (unbiased) coordinate space of all input images.
    
    
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        input_: the input image(s).
        output: the output image.
        padding: boundary box padding in voxels. Default: 0.
        resolution: subsampling of template compared to smallest voxel size in\
            any input image. Valid options are 'mean': unbiased but loss of\
            resolution for individual images possible, and 'max': smallest voxel\
            size of any input image defines the resolution. Default: mean.
        fill: set the intensity in the first volume of the average space to 1.
        datatype: specify output image data type. Valid choices are: float32,\
            float32le, float32be, float64, float64le, float64be, int64, uint64,\
            int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
            int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
            cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
            int8, uint8, bit.
        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 `MraverageheaderOutputs`).
    """
    params = mraverageheader_params(
        padding=padding,
        resolution=resolution,
        fill=fill,
        datatype=datatype,
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        input_=input_,
        output=output,
    )
    return mraverageheader_execute(params, runner)


__all__ = [
    "MRAVERAGEHEADER_METADATA",
    "MraverageheaderOutputs",
    "mraverageheader",
    "mraverageheader_config_params",
    "mraverageheader_execute",
    "mraverageheader_params",
]
