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

import typing
import pathlib
from styxdefs import *

MTNORMALISE_METADATA = Metadata(
    id="3bc2bbe8af34500259b7245db2d18482e852bfea.boutiques",
    name="mtnormalise",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


_MtnormaliseConfigParamsDictNoTag = typing.TypedDict('_MtnormaliseConfigParamsDictNoTag', {
    "key": str,
    "value": str,
})
MtnormaliseConfigParamsDictTagged = typing.TypedDict('MtnormaliseConfigParamsDictTagged', {
    "@type": typing.Literal["config"],
    "key": str,
    "value": str,
})
MtnormaliseConfigParamsDict = _MtnormaliseConfigParamsDictNoTag | MtnormaliseConfigParamsDictTagged


_MtnormaliseInputOutputParamsDictNoTag = typing.TypedDict('_MtnormaliseInputOutputParamsDictNoTag', {
    "input": InputPathType,
    "output": str,
})
MtnormaliseInputOutputParamsDictTagged = typing.TypedDict('MtnormaliseInputOutputParamsDictTagged', {
    "@type": typing.Literal["input_output"],
    "input": InputPathType,
    "output": str,
})
MtnormaliseInputOutputParamsDict = _MtnormaliseInputOutputParamsDictNoTag | MtnormaliseInputOutputParamsDictTagged


_MtnormaliseParamsDictNoTag = typing.TypedDict('_MtnormaliseParamsDictNoTag', {
    "mask": InputPathType,
    "order": typing.NotRequired[str | None],
    "niter": typing.NotRequired[list[int] | None],
    "reference": typing.NotRequired[float | None],
    "balanced": bool,
    "check_norm": typing.NotRequired[str | None],
    "check_mask": typing.NotRequired[str | None],
    "check_factors": typing.NotRequired[str | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MtnormaliseConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "input_output": list[MtnormaliseInputOutputParamsDict],
})
MtnormaliseParamsDictTagged = typing.TypedDict('MtnormaliseParamsDictTagged', {
    "@type": typing.Literal["mrtrix/mtnormalise"],
    "mask": InputPathType,
    "order": typing.NotRequired[str | None],
    "niter": typing.NotRequired[list[int] | None],
    "reference": typing.NotRequired[float | None],
    "balanced": bool,
    "check_norm": typing.NotRequired[str | None],
    "check_mask": typing.NotRequired[str | None],
    "check_factors": typing.NotRequired[str | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MtnormaliseConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "input_output": list[MtnormaliseInputOutputParamsDict],
})
MtnormaliseParamsDict = _MtnormaliseParamsDictNoTag | MtnormaliseParamsDictTagged


def mtnormalise_config(
    key: str,
    value: str,
) -> MtnormaliseConfigParamsDictTagged:
    """
    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 mtnormalise_config_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MtnormaliseConfigParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("key", None) is None:
        raise StyxValidationError("`key` must not be None")
    if not isinstance(params["key"], str):
        raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
    if params.get("value", None) is None:
        raise StyxValidationError("`value` must not be None")
    if not isinstance(params["value"], str):
        raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')


def mtnormalise_config_cargs(
    params: MtnormaliseConfigParamsDict,
    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 MtnormaliseInputOutputOutputs(typing.NamedTuple):
    """
    Output object returned when calling `list[MtnormaliseInputOutputParamsDict](...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output: OutputPathType
    """output normalised tissue compartment image."""


def mtnormalise_input_output(
    input_: InputPathType,
    output: str,
) -> MtnormaliseInputOutputParamsDictTagged:
    """
    Build parameters.
    
    Args:
        input_: input tissue compartment image.
        output: output normalised tissue compartment image.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "input_output",
        "input": input_,
        "output": output,
    }
    return params


def mtnormalise_input_output_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MtnormaliseInputOutputParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("input", None) is None:
        raise StyxValidationError("`input` must not be None")
    if not isinstance(params["input"], (pathlib.Path, str)):
        raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
    if params.get("output", None) is None:
        raise StyxValidationError("`output` must not be None")
    if not isinstance(params["output"], str):
        raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')


def mtnormalise_input_output_cargs(
    params: MtnormaliseInputOutputParamsDict,
    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(execution.input_file(params.get("input", None)))
    cargs.append(params.get("output", None))
    return cargs


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


class MtnormaliseOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MtnormaliseParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    check_norm: OutputPathType | None
    """output the final estimated spatially varying intensity level that is used
    for normalisation. """
    check_mask: OutputPathType | None
    """output the final mask used to compute the normalisation. This mask
    excludes regions identified as outliers by the optimisation process. """
    check_factors: OutputPathType | None
    """output the tissue balance factors computed during normalisation. """
    input_output: list[MtnormaliseInputOutputOutputs]
    """Outputs from `mtnormalise_input_output_outputs`.This is a list of outputs
    with the same length and order as the inputs."""


def mtnormalise_params(
    mask: InputPathType,
    input_output: list[MtnormaliseInputOutputParamsDict],
    order: str | None = None,
    niter: list[int] | None = None,
    reference: float | None = None,
    balanced: bool = False,
    check_norm: str | None = None,
    check_mask: str | None = None,
    check_factors: str | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MtnormaliseConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
) -> MtnormaliseParamsDictTagged:
    """
    Build parameters.
    
    Args:
        mask: the mask defines the data used to compute the intensity\
            normalisation. This option is mandatory.
        input_output: list of all input and output tissue compartment files\
            (see example usage).
        order: the maximum order of the polynomial basis used to fit the\
            normalisation field in the log-domain. An order of 0 is equivalent to\
            not allowing spatial variance of the intensity normalisation factor.\
            (default: 3).
        niter: set the number of iterations. The first (and potentially only)\
            entry applies to the main loop. If supplied as a comma-separated list\
            of integers, the second entry applies to the inner loop to update the\
            balance factors (default: 15,7).
        reference: specify the (positive) reference value to which the summed\
            tissue compartments will be normalised. (default: 0.282095, SH DC term\
            for unit angular integral).
        balanced: incorporate the per-tissue balancing factors into scaling of\
            the output images (NOTE: use of this option has critical consequences\
            for AFD intensity normalisation; should not be used unless these\
            consequences are fully understood).
        check_norm: output the final estimated spatially varying intensity\
            level that is used for normalisation.
        check_mask: output the final mask used to compute the normalisation.\
            This mask excludes regions identified as outliers by the optimisation\
            process.
        check_factors: output the tissue balance factors computed during\
            normalisation.
        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/mtnormalise",
        "mask": mask,
        "balanced": balanced,
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "input_output": input_output,
    }
    if order is not None:
        params["order"] = order
    if niter is not None:
        params["niter"] = niter
    if reference is not None:
        params["reference"] = reference
    if check_norm is not None:
        params["check_norm"] = check_norm
    if check_mask is not None:
        params["check_mask"] = check_mask
    if check_factors is not None:
        params["check_factors"] = check_factors
    if nthreads is not None:
        params["nthreads"] = nthreads
    if config is not None:
        params["config"] = config
    return params


def mtnormalise_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MtnormaliseParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("mask", None) is None:
        raise StyxValidationError("`mask` must not be None")
    if not isinstance(params["mask"], (pathlib.Path, str)):
        raise StyxValidationError(f'`mask` has the wrong type: Received `{type(params.get("mask", None))}` expected `InputPathType`')
    if params.get("order", None) is not None:
        if not isinstance(params["order"], str):
            raise StyxValidationError(f'`order` has the wrong type: Received `{type(params.get("order", None))}` expected `str | None`')
    if params.get("niter", None) is not None:
        if not isinstance(params["niter"], list):
            raise StyxValidationError(f'`niter` has the wrong type: Received `{type(params.get("niter", None))}` expected `list[int] | None`')
        for e in params["niter"]:
            if not isinstance(e, int):
                raise StyxValidationError(f'`niter` has the wrong type: Received `{type(params.get("niter", None))}` expected `list[int] | None`')
    if params.get("reference", None) is not None:
        if not isinstance(params["reference"], (float, int)):
            raise StyxValidationError(f'`reference` has the wrong type: Received `{type(params.get("reference", None))}` expected `float | None`')
    if params.get("balanced", False) is None:
        raise StyxValidationError("`balanced` must not be None")
    if not isinstance(params["balanced"], bool):
        raise StyxValidationError(f'`balanced` has the wrong type: Received `{type(params.get("balanced", False))}` expected `bool`')
    if params.get("check_norm", None) is not None:
        if not isinstance(params["check_norm"], str):
            raise StyxValidationError(f'`check_norm` has the wrong type: Received `{type(params.get("check_norm", None))}` expected `str | None`')
    if params.get("check_mask", None) is not None:
        if not isinstance(params["check_mask"], str):
            raise StyxValidationError(f'`check_mask` has the wrong type: Received `{type(params.get("check_mask", None))}` expected `str | None`')
    if params.get("check_factors", None) is not None:
        if not isinstance(params["check_factors"], str):
            raise StyxValidationError(f'`check_factors` has the wrong type: Received `{type(params.get("check_factors", None))}` expected `str | None`')
    if params.get("info", False) is None:
        raise StyxValidationError("`info` must not be None")
    if not isinstance(params["info"], bool):
        raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
    if params.get("quiet", False) is None:
        raise StyxValidationError("`quiet` must not be None")
    if not isinstance(params["quiet"], bool):
        raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
    if params.get("debug", False) is None:
        raise StyxValidationError("`debug` must not be None")
    if not isinstance(params["debug"], bool):
        raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
    if params.get("force", False) is None:
        raise StyxValidationError("`force` must not be None")
    if not isinstance(params["force"], bool):
        raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
    if params.get("nthreads", None) is not None:
        if not isinstance(params["nthreads"], int):
            raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
    if params.get("config", None) is not None:
        if not isinstance(params["config"], list):
            raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[MtnormaliseConfigParamsDict] | None`')
        for e in params["config"]:
            mtnormalise_config_validate(e)
    if params.get("help", False) is None:
        raise StyxValidationError("`help` must not be None")
    if not isinstance(params["help"], bool):
        raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
    if params.get("version", False) is None:
        raise StyxValidationError("`version` must not be None")
    if not isinstance(params["version"], bool):
        raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
    if params.get("input_output", None) is None:
        raise StyxValidationError("`input_output` must not be None")
    if not isinstance(params["input_output"], list):
        raise StyxValidationError(f'`input_output` has the wrong type: Received `{type(params.get("input_output", None))}` expected `list[MtnormaliseInputOutputParamsDict]`')
    for e in params["input_output"]:
        mtnormalise_input_output_validate(e)


def mtnormalise_cargs(
    params: MtnormaliseParamsDict,
    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("mtnormalise")
    cargs.extend([
        "-mask",
        execution.input_file(params.get("mask", None))
    ])
    if params.get("order", None) is not None:
        cargs.extend([
            "-order",
            params.get("order", None)
        ])
    if params.get("niter", None) is not None:
        cargs.extend([
            "-niter",
            ",".join(map(str, params.get("niter", None)))
        ])
    if params.get("reference", None) is not None:
        cargs.extend([
            "-reference",
            str(params.get("reference", None))
        ])
    if params.get("balanced", False):
        cargs.append("-balanced")
    if params.get("check_norm", None) is not None:
        cargs.extend([
            "-check_norm",
            params.get("check_norm", None)
        ])
    if params.get("check_mask", None) is not None:
        cargs.extend([
            "-check_mask",
            params.get("check_mask", None)
        ])
    if params.get("check_factors", None) is not None:
        cargs.extend([
            "-check_factors",
            params.get("check_factors", 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 [mtnormalise_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([a for c in [mtnormalise_input_output_cargs(s, execution) for s in params.get("input_output", None)] for a in c])
    return cargs


def mtnormalise_outputs(
    params: MtnormaliseParamsDict,
    execution: Execution,
) -> MtnormaliseOutputs:
    """
    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 = MtnormaliseOutputs(
        root=execution.output_file("."),
        check_norm=execution.output_file(params.get("check_norm", None)) if (params.get("check_norm") is not None) else None,
        check_mask=execution.output_file(params.get("check_mask", None)) if (params.get("check_mask") is not None) else None,
        check_factors=execution.output_file(params.get("check_factors", None)) if (params.get("check_factors") is not None) else None,
        input_output=[mtnormalise_input_output_outputs(i, execution) if mtnormalise_input_output_outputs else None for i in params.get("input_output")],
    )
    return ret


def mtnormalise_execute(
    params: MtnormaliseParamsDict,
    runner: Runner | None = None,
) -> MtnormaliseOutputs:
    """
    mtnormalise
    
    Multi-tissue informed log-domain intensity normalisation.
    
    This command takes as input any number of tissue components (e.g. from
    multi-tissue CSD) and outputs corresponding normalised tissue components
    corrected for the effects of (residual) intensity inhomogeneities. Intensity
    normalisation is performed by optimising the voxel-wise sum of all tissue
    compartments towards a constant value, under constraints of spatial
    smoothness (polynomial basis of a given order). Different to the Raffelt et
    al. 2017 abstract, this algorithm performs this task in the log-domain
    instead, with added gradual outlier rejection, different handling of the
    balancing factors between tissue compartments and a different iteration
    structure.
    
    The -mask option is mandatory and is optimally provided with a brain mask
    (such as the one obtained from dwi2mask earlier in the processing pipeline).
    Outlier areas with exceptionally low or high combined tissue contributions
    are accounted for and reoptimised as the intensity inhomogeneity estimation
    becomes more accurate.
    
    References:
    
    Raffelt, D.; Dhollander, T.; Tournier, J.-D.; Tabbara, R.; Smith, R. E.;
    Pierre, E. & Connelly, A. Bias Field Correction and Intensity Normalisation
    for Quantitative Analysis of Apparent Fibre Density. In Proc. ISMRM, 2017,
    26, 3541
    
    Dhollander, T.; Tabbara, R.; Rosnarho-Tornstrand, J.; Tournier, J.-D.;
    Raffelt, D. & Connelly, A. Multi-tissue log-domain intensity and
    inhomogeneity normalisation for quantitative apparent fibre density. In
    Proc. ISMRM, 2021, 29, 2472.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MtnormaliseOutputs`).
    """
    mtnormalise_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(MTNORMALISE_METADATA)
    params = execution.params(params)
    cargs = mtnormalise_cargs(params, execution)
    ret = mtnormalise_outputs(params, execution)
    execution.run(cargs)
    return ret


def mtnormalise(
    mask: InputPathType,
    input_output: list[MtnormaliseInputOutputParamsDict],
    order: str | None = None,
    niter: list[int] | None = None,
    reference: float | None = None,
    balanced: bool = False,
    check_norm: str | None = None,
    check_mask: str | None = None,
    check_factors: str | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MtnormaliseConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> MtnormaliseOutputs:
    """
    mtnormalise
    
    Multi-tissue informed log-domain intensity normalisation.
    
    This command takes as input any number of tissue components (e.g. from
    multi-tissue CSD) and outputs corresponding normalised tissue components
    corrected for the effects of (residual) intensity inhomogeneities. Intensity
    normalisation is performed by optimising the voxel-wise sum of all tissue
    compartments towards a constant value, under constraints of spatial
    smoothness (polynomial basis of a given order). Different to the Raffelt et
    al. 2017 abstract, this algorithm performs this task in the log-domain
    instead, with added gradual outlier rejection, different handling of the
    balancing factors between tissue compartments and a different iteration
    structure.
    
    The -mask option is mandatory and is optimally provided with a brain mask
    (such as the one obtained from dwi2mask earlier in the processing pipeline).
    Outlier areas with exceptionally low or high combined tissue contributions
    are accounted for and reoptimised as the intensity inhomogeneity estimation
    becomes more accurate.
    
    References:
    
    Raffelt, D.; Dhollander, T.; Tournier, J.-D.; Tabbara, R.; Smith, R. E.;
    Pierre, E. & Connelly, A. Bias Field Correction and Intensity Normalisation
    for Quantitative Analysis of Apparent Fibre Density. In Proc. ISMRM, 2017,
    26, 3541
    
    Dhollander, T.; Tabbara, R.; Rosnarho-Tornstrand, J.; Tournier, J.-D.;
    Raffelt, D. & Connelly, A. Multi-tissue log-domain intensity and
    inhomogeneity normalisation for quantitative apparent fibre density. In
    Proc. ISMRM, 2021, 29, 2472.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        mask: the mask defines the data used to compute the intensity\
            normalisation. This option is mandatory.
        input_output: list of all input and output tissue compartment files\
            (see example usage).
        order: the maximum order of the polynomial basis used to fit the\
            normalisation field in the log-domain. An order of 0 is equivalent to\
            not allowing spatial variance of the intensity normalisation factor.\
            (default: 3).
        niter: set the number of iterations. The first (and potentially only)\
            entry applies to the main loop. If supplied as a comma-separated list\
            of integers, the second entry applies to the inner loop to update the\
            balance factors (default: 15,7).
        reference: specify the (positive) reference value to which the summed\
            tissue compartments will be normalised. (default: 0.282095, SH DC term\
            for unit angular integral).
        balanced: incorporate the per-tissue balancing factors into scaling of\
            the output images (NOTE: use of this option has critical consequences\
            for AFD intensity normalisation; should not be used unless these\
            consequences are fully understood).
        check_norm: output the final estimated spatially varying intensity\
            level that is used for normalisation.
        check_mask: output the final mask used to compute the normalisation.\
            This mask excludes regions identified as outliers by the optimisation\
            process.
        check_factors: output the tissue balance factors computed during\
            normalisation.
        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 `MtnormaliseOutputs`).
    """
    params = mtnormalise_params(
        mask=mask,
        order=order,
        niter=niter,
        reference=reference,
        balanced=balanced,
        check_norm=check_norm,
        check_mask=check_mask,
        check_factors=check_factors,
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        input_output=input_output,
    )
    return mtnormalise_execute(params, runner)


__all__ = [
    "MTNORMALISE_METADATA",
    "MtnormaliseConfigParamsDict",
    "MtnormaliseConfigParamsDictTagged",
    "MtnormaliseInputOutputOutputs",
    "MtnormaliseInputOutputParamsDict",
    "MtnormaliseInputOutputParamsDictTagged",
    "MtnormaliseOutputs",
    "MtnormaliseParamsDict",
    "MtnormaliseParamsDictTagged",
    "mtnormalise",
    "mtnormalise_config",
    "mtnormalise_execute",
    "mtnormalise_input_output",
    "mtnormalise_params",
]
