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

import typing
import pathlib
from styxdefs import *

SH2AMP_METADATA = Metadata(
    id="845bbdcb825f577d4f4e931e8e0dd0e1f1f2de94.boutiques",
    name="sh2amp",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


_Sh2ampFslgradParamsDictNoTag = typing.TypedDict('_Sh2ampFslgradParamsDictNoTag', {
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
Sh2ampFslgradParamsDictTagged = typing.TypedDict('Sh2ampFslgradParamsDictTagged', {
    "@type": typing.Literal["fslgrad"],
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
Sh2ampFslgradParamsDict = _Sh2ampFslgradParamsDictNoTag | Sh2ampFslgradParamsDictTagged


_Sh2ampVariousStringParamsDictNoTag = typing.TypedDict('_Sh2ampVariousStringParamsDictNoTag', {
    "obj": str,
})
Sh2ampVariousStringParamsDictTagged = typing.TypedDict('Sh2ampVariousStringParamsDictTagged', {
    "@type": typing.Literal["VariousString"],
    "obj": str,
})
Sh2ampVariousStringParamsDict = _Sh2ampVariousStringParamsDictNoTag | Sh2ampVariousStringParamsDictTagged


_Sh2ampVariousFileParamsDictNoTag = typing.TypedDict('_Sh2ampVariousFileParamsDictNoTag', {
    "obj": InputPathType,
})
Sh2ampVariousFileParamsDictTagged = typing.TypedDict('Sh2ampVariousFileParamsDictTagged', {
    "@type": typing.Literal["VariousFile"],
    "obj": InputPathType,
})
Sh2ampVariousFileParamsDict = _Sh2ampVariousFileParamsDictNoTag | Sh2ampVariousFileParamsDictTagged


_Sh2ampConfigParamsDictNoTag = typing.TypedDict('_Sh2ampConfigParamsDictNoTag', {
    "key": str,
    "value": str,
})
Sh2ampConfigParamsDictTagged = typing.TypedDict('Sh2ampConfigParamsDictTagged', {
    "@type": typing.Literal["config"],
    "key": str,
    "value": str,
})
Sh2ampConfigParamsDict = _Sh2ampConfigParamsDictNoTag | Sh2ampConfigParamsDictTagged


_Sh2ampParamsDictNoTag = typing.TypedDict('_Sh2ampParamsDictNoTag', {
    "nonnegative": bool,
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[Sh2ampFslgradParamsDict | None],
    "strides": typing.NotRequired[typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None],
    "datatype": typing.NotRequired[str | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Sh2ampConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "input": InputPathType,
    "directions": InputPathType,
    "output": str,
})
Sh2ampParamsDictTagged = typing.TypedDict('Sh2ampParamsDictTagged', {
    "@type": typing.Literal["mrtrix/sh2amp"],
    "nonnegative": bool,
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[Sh2ampFslgradParamsDict | None],
    "strides": typing.NotRequired[typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None],
    "datatype": typing.NotRequired[str | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[Sh2ampConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "input": InputPathType,
    "directions": InputPathType,
    "output": str,
})
Sh2ampParamsDict = _Sh2ampParamsDictNoTag | Sh2ampParamsDictTagged


def sh2amp_strides_cargs_dyn_fn(
    t: str,
) -> typing.Any:
    """
    Get build cargs function by command type.
    
    Args:
        t: Command type.
    Returns:
        Build cargs function.
    """
    return {
        "VariousString": sh2amp_various_string_cargs,
        "VariousFile": sh2amp_various_file_cargs,
    }.get(t)


def sh2amp_strides_validate_dyn_fn(
    t: str,
) -> typing.Any:
    """
    Get validate params function by command type.
    
    Args:
        t: Command type.
    Returns:
        Validate params function.
    """
    return {
        "VariousString": sh2amp_various_string_validate,
        "VariousFile": sh2amp_various_file_validate,
    }.get(t)


def sh2amp_fslgrad(
    bvecs: InputPathType,
    bvals: InputPathType,
) -> Sh2ampFslgradParamsDictTagged:
    """
    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 sh2amp_fslgrad_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `Sh2ampFslgradParamsDict` 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 sh2amp_fslgrad_cargs(
    params: Sh2ampFslgradParamsDict,
    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 sh2amp_various_string(
    obj: str,
) -> Sh2ampVariousStringParamsDictTagged:
    """
    Build parameters.
    
    Args:
        obj: String object.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "VariousString",
        "obj": obj,
    }
    return params


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


def sh2amp_various_string_cargs(
    params: Sh2ampVariousStringParamsDict,
    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(params.get("obj", None))
    return cargs


def sh2amp_various_file(
    obj: InputPathType,
) -> Sh2ampVariousFileParamsDictTagged:
    """
    Build parameters.
    
    Args:
        obj: File object.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "VariousFile",
        "obj": obj,
    }
    return params


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


def sh2amp_various_file_cargs(
    params: Sh2ampVariousFileParamsDict,
    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("obj", None)))
    return cargs


def sh2amp_config(
    key: str,
    value: str,
) -> Sh2ampConfigParamsDictTagged:
    """
    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 sh2amp_config_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `Sh2ampConfigParamsDict` 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 sh2amp_config_cargs(
    params: Sh2ampConfigParamsDict,
    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 Sh2ampOutputs(typing.NamedTuple):
    """
    Output object returned when calling `Sh2ampParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output: OutputPathType
    """the output image consisting of the amplitude of the SH functions along
    the specified directions."""


def sh2amp_params(
    input_: InputPathType,
    directions: InputPathType,
    output: str,
    nonnegative: bool = False,
    grad: InputPathType | None = None,
    fslgrad: Sh2ampFslgradParamsDict | None = None,
    strides: typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None = None,
    datatype: str | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Sh2ampConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
) -> Sh2ampParamsDictTagged:
    """
    Build parameters.
    
    Args:
        input_: the input image consisting of spherical harmonic (SH)\
            coefficients.
        directions: the list of directions along which the SH functions will be\
            sampled, generated using the dirgen command.
        output: the output image consisting of the amplitude of the SH\
            functions along the specified directions.
        nonnegative: cap all negative amplitudes to zero.
        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.
        strides: specify the strides of the output data in memory; either as a\
            comma-separated list of (signed) integers, or as a template image from\
            which the strides shall be extracted and used. The actual strides\
            produced will depend on whether the output image format can support it.
        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/sh2amp",
        "nonnegative": nonnegative,
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "input": input_,
        "directions": directions,
        "output": output,
    }
    if grad is not None:
        params["grad"] = grad
    if fslgrad is not None:
        params["fslgrad"] = fslgrad
    if strides is not None:
        params["strides"] = strides
    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 sh2amp_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `Sh2ampParamsDict` 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("nonnegative", False) is None:
        raise StyxValidationError("`nonnegative` must not be None")
    if not isinstance(params["nonnegative"], bool):
        raise StyxValidationError(f'`nonnegative` has the wrong type: Received `{type(params.get("nonnegative", False))}` expected `bool`')
    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:
        sh2amp_fslgrad_validate(params["fslgrad"])
    if params.get("strides", None) is not None:
        if not isinstance(params["strides"], dict):
            raise StyxValidationError(f'Params object has the wrong type \'{type(params["strides"])}\'')
        if "@type" not in params["strides"]:
            raise StyxValidationError("Params object is missing `@type`")
        if params["strides"]["@type"] not in ["VariousString", "VariousFile"]:
            raise StyxValidationError("Parameter `strides`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
        sh2amp_strides_validate_dyn_fn(params["strides"]["@type"])(params["strides"])
    if params.get("datatype", None) is not None:
        if not isinstance(params["datatype"], str):
            raise StyxValidationError(f'`datatype` has the wrong type: Received `{type(params.get("datatype", 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[Sh2ampConfigParamsDict] | None`')
        for e in params["config"]:
            sh2amp_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", 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("directions", None) is None:
        raise StyxValidationError("`directions` must not be None")
    if not isinstance(params["directions"], (pathlib.Path, str)):
        raise StyxValidationError(f'`directions` has the wrong type: Received `{type(params.get("directions", 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 sh2amp_cargs(
    params: Sh2ampParamsDict,
    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("sh2amp")
    if params.get("nonnegative", False):
        cargs.append("-nonnegative")
    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(sh2amp_fslgrad_cargs(params.get("fslgrad", None), execution))
    if params.get("strides", None) is not None:
        cargs.extend([
            "-strides",
            *sh2amp_strides_cargs_dyn_fn(params.get("strides", None)["@type"])(params.get("strides", None), execution)
        ])
    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 [sh2amp_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("input", None)))
    cargs.append(execution.input_file(params.get("directions", None)))
    cargs.append(params.get("output", None))
    return cargs


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


def sh2amp_execute(
    params: Sh2ampParamsDict,
    runner: Runner | None = None,
) -> Sh2ampOutputs:
    """
    sh2amp
    
    Evaluate the amplitude of an image of spherical harmonic functions along
    specified directions.
    
    The input image should consist of a 4D or 5D image, with SH coefficients
    along the 4th dimension according to the convention below. If 4D (or size 1
    along the 5th dimension), the program expects to be provided with a single
    shell of directions. If 5D, each set of coefficients along the 5th dimension
    is understood to correspond to a different shell.
    
    The directions can be provided as:
    - a 2-column ASCII text file contained azimuth / elevation pairs (as
    produced by dirgen)
    - a 3-column ASCII text file containing x, y, z Cartesian direction vectors
    (as produced by dirgen -cart)
    - a 4-column ASCII text file containing the x, y, z, b components of a full
    DW encoding scheme (in MRtrix format, see main documentation for details).
    - an image file whose header contains a valid DW encoding scheme
    
    If a full DW encoding is provided, the number of shells needs to match those
    found in the input image of coefficients (i.e. its size along the 5th
    dimension). If needed, the -shell option can be used to pick out the
    specific shell(s) of interest.
    
    If the input image contains multiple shells (its size along the 5th
    dimension is greater than one), the program will expect the direction set to
    contain multiple shells, which can only be provided as a full DW encodings
    (the last two options in the list above).
    
    The spherical harmonic coefficients are stored according the conventions
    described the main documentation, which can be found at the following link:
    https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Sh2ampOutputs`).
    """
    sh2amp_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(SH2AMP_METADATA)
    params = execution.params(params)
    cargs = sh2amp_cargs(params, execution)
    ret = sh2amp_outputs(params, execution)
    execution.run(cargs)
    return ret


def sh2amp(
    input_: InputPathType,
    directions: InputPathType,
    output: str,
    nonnegative: bool = False,
    grad: InputPathType | None = None,
    fslgrad: Sh2ampFslgradParamsDict | None = None,
    strides: typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None = None,
    datatype: str | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Sh2ampConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> Sh2ampOutputs:
    """
    sh2amp
    
    Evaluate the amplitude of an image of spherical harmonic functions along
    specified directions.
    
    The input image should consist of a 4D or 5D image, with SH coefficients
    along the 4th dimension according to the convention below. If 4D (or size 1
    along the 5th dimension), the program expects to be provided with a single
    shell of directions. If 5D, each set of coefficients along the 5th dimension
    is understood to correspond to a different shell.
    
    The directions can be provided as:
    - a 2-column ASCII text file contained azimuth / elevation pairs (as
    produced by dirgen)
    - a 3-column ASCII text file containing x, y, z Cartesian direction vectors
    (as produced by dirgen -cart)
    - a 4-column ASCII text file containing the x, y, z, b components of a full
    DW encoding scheme (in MRtrix format, see main documentation for details).
    - an image file whose header contains a valid DW encoding scheme
    
    If a full DW encoding is provided, the number of shells needs to match those
    found in the input image of coefficients (i.e. its size along the 5th
    dimension). If needed, the -shell option can be used to pick out the
    specific shell(s) of interest.
    
    If the input image contains multiple shells (its size along the 5th
    dimension is greater than one), the program will expect the direction set to
    contain multiple shells, which can only be provided as a full DW encodings
    (the last two options in the list above).
    
    The spherical harmonic coefficients are stored according the conventions
    described the main documentation, which can be found at the following link:
    https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        input_: the input image consisting of spherical harmonic (SH)\
            coefficients.
        directions: the list of directions along which the SH functions will be\
            sampled, generated using the dirgen command.
        output: the output image consisting of the amplitude of the SH\
            functions along the specified directions.
        nonnegative: cap all negative amplitudes to zero.
        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.
        strides: specify the strides of the output data in memory; either as a\
            comma-separated list of (signed) integers, or as a template image from\
            which the strides shall be extracted and used. The actual strides\
            produced will depend on whether the output image format can support it.
        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 `Sh2ampOutputs`).
    """
    params = sh2amp_params(
        nonnegative=nonnegative,
        grad=grad,
        fslgrad=fslgrad,
        strides=strides,
        datatype=datatype,
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        input_=input_,
        directions=directions,
        output=output,
    )
    return sh2amp_execute(params, runner)


__all__ = [
    "SH2AMP_METADATA",
    "Sh2ampConfigParamsDict",
    "Sh2ampConfigParamsDictTagged",
    "Sh2ampFslgradParamsDict",
    "Sh2ampFslgradParamsDictTagged",
    "Sh2ampOutputs",
    "Sh2ampParamsDict",
    "Sh2ampParamsDictTagged",
    "Sh2ampVariousFileParamsDict",
    "Sh2ampVariousFileParamsDictTagged",
    "Sh2ampVariousStringParamsDict",
    "Sh2ampVariousStringParamsDictTagged",
    "sh2amp",
    "sh2amp_config",
    "sh2amp_execute",
    "sh2amp_fslgrad",
    "sh2amp_params",
    "sh2amp_various_file",
    "sh2amp_various_string",
]
