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

import typing
import pathlib
from styxdefs import *

DWI2TENSOR_METADATA = Metadata(
    id="700cecd2ddde8992557eb31468df42097fa6e2b1.boutiques",
    name="dwi2tensor",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


_Dwi2tensorFslgradParamsDictNoTag = typing.TypedDict('_Dwi2tensorFslgradParamsDictNoTag', {
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
Dwi2tensorFslgradParamsDictTagged = typing.TypedDict('Dwi2tensorFslgradParamsDictTagged', {
    "@type": typing.Literal["fslgrad"],
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
Dwi2tensorFslgradParamsDict = _Dwi2tensorFslgradParamsDictNoTag | Dwi2tensorFslgradParamsDictTagged


_Dwi2tensorConfigParamsDictNoTag = typing.TypedDict('_Dwi2tensorConfigParamsDictNoTag', {
    "key": str,
    "value": str,
})
Dwi2tensorConfigParamsDictTagged = typing.TypedDict('Dwi2tensorConfigParamsDictTagged', {
    "@type": typing.Literal["config"],
    "key": str,
    "value": str,
})
Dwi2tensorConfigParamsDict = _Dwi2tensorConfigParamsDictNoTag | Dwi2tensorConfigParamsDictTagged


_Dwi2tensorParamsDictNoTag = typing.TypedDict('_Dwi2tensorParamsDictNoTag', {
    "ols": bool,
    "mask": typing.NotRequired[InputPathType | None],
    "b0": typing.NotRequired[str | None],
    "dkt": typing.NotRequired[str | None],
    "iter": typing.NotRequired[int | None],
    "predicted_signal": typing.NotRequired[str | None],
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[Dwi2tensorFslgradParamsDict | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Dwi2tensorConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "dwi": InputPathType,
    "dt": str,
})
Dwi2tensorParamsDictTagged = typing.TypedDict('Dwi2tensorParamsDictTagged', {
    "@type": typing.Literal["mrtrix/dwi2tensor"],
    "ols": bool,
    "mask": typing.NotRequired[InputPathType | None],
    "b0": typing.NotRequired[str | None],
    "dkt": typing.NotRequired[str | None],
    "iter": typing.NotRequired[int | None],
    "predicted_signal": typing.NotRequired[str | None],
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[Dwi2tensorFslgradParamsDict | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Dwi2tensorConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "dwi": InputPathType,
    "dt": str,
})
Dwi2tensorParamsDict = _Dwi2tensorParamsDictNoTag | Dwi2tensorParamsDictTagged


def dwi2tensor_fslgrad(
    bvecs: InputPathType,
    bvals: InputPathType,
) -> Dwi2tensorFslgradParamsDictTagged:
    """
    Build parameters.
    
    Args:
        bvecs: Provide the diffusion-weighted gradient scheme used in the\
            acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
            scheme is present in the input image header, the data provided with\
            this option will be instead used.
        bvals: Provide the diffusion-weighted gradient scheme used in the\
            acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
            scheme is present in the input image header, the data provided with\
            this option will be instead used.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "fslgrad",
        "bvecs": bvecs,
        "bvals": bvals,
    }
    return params


def dwi2tensor_fslgrad_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `Dwi2tensorFslgradParamsDict` 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("bvecs", None) is None:
        raise StyxValidationError("`bvecs` must not be None")
    if not isinstance(params["bvecs"], (pathlib.Path, str)):
        raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
    if params.get("bvals", None) is None:
        raise StyxValidationError("`bvals` must not be None")
    if not isinstance(params["bvals"], (pathlib.Path, str)):
        raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')


def dwi2tensor_fslgrad_cargs(
    params: Dwi2tensorFslgradParamsDict,
    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("-fslgrad")
    cargs.append(execution.input_file(params.get("bvecs", None)))
    cargs.append(execution.input_file(params.get("bvals", None)))
    return cargs


def dwi2tensor_config(
    key: str,
    value: str,
) -> Dwi2tensorConfigParamsDictTagged:
    """
    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 dwi2tensor_config_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `Dwi2tensorConfigParamsDict` 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 dwi2tensor_config_cargs(
    params: Dwi2tensorConfigParamsDict,
    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 Dwi2tensorOutputs(typing.NamedTuple):
    """
    Output object returned when calling `Dwi2tensorParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    dt: OutputPathType
    """the output dt image."""
    b0: OutputPathType | None
    """the output b0 image. """
    dkt: OutputPathType | None
    """the output dkt image. """
    predicted_signal: OutputPathType | None
    """the predicted dwi image. """


def dwi2tensor_params(
    dwi: InputPathType,
    dt: str,
    ols: bool = False,
    mask: InputPathType | None = None,
    b0: str | None = None,
    dkt: str | None = None,
    iter_: int | None = None,
    predicted_signal: str | None = None,
    grad: InputPathType | None = None,
    fslgrad: Dwi2tensorFslgradParamsDict | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Dwi2tensorConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
) -> Dwi2tensorParamsDictTagged:
    """
    Build parameters.
    
    Args:
        dwi: the input dwi image.
        dt: the output dt image.
        ols: perform initial fit using an ordinary least-squares (OLS) fit (see\
            Description).
        mask: only perform computation within the specified binary brain mask\
            image.
        b0: the output b0 image.
        dkt: the output dkt image.
        iter_: number of iterative reweightings for IWLS algorithm (default: 2)\
            (see Description).
        predicted_signal: the predicted dwi image.
        grad: Provide the diffusion-weighted gradient scheme used in the\
            acquisition in a text file. This should be supplied as a 4xN text file\
            with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
            the direction of the applied gradient, and b gives the b-value in units\
            of s/mm^2. If a diffusion gradient scheme is present in the input image\
            header, the data provided with this option will be instead used.
        fslgrad: Provide the diffusion-weighted gradient scheme used in the\
            acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
            scheme is present in the input image header, the data provided with\
            this option will be instead used.
        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/dwi2tensor",
        "ols": ols,
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "dwi": dwi,
        "dt": dt,
    }
    if mask is not None:
        params["mask"] = mask
    if b0 is not None:
        params["b0"] = b0
    if dkt is not None:
        params["dkt"] = dkt
    if iter_ is not None:
        params["iter"] = iter_
    if predicted_signal is not None:
        params["predicted_signal"] = predicted_signal
    if grad is not None:
        params["grad"] = grad
    if fslgrad is not None:
        params["fslgrad"] = fslgrad
    if nthreads is not None:
        params["nthreads"] = nthreads
    if config is not None:
        params["config"] = config
    return params


def dwi2tensor_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `Dwi2tensorParamsDict` 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("ols", False) is None:
        raise StyxValidationError("`ols` must not be None")
    if not isinstance(params["ols"], bool):
        raise StyxValidationError(f'`ols` has the wrong type: Received `{type(params.get("ols", False))}` expected `bool`')
    if params.get("mask", None) is not 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 | None`')
    if params.get("b0", None) is not None:
        if not isinstance(params["b0"], str):
            raise StyxValidationError(f'`b0` has the wrong type: Received `{type(params.get("b0", None))}` expected `str | None`')
    if params.get("dkt", None) is not None:
        if not isinstance(params["dkt"], str):
            raise StyxValidationError(f'`dkt` has the wrong type: Received `{type(params.get("dkt", None))}` expected `str | None`')
    if params.get("iter", None) is not None:
        if not isinstance(params["iter"], int):
            raise StyxValidationError(f'`iter` has the wrong type: Received `{type(params.get("iter", None))}` expected `int | None`')
    if params.get("predicted_signal", None) is not None:
        if not isinstance(params["predicted_signal"], str):
            raise StyxValidationError(f'`predicted_signal` has the wrong type: Received `{type(params.get("predicted_signal", None))}` expected `str | None`')
    if params.get("grad", None) is not None:
        if not isinstance(params["grad"], (pathlib.Path, str)):
            raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
    if params.get("fslgrad", None) is not None:
        dwi2tensor_fslgrad_validate(params["fslgrad"])
    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[Dwi2tensorConfigParamsDict] | None`')
        for e in params["config"]:
            dwi2tensor_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("dwi", None) is None:
        raise StyxValidationError("`dwi` must not be None")
    if not isinstance(params["dwi"], (pathlib.Path, str)):
        raise StyxValidationError(f'`dwi` has the wrong type: Received `{type(params.get("dwi", None))}` expected `InputPathType`')
    if params.get("dt", None) is None:
        raise StyxValidationError("`dt` must not be None")
    if not isinstance(params["dt"], str):
        raise StyxValidationError(f'`dt` has the wrong type: Received `{type(params.get("dt", None))}` expected `str`')


def dwi2tensor_cargs(
    params: Dwi2tensorParamsDict,
    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("dwi2tensor")
    if params.get("ols", False):
        cargs.append("-ols")
    if params.get("mask", None) is not None:
        cargs.extend([
            "-mask",
            execution.input_file(params.get("mask", None))
        ])
    if params.get("b0", None) is not None:
        cargs.extend([
            "-b0",
            params.get("b0", None)
        ])
    if params.get("dkt", None) is not None:
        cargs.extend([
            "-dkt",
            params.get("dkt", None)
        ])
    if params.get("iter", None) is not None:
        cargs.extend([
            "-iter",
            str(params.get("iter", None))
        ])
    if params.get("predicted_signal", None) is not None:
        cargs.extend([
            "-predicted_signal",
            params.get("predicted_signal", None)
        ])
    if params.get("grad", None) is not None:
        cargs.extend([
            "-grad",
            execution.input_file(params.get("grad", None))
        ])
    if params.get("fslgrad", None) is not None:
        cargs.extend(dwi2tensor_fslgrad_cargs(params.get("fslgrad", None), execution))
    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 [dwi2tensor_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("dwi", None)))
    cargs.append(params.get("dt", None))
    return cargs


def dwi2tensor_outputs(
    params: Dwi2tensorParamsDict,
    execution: Execution,
) -> Dwi2tensorOutputs:
    """
    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 = Dwi2tensorOutputs(
        root=execution.output_file("."),
        dt=execution.output_file(params.get("dt", None)),
        b0=execution.output_file(params.get("b0", None)) if (params.get("b0") is not None) else None,
        dkt=execution.output_file(params.get("dkt", None)) if (params.get("dkt") is not None) else None,
        predicted_signal=execution.output_file(params.get("predicted_signal", None)) if (params.get("predicted_signal") is not None) else None,
    )
    return ret


def dwi2tensor_execute(
    params: Dwi2tensorParamsDict,
    runner: Runner | None = None,
) -> Dwi2tensorOutputs:
    """
    dwi2tensor
    
    Diffusion (kurtosis) tensor estimation.
    
    By default, the diffusion tensor (and optionally its kurtosis) is fitted to
    the log-signal in two steps: firstly, using weighted least-squares (WLS)
    with weights based on the empirical signal intensities; secondly, by further
    iterated weighted least-squares (IWLS) with weights determined by the signal
    predictions from the previous iteration (by default, 2 iterations will be
    performed). This behaviour can be altered in two ways:
    
    * The -ols option will cause the first fitting step to be performed using
    ordinary least-squares (OLS); that is, all measurements contribute equally
    to the fit, instead of the default behaviour of weighting based on the
    empirical signal intensities.
    
    * The -iter option controls the number of iterations of the IWLS prodedure.
    If this is set to zero, then the output model parameters will be those
    resulting from the first fitting step only: either WLS by default, or OLS if
    the -ols option is used in conjunction with -iter 0.
    
    The tensor coefficients are stored in the output image as follows:
    volumes 0-5: D11, D22, D33, D12, D13, D23
    
    If diffusion kurtosis is estimated using the -dkt option, these are stored
    as follows:
    volumes 0-2: W1111, W2222, W3333
    volumes 3-8: W1112, W1113, W1222, W1333, W2223, W2333
    volumes 9-11: W1122, W1133, W2233
    volumes 12-14: W1123, W1223, W1233
    
    References:
    
    References based on fitting algorithm used:
    
    * OLS, WLS:
    Basser, P.J.; Mattiello, J.; LeBihan, D. Estimation of the effective
    self-diffusion tensor from the NMR spin echo. J Magn Reson B., 1994, 103,
    247â€“254.
    
    * IWLS:
    Veraart, J.; Sijbers, J.; Sunaert, S.; Leemans, A. & Jeurissen, B. Weighted
    linear least squares estimation of diffusion MRI parameters: strengths,
    limitations, and pitfalls. NeuroImage, 2013, 81, 335-346.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Dwi2tensorOutputs`).
    """
    dwi2tensor_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(DWI2TENSOR_METADATA)
    params = execution.params(params)
    cargs = dwi2tensor_cargs(params, execution)
    ret = dwi2tensor_outputs(params, execution)
    execution.run(cargs)
    return ret


def dwi2tensor(
    dwi: InputPathType,
    dt: str,
    ols: bool = False,
    mask: InputPathType | None = None,
    b0: str | None = None,
    dkt: str | None = None,
    iter_: int | None = None,
    predicted_signal: str | None = None,
    grad: InputPathType | None = None,
    fslgrad: Dwi2tensorFslgradParamsDict | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Dwi2tensorConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> Dwi2tensorOutputs:
    """
    dwi2tensor
    
    Diffusion (kurtosis) tensor estimation.
    
    By default, the diffusion tensor (and optionally its kurtosis) is fitted to
    the log-signal in two steps: firstly, using weighted least-squares (WLS)
    with weights based on the empirical signal intensities; secondly, by further
    iterated weighted least-squares (IWLS) with weights determined by the signal
    predictions from the previous iteration (by default, 2 iterations will be
    performed). This behaviour can be altered in two ways:
    
    * The -ols option will cause the first fitting step to be performed using
    ordinary least-squares (OLS); that is, all measurements contribute equally
    to the fit, instead of the default behaviour of weighting based on the
    empirical signal intensities.
    
    * The -iter option controls the number of iterations of the IWLS prodedure.
    If this is set to zero, then the output model parameters will be those
    resulting from the first fitting step only: either WLS by default, or OLS if
    the -ols option is used in conjunction with -iter 0.
    
    The tensor coefficients are stored in the output image as follows:
    volumes 0-5: D11, D22, D33, D12, D13, D23
    
    If diffusion kurtosis is estimated using the -dkt option, these are stored
    as follows:
    volumes 0-2: W1111, W2222, W3333
    volumes 3-8: W1112, W1113, W1222, W1333, W2223, W2333
    volumes 9-11: W1122, W1133, W2233
    volumes 12-14: W1123, W1223, W1233
    
    References:
    
    References based on fitting algorithm used:
    
    * OLS, WLS:
    Basser, P.J.; Mattiello, J.; LeBihan, D. Estimation of the effective
    self-diffusion tensor from the NMR spin echo. J Magn Reson B., 1994, 103,
    247â€“254.
    
    * IWLS:
    Veraart, J.; Sijbers, J.; Sunaert, S.; Leemans, A. & Jeurissen, B. Weighted
    linear least squares estimation of diffusion MRI parameters: strengths,
    limitations, and pitfalls. NeuroImage, 2013, 81, 335-346.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        dwi: the input dwi image.
        dt: the output dt image.
        ols: perform initial fit using an ordinary least-squares (OLS) fit (see\
            Description).
        mask: only perform computation within the specified binary brain mask\
            image.
        b0: the output b0 image.
        dkt: the output dkt image.
        iter_: number of iterative reweightings for IWLS algorithm (default: 2)\
            (see Description).
        predicted_signal: the predicted dwi image.
        grad: Provide the diffusion-weighted gradient scheme used in the\
            acquisition in a text file. This should be supplied as a 4xN text file\
            with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
            the direction of the applied gradient, and b gives the b-value in units\
            of s/mm^2. If a diffusion gradient scheme is present in the input image\
            header, the data provided with this option will be instead used.
        fslgrad: Provide the diffusion-weighted gradient scheme used in the\
            acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
            scheme is present in the input image header, the data provided with\
            this option will be instead used.
        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 `Dwi2tensorOutputs`).
    """
    params = dwi2tensor_params(
        ols=ols,
        mask=mask,
        b0=b0,
        dkt=dkt,
        iter_=iter_,
        predicted_signal=predicted_signal,
        grad=grad,
        fslgrad=fslgrad,
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        dwi=dwi,
        dt=dt,
    )
    return dwi2tensor_execute(params, runner)


__all__ = [
    "DWI2TENSOR_METADATA",
    "Dwi2tensorConfigParamsDict",
    "Dwi2tensorConfigParamsDictTagged",
    "Dwi2tensorFslgradParamsDict",
    "Dwi2tensorFslgradParamsDictTagged",
    "Dwi2tensorOutputs",
    "Dwi2tensorParamsDict",
    "Dwi2tensorParamsDictTagged",
    "dwi2tensor",
    "dwi2tensor_config",
    "dwi2tensor_execute",
    "dwi2tensor_fslgrad",
    "dwi2tensor_params",
]
