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

import typing
import pathlib
from styxdefs import *

MRINFO_METADATA = Metadata(
    id="8282cf2096dd2c6c171488cc71738cd947e2697c.boutiques",
    name="mrinfo",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


_MrinfoPropertyParamsDictNoTag = typing.TypedDict('_MrinfoPropertyParamsDictNoTag', {
    "key": str,
})
MrinfoPropertyParamsDictTagged = typing.TypedDict('MrinfoPropertyParamsDictTagged', {
    "@type": typing.Literal["property"],
    "key": str,
})
MrinfoPropertyParamsDict = _MrinfoPropertyParamsDictNoTag | MrinfoPropertyParamsDictTagged


_MrinfoFslgradParamsDictNoTag = typing.TypedDict('_MrinfoFslgradParamsDictNoTag', {
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
MrinfoFslgradParamsDictTagged = typing.TypedDict('MrinfoFslgradParamsDictTagged', {
    "@type": typing.Literal["fslgrad"],
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
MrinfoFslgradParamsDict = _MrinfoFslgradParamsDictNoTag | MrinfoFslgradParamsDictTagged


_MrinfoExportGradFslParamsDictNoTag = typing.TypedDict('_MrinfoExportGradFslParamsDictNoTag', {
    "bvecs_path": str,
    "bvals_path": str,
})
MrinfoExportGradFslParamsDictTagged = typing.TypedDict('MrinfoExportGradFslParamsDictTagged', {
    "@type": typing.Literal["export_grad_fsl"],
    "bvecs_path": str,
    "bvals_path": str,
})
MrinfoExportGradFslParamsDict = _MrinfoExportGradFslParamsDictNoTag | MrinfoExportGradFslParamsDictTagged


_MrinfoExportPeEddyParamsDictNoTag = typing.TypedDict('_MrinfoExportPeEddyParamsDictNoTag', {
    "config": str,
    "indices": str,
})
MrinfoExportPeEddyParamsDictTagged = typing.TypedDict('MrinfoExportPeEddyParamsDictTagged', {
    "@type": typing.Literal["export_pe_eddy"],
    "config": str,
    "indices": str,
})
MrinfoExportPeEddyParamsDict = _MrinfoExportPeEddyParamsDictNoTag | MrinfoExportPeEddyParamsDictTagged


_MrinfoConfigParamsDictNoTag = typing.TypedDict('_MrinfoConfigParamsDictNoTag', {
    "key": str,
    "value": str,
})
MrinfoConfigParamsDictTagged = typing.TypedDict('MrinfoConfigParamsDictTagged', {
    "@type": typing.Literal["config"],
    "key": str,
    "value": str,
})
MrinfoConfigParamsDict = _MrinfoConfigParamsDictNoTag | MrinfoConfigParamsDictTagged


_MrinfoParamsDictNoTag = typing.TypedDict('_MrinfoParamsDictNoTag', {
    "all": bool,
    "name": bool,
    "format": bool,
    "ndim": bool,
    "size": bool,
    "spacing": bool,
    "datatype": bool,
    "strides": bool,
    "offset": bool,
    "multiplier": bool,
    "transform": bool,
    "property": typing.NotRequired[list[MrinfoPropertyParamsDict] | None],
    "json_keyval": typing.NotRequired[str | None],
    "json_all": typing.NotRequired[str | None],
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[MrinfoFslgradParamsDict | None],
    "bvalue_scaling": typing.NotRequired[str | None],
    "export_grad_mrtrix": typing.NotRequired[str | None],
    "export_grad_fsl": typing.NotRequired[MrinfoExportGradFslParamsDict | None],
    "dwgrad": bool,
    "shell_bvalues": bool,
    "shell_sizes": bool,
    "shell_indices": bool,
    "export_pe_table": typing.NotRequired[str | None],
    "export_pe_eddy": typing.NotRequired[MrinfoExportPeEddyParamsDict | None],
    "petable": bool,
    "nodelete": bool,
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MrinfoConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "image": list[InputPathType],
})
MrinfoParamsDictTagged = typing.TypedDict('MrinfoParamsDictTagged', {
    "@type": typing.Literal["mrtrix/mrinfo"],
    "all": bool,
    "name": bool,
    "format": bool,
    "ndim": bool,
    "size": bool,
    "spacing": bool,
    "datatype": bool,
    "strides": bool,
    "offset": bool,
    "multiplier": bool,
    "transform": bool,
    "property": typing.NotRequired[list[MrinfoPropertyParamsDict] | None],
    "json_keyval": typing.NotRequired[str | None],
    "json_all": typing.NotRequired[str | None],
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[MrinfoFslgradParamsDict | None],
    "bvalue_scaling": typing.NotRequired[str | None],
    "export_grad_mrtrix": typing.NotRequired[str | None],
    "export_grad_fsl": typing.NotRequired[MrinfoExportGradFslParamsDict | None],
    "dwgrad": bool,
    "shell_bvalues": bool,
    "shell_sizes": bool,
    "shell_indices": bool,
    "export_pe_table": typing.NotRequired[str | None],
    "export_pe_eddy": typing.NotRequired[MrinfoExportPeEddyParamsDict | None],
    "petable": bool,
    "nodelete": bool,
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MrinfoConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "image": list[InputPathType],
})
MrinfoParamsDict = _MrinfoParamsDictNoTag | MrinfoParamsDictTagged


def mrinfo_property(
    key: str,
) -> MrinfoPropertyParamsDictTagged:
    """
    Build parameters.
    
    Args:
        key: any text properties embedded in the image header under the\
            specified key (use 'all' to list all keys found).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "property",
        "key": key,
    }
    return params


def mrinfo_property_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrinfoPropertyParamsDict` 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`')


def mrinfo_property_cargs(
    params: MrinfoPropertyParamsDict,
    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("-property")
    cargs.append(params.get("key", None))
    return cargs


def mrinfo_fslgrad(
    bvecs: InputPathType,
    bvals: InputPathType,
) -> MrinfoFslgradParamsDictTagged:
    """
    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 mrinfo_fslgrad_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrinfoFslgradParamsDict` 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 mrinfo_fslgrad_cargs(
    params: MrinfoFslgradParamsDict,
    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


class MrinfoExportGradFslOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MrinfoExportGradFslParamsDict | None(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    bvecs_path: OutputPathType
    """export the diffusion-weighted gradient table to files in FSL (bvecs /
    bvals) format"""
    bvals_path: OutputPathType
    """export the diffusion-weighted gradient table to files in FSL (bvecs /
    bvals) format"""


def mrinfo_export_grad_fsl(
    bvecs_path: str,
    bvals_path: str,
) -> MrinfoExportGradFslParamsDictTagged:
    """
    Build parameters.
    
    Args:
        bvecs_path: export the diffusion-weighted gradient table to files in\
            FSL (bvecs / bvals) format.
        bvals_path: export the diffusion-weighted gradient table to files in\
            FSL (bvecs / bvals) format.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "export_grad_fsl",
        "bvecs_path": bvecs_path,
        "bvals_path": bvals_path,
    }
    return params


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


def mrinfo_export_grad_fsl_cargs(
    params: MrinfoExportGradFslParamsDict,
    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("-export_grad_fsl")
    cargs.append(params.get("bvecs_path", None))
    cargs.append(params.get("bvals_path", None))
    return cargs


def mrinfo_export_grad_fsl_outputs(
    params: MrinfoExportGradFslParamsDict,
    execution: Execution,
) -> MrinfoExportGradFslOutputs:
    """
    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 = MrinfoExportGradFslOutputs(
        root=execution.output_file("."),
        bvecs_path=execution.output_file(params.get("bvecs_path", None)),
        bvals_path=execution.output_file(params.get("bvals_path", None)),
    )
    return ret


class MrinfoExportPeEddyOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MrinfoExportPeEddyParamsDict | None(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    config: OutputPathType
    """export phase-encoding information to an EDDY-style config / index file
    pair"""
    indices: OutputPathType
    """export phase-encoding information to an EDDY-style config / index file
    pair"""


def mrinfo_export_pe_eddy(
    config: str,
    indices: str,
) -> MrinfoExportPeEddyParamsDictTagged:
    """
    Build parameters.
    
    Args:
        config: export phase-encoding information to an EDDY-style config /\
            index file pair.
        indices: export phase-encoding information to an EDDY-style config /\
            index file pair.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "export_pe_eddy",
        "config": config,
        "indices": indices,
    }
    return params


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


def mrinfo_export_pe_eddy_cargs(
    params: MrinfoExportPeEddyParamsDict,
    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("-export_pe_eddy")
    cargs.append(params.get("config", None))
    cargs.append(params.get("indices", None))
    return cargs


def mrinfo_export_pe_eddy_outputs(
    params: MrinfoExportPeEddyParamsDict,
    execution: Execution,
) -> MrinfoExportPeEddyOutputs:
    """
    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 = MrinfoExportPeEddyOutputs(
        root=execution.output_file("."),
        config=execution.output_file(params.get("config", None)),
        indices=execution.output_file(params.get("indices", None)),
    )
    return ret


def mrinfo_config(
    key: str,
    value: str,
) -> MrinfoConfigParamsDictTagged:
    """
    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 mrinfo_config_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrinfoConfigParamsDict` 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 mrinfo_config_cargs(
    params: MrinfoConfigParamsDict,
    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 MrinfoOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MrinfoParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    json_keyval: OutputPathType | None
    """export header key/value entries to a JSON file """
    json_all: OutputPathType | None
    """export all header contents to a JSON file """
    export_grad_mrtrix: OutputPathType | None
    """export the diffusion-weighted gradient table to file in MRtrix format """
    export_pe_table: OutputPathType | None
    """export phase-encoding table to file """
    export_grad_fsl: MrinfoExportGradFslOutputs | None
    """Outputs from `mrinfo_export_grad_fsl_outputs`."""
    export_pe_eddy: MrinfoExportPeEddyOutputs | None
    """Outputs from `mrinfo_export_pe_eddy_outputs`."""


def mrinfo_params(
    image: list[InputPathType],
    all_: bool = False,
    name: bool = False,
    format_: bool = False,
    ndim: bool = False,
    size: bool = False,
    spacing: bool = False,
    datatype: bool = False,
    strides: bool = False,
    offset: bool = False,
    multiplier: bool = False,
    transform: bool = False,
    property_: list[MrinfoPropertyParamsDict] | None = None,
    json_keyval: str | None = None,
    json_all: str | None = None,
    grad: InputPathType | None = None,
    fslgrad: MrinfoFslgradParamsDict | None = None,
    bvalue_scaling: str | None = None,
    export_grad_mrtrix: str | None = None,
    export_grad_fsl: MrinfoExportGradFslParamsDict | None = None,
    dwgrad: bool = False,
    shell_bvalues: bool = False,
    shell_sizes: bool = False,
    shell_indices: bool = False,
    export_pe_table: str | None = None,
    export_pe_eddy: MrinfoExportPeEddyParamsDict | None = None,
    petable: bool = False,
    nodelete: bool = False,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MrinfoConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
) -> MrinfoParamsDictTagged:
    """
    Build parameters.
    
    Args:
        image: the input image(s).
        all_: print all properties, rather than the first and last 2 of each.
        name: print the file system path of the image.
        format_: image file format.
        ndim: number of image dimensions.
        size: image size along each axis.
        spacing: voxel spacing along each image dimension.
        datatype: data type used for image data storage.
        strides: data strides i.e. order and direction of axes data layout.
        offset: image intensity offset.
        multiplier: image intensity multiplier.
        transform: the transformation from image coordinates [mm] to scanner /\
            real world coordinates [mm].
        property_: any text properties embedded in the image header under the\
            specified key (use 'all' to list all keys found).
        json_keyval: export header key/value entries to a JSON file.
        json_all: export all header contents to a JSON file.
        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.
        bvalue_scaling: enable or disable scaling of diffusion b-values by the\
            square of the corresponding DW gradient norm (see Desciption). Valid\
            choices are yes/no, true/false, 0/1 (default: automatic).
        export_grad_mrtrix: export the diffusion-weighted gradient table to\
            file in MRtrix format.
        export_grad_fsl: export the diffusion-weighted gradient table to files\
            in FSL (bvecs / bvals) format.
        dwgrad: the diffusion-weighting gradient table, as interpreted by\
            MRtrix3.
        shell_bvalues: list the average b-value of each shell.
        shell_sizes: list the number of volumes in each shell.
        shell_indices: list the image volumes attributed to each b-value shell.
        export_pe_table: export phase-encoding table to file.
        export_pe_eddy: export phase-encoding information to an EDDY-style\
            config / index file pair.
        petable: print the phase encoding table.
        nodelete: don't delete temporary images or images passed to mrinfo via\
            Unix pipes.
        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/mrinfo",
        "all": all_,
        "name": name,
        "format": format_,
        "ndim": ndim,
        "size": size,
        "spacing": spacing,
        "datatype": datatype,
        "strides": strides,
        "offset": offset,
        "multiplier": multiplier,
        "transform": transform,
        "dwgrad": dwgrad,
        "shell_bvalues": shell_bvalues,
        "shell_sizes": shell_sizes,
        "shell_indices": shell_indices,
        "petable": petable,
        "nodelete": nodelete,
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "image": image,
    }
    if property_ is not None:
        params["property"] = property_
    if json_keyval is not None:
        params["json_keyval"] = json_keyval
    if json_all is not None:
        params["json_all"] = json_all
    if grad is not None:
        params["grad"] = grad
    if fslgrad is not None:
        params["fslgrad"] = fslgrad
    if bvalue_scaling is not None:
        params["bvalue_scaling"] = bvalue_scaling
    if export_grad_mrtrix is not None:
        params["export_grad_mrtrix"] = export_grad_mrtrix
    if export_grad_fsl is not None:
        params["export_grad_fsl"] = export_grad_fsl
    if export_pe_table is not None:
        params["export_pe_table"] = export_pe_table
    if export_pe_eddy is not None:
        params["export_pe_eddy"] = export_pe_eddy
    if nthreads is not None:
        params["nthreads"] = nthreads
    if config is not None:
        params["config"] = config
    return params


def mrinfo_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrinfoParamsDict` 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("all", False) is None:
        raise StyxValidationError("`all` must not be None")
    if not isinstance(params["all"], bool):
        raise StyxValidationError(f'`all` has the wrong type: Received `{type(params.get("all", False))}` expected `bool`')
    if params.get("name", False) is None:
        raise StyxValidationError("`name` must not be None")
    if not isinstance(params["name"], bool):
        raise StyxValidationError(f'`name` has the wrong type: Received `{type(params.get("name", False))}` expected `bool`')
    if params.get("format", False) is None:
        raise StyxValidationError("`format` must not be None")
    if not isinstance(params["format"], bool):
        raise StyxValidationError(f'`format` has the wrong type: Received `{type(params.get("format", False))}` expected `bool`')
    if params.get("ndim", False) is None:
        raise StyxValidationError("`ndim` must not be None")
    if not isinstance(params["ndim"], bool):
        raise StyxValidationError(f'`ndim` has the wrong type: Received `{type(params.get("ndim", False))}` expected `bool`')
    if params.get("size", False) is None:
        raise StyxValidationError("`size` must not be None")
    if not isinstance(params["size"], bool):
        raise StyxValidationError(f'`size` has the wrong type: Received `{type(params.get("size", False))}` expected `bool`')
    if params.get("spacing", False) is None:
        raise StyxValidationError("`spacing` must not be None")
    if not isinstance(params["spacing"], bool):
        raise StyxValidationError(f'`spacing` has the wrong type: Received `{type(params.get("spacing", False))}` expected `bool`')
    if params.get("datatype", False) is None:
        raise StyxValidationError("`datatype` must not be None")
    if not isinstance(params["datatype"], bool):
        raise StyxValidationError(f'`datatype` has the wrong type: Received `{type(params.get("datatype", False))}` expected `bool`')
    if params.get("strides", False) is None:
        raise StyxValidationError("`strides` must not be None")
    if not isinstance(params["strides"], bool):
        raise StyxValidationError(f'`strides` has the wrong type: Received `{type(params.get("strides", False))}` expected `bool`')
    if params.get("offset", False) is None:
        raise StyxValidationError("`offset` must not be None")
    if not isinstance(params["offset"], bool):
        raise StyxValidationError(f'`offset` has the wrong type: Received `{type(params.get("offset", False))}` expected `bool`')
    if params.get("multiplier", False) is None:
        raise StyxValidationError("`multiplier` must not be None")
    if not isinstance(params["multiplier"], bool):
        raise StyxValidationError(f'`multiplier` has the wrong type: Received `{type(params.get("multiplier", False))}` expected `bool`')
    if params.get("transform", False) is None:
        raise StyxValidationError("`transform` must not be None")
    if not isinstance(params["transform"], bool):
        raise StyxValidationError(f'`transform` has the wrong type: Received `{type(params.get("transform", False))}` expected `bool`')
    if params.get("property", None) is not None:
        if not isinstance(params["property"], list):
            raise StyxValidationError(f'`property` has the wrong type: Received `{type(params.get("property", None))}` expected `list[MrinfoPropertyParamsDict] | None`')
        for e in params["property"]:
            mrinfo_property_validate(e)
    if params.get("json_keyval", None) is not None:
        if not isinstance(params["json_keyval"], str):
            raise StyxValidationError(f'`json_keyval` has the wrong type: Received `{type(params.get("json_keyval", None))}` expected `str | None`')
    if params.get("json_all", None) is not None:
        if not isinstance(params["json_all"], str):
            raise StyxValidationError(f'`json_all` has the wrong type: Received `{type(params.get("json_all", 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:
        mrinfo_fslgrad_validate(params["fslgrad"])
    if params.get("bvalue_scaling", None) is not None:
        if not isinstance(params["bvalue_scaling"], str):
            raise StyxValidationError(f'`bvalue_scaling` has the wrong type: Received `{type(params.get("bvalue_scaling", None))}` expected `str | None`')
    if params.get("export_grad_mrtrix", None) is not None:
        if not isinstance(params["export_grad_mrtrix"], str):
            raise StyxValidationError(f'`export_grad_mrtrix` has the wrong type: Received `{type(params.get("export_grad_mrtrix", None))}` expected `str | None`')
    if params.get("export_grad_fsl", None) is not None:
        mrinfo_export_grad_fsl_validate(params["export_grad_fsl"])
    if params.get("dwgrad", False) is None:
        raise StyxValidationError("`dwgrad` must not be None")
    if not isinstance(params["dwgrad"], bool):
        raise StyxValidationError(f'`dwgrad` has the wrong type: Received `{type(params.get("dwgrad", False))}` expected `bool`')
    if params.get("shell_bvalues", False) is None:
        raise StyxValidationError("`shell_bvalues` must not be None")
    if not isinstance(params["shell_bvalues"], bool):
        raise StyxValidationError(f'`shell_bvalues` has the wrong type: Received `{type(params.get("shell_bvalues", False))}` expected `bool`')
    if params.get("shell_sizes", False) is None:
        raise StyxValidationError("`shell_sizes` must not be None")
    if not isinstance(params["shell_sizes"], bool):
        raise StyxValidationError(f'`shell_sizes` has the wrong type: Received `{type(params.get("shell_sizes", False))}` expected `bool`')
    if params.get("shell_indices", False) is None:
        raise StyxValidationError("`shell_indices` must not be None")
    if not isinstance(params["shell_indices"], bool):
        raise StyxValidationError(f'`shell_indices` has the wrong type: Received `{type(params.get("shell_indices", False))}` expected `bool`')
    if params.get("export_pe_table", None) is not None:
        if not isinstance(params["export_pe_table"], str):
            raise StyxValidationError(f'`export_pe_table` has the wrong type: Received `{type(params.get("export_pe_table", None))}` expected `str | None`')
    if params.get("export_pe_eddy", None) is not None:
        mrinfo_export_pe_eddy_validate(params["export_pe_eddy"])
    if params.get("petable", False) is None:
        raise StyxValidationError("`petable` must not be None")
    if not isinstance(params["petable"], bool):
        raise StyxValidationError(f'`petable` has the wrong type: Received `{type(params.get("petable", False))}` expected `bool`')
    if params.get("nodelete", False) is None:
        raise StyxValidationError("`nodelete` must not be None")
    if not isinstance(params["nodelete"], bool):
        raise StyxValidationError(f'`nodelete` has the wrong type: Received `{type(params.get("nodelete", False))}` expected `bool`')
    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[MrinfoConfigParamsDict] | None`')
        for e in params["config"]:
            mrinfo_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("image", None) is None:
        raise StyxValidationError("`image` must not be None")
    if not isinstance(params["image"], list):
        raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `list[InputPathType]`')
    for e in params["image"]:
        if not isinstance(e, (pathlib.Path, str)):
            raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `list[InputPathType]`')


def mrinfo_cargs(
    params: MrinfoParamsDict,
    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("mrinfo")
    if params.get("all", False):
        cargs.append("-all")
    if params.get("name", False):
        cargs.append("-name")
    if params.get("format", False):
        cargs.append("-format")
    if params.get("ndim", False):
        cargs.append("-ndim")
    if params.get("size", False):
        cargs.append("-size")
    if params.get("spacing", False):
        cargs.append("-spacing")
    if params.get("datatype", False):
        cargs.append("-datatype")
    if params.get("strides", False):
        cargs.append("-strides")
    if params.get("offset", False):
        cargs.append("-offset")
    if params.get("multiplier", False):
        cargs.append("-multiplier")
    if params.get("transform", False):
        cargs.append("-transform")
    if params.get("property", None) is not None:
        cargs.extend([a for c in [mrinfo_property_cargs(s, execution) for s in params.get("property", None)] for a in c])
    if params.get("json_keyval", None) is not None:
        cargs.extend([
            "-json_keyval",
            params.get("json_keyval", None)
        ])
    if params.get("json_all", None) is not None:
        cargs.extend([
            "-json_all",
            params.get("json_all", 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(mrinfo_fslgrad_cargs(params.get("fslgrad", None), execution))
    if params.get("bvalue_scaling", None) is not None:
        cargs.extend([
            "-bvalue_scaling",
            params.get("bvalue_scaling", None)
        ])
    if params.get("export_grad_mrtrix", None) is not None:
        cargs.extend([
            "-export_grad_mrtrix",
            params.get("export_grad_mrtrix", None)
        ])
    if params.get("export_grad_fsl", None) is not None:
        cargs.extend(mrinfo_export_grad_fsl_cargs(params.get("export_grad_fsl", None), execution))
    if params.get("dwgrad", False):
        cargs.append("-dwgrad")
    if params.get("shell_bvalues", False):
        cargs.append("-shell_bvalues")
    if params.get("shell_sizes", False):
        cargs.append("-shell_sizes")
    if params.get("shell_indices", False):
        cargs.append("-shell_indices")
    if params.get("export_pe_table", None) is not None:
        cargs.extend([
            "-export_pe_table",
            params.get("export_pe_table", None)
        ])
    if params.get("export_pe_eddy", None) is not None:
        cargs.extend(mrinfo_export_pe_eddy_cargs(params.get("export_pe_eddy", None), execution))
    if params.get("petable", False):
        cargs.append("-petable")
    if params.get("nodelete", False):
        cargs.append("-nodelete")
    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 [mrinfo_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("image", None)])
    return cargs


def mrinfo_outputs(
    params: MrinfoParamsDict,
    execution: Execution,
) -> MrinfoOutputs:
    """
    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 = MrinfoOutputs(
        root=execution.output_file("."),
        json_keyval=execution.output_file(params.get("json_keyval", None)) if (params.get("json_keyval") is not None) else None,
        json_all=execution.output_file(params.get("json_all", None)) if (params.get("json_all") is not None) else None,
        export_grad_mrtrix=execution.output_file(params.get("export_grad_mrtrix", None)) if (params.get("export_grad_mrtrix") is not None) else None,
        export_pe_table=execution.output_file(params.get("export_pe_table", None)) if (params.get("export_pe_table") is not None) else None,
        export_grad_fsl=mrinfo_export_grad_fsl_outputs(params.get("export_grad_fsl"), execution) if params.get("export_grad_fsl") else None,
        export_pe_eddy=mrinfo_export_pe_eddy_outputs(params.get("export_pe_eddy"), execution) if params.get("export_pe_eddy") else None,
    )
    return ret


def mrinfo_execute(
    params: MrinfoParamsDict,
    runner: Runner | None = None,
) -> MrinfoOutputs:
    """
    mrinfo
    
    Display image header information, or extract specific information from the
    header.
    
    By default, all information contained in each image header will be printed
    to the console in a reader-friendly format.
    
    Alternatively, command-line options may be used to extract specific details
    from the header(s); these are printed to the console in a format more
    appropriate for scripting purposes or piping to file. If multiple options
    and/or images are provided, the requested header fields will be printed in
    the order in which they appear in the help page, with all requested details
    from each input image in sequence printed before the next image is
    processed.
    
    The command can also write the diffusion gradient table from a single input
    image to file; either in the MRtrix or FSL format (bvecs/bvals file pair;
    includes appropriate diffusion gradient vector reorientation)
    
    The -dwgrad, -export_* and -shell_* options provide (information about) the
    diffusion weighting gradient table after it has been processed by the
    MRtrix3 back-end (vectors normalised, b-values scaled by the square of the
    vector norm, depending on the -bvalue_scaling option). To see the raw
    gradient table information as stored in the image header, i.e. without
    MRtrix3 back-end processing, use "-property dw_scheme".
    
    The -bvalue_scaling option controls an aspect of the import of diffusion
    gradient tables. When the input diffusion-weighting direction vectors have
    norms that differ substantially from unity, the b-values will be scaled by
    the square of their corresponding vector norm (this is how multi-shell
    acquisitions are frequently achieved on scanner platforms). However in some
    rare instances, the b-values may be correct, despite the vectors not being
    of unit norm (or conversely, the b-values may need to be rescaled even
    though the vectors are close to unit norm). This option allows the user to
    control this operation and override MRrtix3's automatic detection.
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrinfoOutputs`).
    """
    mrinfo_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRINFO_METADATA)
    params = execution.params(params)
    cargs = mrinfo_cargs(params, execution)
    ret = mrinfo_outputs(params, execution)
    execution.run(cargs)
    return ret


def mrinfo(
    image: list[InputPathType],
    all_: bool = False,
    name: bool = False,
    format_: bool = False,
    ndim: bool = False,
    size: bool = False,
    spacing: bool = False,
    datatype: bool = False,
    strides: bool = False,
    offset: bool = False,
    multiplier: bool = False,
    transform: bool = False,
    property_: list[MrinfoPropertyParamsDict] | None = None,
    json_keyval: str | None = None,
    json_all: str | None = None,
    grad: InputPathType | None = None,
    fslgrad: MrinfoFslgradParamsDict | None = None,
    bvalue_scaling: str | None = None,
    export_grad_mrtrix: str | None = None,
    export_grad_fsl: MrinfoExportGradFslParamsDict | None = None,
    dwgrad: bool = False,
    shell_bvalues: bool = False,
    shell_sizes: bool = False,
    shell_indices: bool = False,
    export_pe_table: str | None = None,
    export_pe_eddy: MrinfoExportPeEddyParamsDict | None = None,
    petable: bool = False,
    nodelete: bool = False,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MrinfoConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> MrinfoOutputs:
    """
    mrinfo
    
    Display image header information, or extract specific information from the
    header.
    
    By default, all information contained in each image header will be printed
    to the console in a reader-friendly format.
    
    Alternatively, command-line options may be used to extract specific details
    from the header(s); these are printed to the console in a format more
    appropriate for scripting purposes or piping to file. If multiple options
    and/or images are provided, the requested header fields will be printed in
    the order in which they appear in the help page, with all requested details
    from each input image in sequence printed before the next image is
    processed.
    
    The command can also write the diffusion gradient table from a single input
    image to file; either in the MRtrix or FSL format (bvecs/bvals file pair;
    includes appropriate diffusion gradient vector reorientation)
    
    The -dwgrad, -export_* and -shell_* options provide (information about) the
    diffusion weighting gradient table after it has been processed by the
    MRtrix3 back-end (vectors normalised, b-values scaled by the square of the
    vector norm, depending on the -bvalue_scaling option). To see the raw
    gradient table information as stored in the image header, i.e. without
    MRtrix3 back-end processing, use "-property dw_scheme".
    
    The -bvalue_scaling option controls an aspect of the import of diffusion
    gradient tables. When the input diffusion-weighting direction vectors have
    norms that differ substantially from unity, the b-values will be scaled by
    the square of their corresponding vector norm (this is how multi-shell
    acquisitions are frequently achieved on scanner platforms). However in some
    rare instances, the b-values may be correct, despite the vectors not being
    of unit norm (or conversely, the b-values may need to be rescaled even
    though the vectors are close to unit norm). This option allows the user to
    control this operation and override MRrtix3's automatic detection.
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        image: the input image(s).
        all_: print all properties, rather than the first and last 2 of each.
        name: print the file system path of the image.
        format_: image file format.
        ndim: number of image dimensions.
        size: image size along each axis.
        spacing: voxel spacing along each image dimension.
        datatype: data type used for image data storage.
        strides: data strides i.e. order and direction of axes data layout.
        offset: image intensity offset.
        multiplier: image intensity multiplier.
        transform: the transformation from image coordinates [mm] to scanner /\
            real world coordinates [mm].
        property_: any text properties embedded in the image header under the\
            specified key (use 'all' to list all keys found).
        json_keyval: export header key/value entries to a JSON file.
        json_all: export all header contents to a JSON file.
        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.
        bvalue_scaling: enable or disable scaling of diffusion b-values by the\
            square of the corresponding DW gradient norm (see Desciption). Valid\
            choices are yes/no, true/false, 0/1 (default: automatic).
        export_grad_mrtrix: export the diffusion-weighted gradient table to\
            file in MRtrix format.
        export_grad_fsl: export the diffusion-weighted gradient table to files\
            in FSL (bvecs / bvals) format.
        dwgrad: the diffusion-weighting gradient table, as interpreted by\
            MRtrix3.
        shell_bvalues: list the average b-value of each shell.
        shell_sizes: list the number of volumes in each shell.
        shell_indices: list the image volumes attributed to each b-value shell.
        export_pe_table: export phase-encoding table to file.
        export_pe_eddy: export phase-encoding information to an EDDY-style\
            config / index file pair.
        petable: print the phase encoding table.
        nodelete: don't delete temporary images or images passed to mrinfo via\
            Unix pipes.
        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 `MrinfoOutputs`).
    """
    params = mrinfo_params(
        all_=all_,
        name=name,
        format_=format_,
        ndim=ndim,
        size=size,
        spacing=spacing,
        datatype=datatype,
        strides=strides,
        offset=offset,
        multiplier=multiplier,
        transform=transform,
        property_=property_,
        json_keyval=json_keyval,
        json_all=json_all,
        grad=grad,
        fslgrad=fslgrad,
        bvalue_scaling=bvalue_scaling,
        export_grad_mrtrix=export_grad_mrtrix,
        export_grad_fsl=export_grad_fsl,
        dwgrad=dwgrad,
        shell_bvalues=shell_bvalues,
        shell_sizes=shell_sizes,
        shell_indices=shell_indices,
        export_pe_table=export_pe_table,
        export_pe_eddy=export_pe_eddy,
        petable=petable,
        nodelete=nodelete,
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        image=image,
    )
    return mrinfo_execute(params, runner)


__all__ = [
    "MRINFO_METADATA",
    "MrinfoConfigParamsDict",
    "MrinfoConfigParamsDictTagged",
    "MrinfoExportGradFslOutputs",
    "MrinfoExportGradFslParamsDict",
    "MrinfoExportGradFslParamsDictTagged",
    "MrinfoExportPeEddyOutputs",
    "MrinfoExportPeEddyParamsDict",
    "MrinfoExportPeEddyParamsDictTagged",
    "MrinfoFslgradParamsDict",
    "MrinfoFslgradParamsDictTagged",
    "MrinfoOutputs",
    "MrinfoParamsDict",
    "MrinfoParamsDictTagged",
    "MrinfoPropertyParamsDict",
    "MrinfoPropertyParamsDictTagged",
    "mrinfo",
    "mrinfo_config",
    "mrinfo_execute",
    "mrinfo_export_grad_fsl",
    "mrinfo_export_pe_eddy",
    "mrinfo_fslgrad",
    "mrinfo_params",
    "mrinfo_property",
]
