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

import typing
import pathlib
from styxdefs import *

MRCONVERT_METADATA = Metadata(
    id="bef3db00bf7c217fcb538ce0cdc9238e54062140.boutiques",
    name="mrconvert",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


_MrconvertCoordParamsDictNoTag = typing.TypedDict('_MrconvertCoordParamsDictNoTag', {
    "axis": int,
    "selection": list[int],
})
MrconvertCoordParamsDictTagged = typing.TypedDict('MrconvertCoordParamsDictTagged', {
    "@type": typing.Literal["coord"],
    "axis": int,
    "selection": list[int],
})
MrconvertCoordParamsDict = _MrconvertCoordParamsDictNoTag | MrconvertCoordParamsDictTagged


_MrconvertClearPropertyParamsDictNoTag = typing.TypedDict('_MrconvertClearPropertyParamsDictNoTag', {
    "key": str,
})
MrconvertClearPropertyParamsDictTagged = typing.TypedDict('MrconvertClearPropertyParamsDictTagged', {
    "@type": typing.Literal["clear_property"],
    "key": str,
})
MrconvertClearPropertyParamsDict = _MrconvertClearPropertyParamsDictNoTag | MrconvertClearPropertyParamsDictTagged


_MrconvertSetPropertyParamsDictNoTag = typing.TypedDict('_MrconvertSetPropertyParamsDictNoTag', {
    "key": str,
    "value": str,
})
MrconvertSetPropertyParamsDictTagged = typing.TypedDict('MrconvertSetPropertyParamsDictTagged', {
    "@type": typing.Literal["set_property"],
    "key": str,
    "value": str,
})
MrconvertSetPropertyParamsDict = _MrconvertSetPropertyParamsDictNoTag | MrconvertSetPropertyParamsDictTagged


_MrconvertAppendPropertyParamsDictNoTag = typing.TypedDict('_MrconvertAppendPropertyParamsDictNoTag', {
    "key": str,
    "value": str,
})
MrconvertAppendPropertyParamsDictTagged = typing.TypedDict('MrconvertAppendPropertyParamsDictTagged', {
    "@type": typing.Literal["append_property"],
    "key": str,
    "value": str,
})
MrconvertAppendPropertyParamsDict = _MrconvertAppendPropertyParamsDictNoTag | MrconvertAppendPropertyParamsDictTagged


_MrconvertVariousStringParamsDictNoTag = typing.TypedDict('_MrconvertVariousStringParamsDictNoTag', {
    "obj": str,
})
MrconvertVariousStringParamsDictTagged = typing.TypedDict('MrconvertVariousStringParamsDictTagged', {
    "@type": typing.Literal["VariousString"],
    "obj": str,
})
MrconvertVariousStringParamsDict = _MrconvertVariousStringParamsDictNoTag | MrconvertVariousStringParamsDictTagged


_MrconvertVariousFileParamsDictNoTag = typing.TypedDict('_MrconvertVariousFileParamsDictNoTag', {
    "obj": InputPathType,
})
MrconvertVariousFileParamsDictTagged = typing.TypedDict('MrconvertVariousFileParamsDictTagged', {
    "@type": typing.Literal["VariousFile"],
    "obj": InputPathType,
})
MrconvertVariousFileParamsDict = _MrconvertVariousFileParamsDictNoTag | MrconvertVariousFileParamsDictTagged


_MrconvertVariousString1ParamsDictNoTag = typing.TypedDict('_MrconvertVariousString1ParamsDictNoTag', {
    "obj": str,
})
MrconvertVariousString1ParamsDictTagged = typing.TypedDict('MrconvertVariousString1ParamsDictTagged', {
    "@type": typing.Literal["VariousString_1"],
    "obj": str,
})
MrconvertVariousString1ParamsDict = _MrconvertVariousString1ParamsDictNoTag | MrconvertVariousString1ParamsDictTagged


_MrconvertVariousFile1ParamsDictNoTag = typing.TypedDict('_MrconvertVariousFile1ParamsDictNoTag', {
    "obj": InputPathType,
})
MrconvertVariousFile1ParamsDictTagged = typing.TypedDict('MrconvertVariousFile1ParamsDictTagged', {
    "@type": typing.Literal["VariousFile_1"],
    "obj": InputPathType,
})
MrconvertVariousFile1ParamsDict = _MrconvertVariousFile1ParamsDictNoTag | MrconvertVariousFile1ParamsDictTagged


_MrconvertFslgradParamsDictNoTag = typing.TypedDict('_MrconvertFslgradParamsDictNoTag', {
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
MrconvertFslgradParamsDictTagged = typing.TypedDict('MrconvertFslgradParamsDictTagged', {
    "@type": typing.Literal["fslgrad"],
    "bvecs": InputPathType,
    "bvals": InputPathType,
})
MrconvertFslgradParamsDict = _MrconvertFslgradParamsDictNoTag | MrconvertFslgradParamsDictTagged


_MrconvertExportGradFslParamsDictNoTag = typing.TypedDict('_MrconvertExportGradFslParamsDictNoTag', {
    "bvecs_path": str,
    "bvals_path": str,
})
MrconvertExportGradFslParamsDictTagged = typing.TypedDict('MrconvertExportGradFslParamsDictTagged', {
    "@type": typing.Literal["export_grad_fsl"],
    "bvecs_path": str,
    "bvals_path": str,
})
MrconvertExportGradFslParamsDict = _MrconvertExportGradFslParamsDictNoTag | MrconvertExportGradFslParamsDictTagged


_MrconvertImportPeEddyParamsDictNoTag = typing.TypedDict('_MrconvertImportPeEddyParamsDictNoTag', {
    "config": InputPathType,
    "indices": InputPathType,
})
MrconvertImportPeEddyParamsDictTagged = typing.TypedDict('MrconvertImportPeEddyParamsDictTagged', {
    "@type": typing.Literal["import_pe_eddy"],
    "config": InputPathType,
    "indices": InputPathType,
})
MrconvertImportPeEddyParamsDict = _MrconvertImportPeEddyParamsDictNoTag | MrconvertImportPeEddyParamsDictTagged


_MrconvertExportPeEddyParamsDictNoTag = typing.TypedDict('_MrconvertExportPeEddyParamsDictNoTag', {
    "config": str,
    "indices": str,
})
MrconvertExportPeEddyParamsDictTagged = typing.TypedDict('MrconvertExportPeEddyParamsDictTagged', {
    "@type": typing.Literal["export_pe_eddy"],
    "config": str,
    "indices": str,
})
MrconvertExportPeEddyParamsDict = _MrconvertExportPeEddyParamsDictNoTag | MrconvertExportPeEddyParamsDictTagged


_MrconvertConfigParamsDictNoTag = typing.TypedDict('_MrconvertConfigParamsDictNoTag', {
    "key": str,
    "value": str,
})
MrconvertConfigParamsDictTagged = typing.TypedDict('MrconvertConfigParamsDictTagged', {
    "@type": typing.Literal["config"],
    "key": str,
    "value": str,
})
MrconvertConfigParamsDict = _MrconvertConfigParamsDictNoTag | MrconvertConfigParamsDictTagged


_MrconvertParamsDictNoTag = typing.TypedDict('_MrconvertParamsDictNoTag', {
    "coord": typing.NotRequired[list[MrconvertCoordParamsDict] | None],
    "vox": typing.NotRequired[list[float] | None],
    "axes": typing.NotRequired[list[int] | None],
    "scaling": typing.NotRequired[list[float] | None],
    "json_import": typing.NotRequired[InputPathType | None],
    "json_export": typing.NotRequired[str | None],
    "clear_property": typing.NotRequired[list[MrconvertClearPropertyParamsDict] | None],
    "set_property": typing.NotRequired[list[MrconvertSetPropertyParamsDict] | None],
    "append_property": typing.NotRequired[list[MrconvertAppendPropertyParamsDict] | None],
    "copy_properties": typing.NotRequired[typing.Union[MrconvertVariousStringParamsDictTagged, MrconvertVariousFileParamsDictTagged] | None],
    "strides": typing.NotRequired[typing.Union[MrconvertVariousString1ParamsDictTagged, MrconvertVariousFile1ParamsDictTagged] | None],
    "datatype": typing.NotRequired[str | None],
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[MrconvertFslgradParamsDict | None],
    "bvalue_scaling": typing.NotRequired[str | None],
    "export_grad_mrtrix": typing.NotRequired[str | None],
    "export_grad_fsl": typing.NotRequired[MrconvertExportGradFslParamsDict | None],
    "import_pe_table": typing.NotRequired[InputPathType | None],
    "import_pe_eddy": typing.NotRequired[MrconvertImportPeEddyParamsDict | None],
    "export_pe_table": typing.NotRequired[str | None],
    "export_pe_eddy": typing.NotRequired[MrconvertExportPeEddyParamsDict | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MrconvertConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "input": InputPathType,
    "output": str,
})
MrconvertParamsDictTagged = typing.TypedDict('MrconvertParamsDictTagged', {
    "@type": typing.Literal["mrtrix/mrconvert"],
    "coord": typing.NotRequired[list[MrconvertCoordParamsDict] | None],
    "vox": typing.NotRequired[list[float] | None],
    "axes": typing.NotRequired[list[int] | None],
    "scaling": typing.NotRequired[list[float] | None],
    "json_import": typing.NotRequired[InputPathType | None],
    "json_export": typing.NotRequired[str | None],
    "clear_property": typing.NotRequired[list[MrconvertClearPropertyParamsDict] | None],
    "set_property": typing.NotRequired[list[MrconvertSetPropertyParamsDict] | None],
    "append_property": typing.NotRequired[list[MrconvertAppendPropertyParamsDict] | None],
    "copy_properties": typing.NotRequired[typing.Union[MrconvertVariousStringParamsDictTagged, MrconvertVariousFileParamsDictTagged] | None],
    "strides": typing.NotRequired[typing.Union[MrconvertVariousString1ParamsDictTagged, MrconvertVariousFile1ParamsDictTagged] | None],
    "datatype": typing.NotRequired[str | None],
    "grad": typing.NotRequired[InputPathType | None],
    "fslgrad": typing.NotRequired[MrconvertFslgradParamsDict | None],
    "bvalue_scaling": typing.NotRequired[str | None],
    "export_grad_mrtrix": typing.NotRequired[str | None],
    "export_grad_fsl": typing.NotRequired[MrconvertExportGradFslParamsDict | None],
    "import_pe_table": typing.NotRequired[InputPathType | None],
    "import_pe_eddy": typing.NotRequired[MrconvertImportPeEddyParamsDict | None],
    "export_pe_table": typing.NotRequired[str | None],
    "export_pe_eddy": typing.NotRequired[MrconvertExportPeEddyParamsDict | None],
    "info": bool,
    "quiet": bool,
    "debug": bool,
    "force": bool,
    "nthreads": typing.NotRequired[int | None],
    "config": typing.NotRequired[list[MrconvertConfigParamsDict] | None],
    "help": bool,
    "version": bool,
    "input": InputPathType,
    "output": str,
})
MrconvertParamsDict = _MrconvertParamsDictNoTag | MrconvertParamsDictTagged


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


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


def mrconvert_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_1": mrconvert_various_string_1_cargs,
        "VariousFile_1": mrconvert_various_file_1_cargs,
    }.get(t)


def mrconvert_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_1": mrconvert_various_string_1_validate,
        "VariousFile_1": mrconvert_various_file_1_validate,
    }.get(t)


def mrconvert_coord(
    axis: int,
    selection: list[int],
) -> MrconvertCoordParamsDictTagged:
    """
    Build parameters.
    
    Args:
        axis: retain data from the input image only at the coordinates\
            specified in the selection along the specified axis. The selection\
            argument expects a number sequence, which can also include the 'end'\
            keyword.
        selection: retain data from the input image only at the coordinates\
            specified in the selection along the specified axis. The selection\
            argument expects a number sequence, which can also include the 'end'\
            keyword.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "coord",
        "axis": axis,
        "selection": selection,
    }
    return params


def mrconvert_coord_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertCoordParamsDict` 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("axis", None) is None:
        raise StyxValidationError("`axis` must not be None")
    if not isinstance(params["axis"], int):
        raise StyxValidationError(f'`axis` has the wrong type: Received `{type(params.get("axis", None))}` expected `int`')
    if params.get("selection", None) is None:
        raise StyxValidationError("`selection` must not be None")
    if not isinstance(params["selection"], list):
        raise StyxValidationError(f'`selection` has the wrong type: Received `{type(params.get("selection", None))}` expected `list[int]`')
    for e in params["selection"]:
        if not isinstance(e, int):
            raise StyxValidationError(f'`selection` has the wrong type: Received `{type(params.get("selection", None))}` expected `list[int]`')


def mrconvert_coord_cargs(
    params: MrconvertCoordParamsDict,
    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("-coord")
    cargs.append(str(params.get("axis", None)))
    cargs.extend(map(str, params.get("selection", None)))
    return cargs


def mrconvert_clear_property(
    key: str,
) -> MrconvertClearPropertyParamsDictTagged:
    """
    Build parameters.
    
    Args:
        key: remove the specified key from the image header altogether.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "clear_property",
        "key": key,
    }
    return params


def mrconvert_clear_property_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertClearPropertyParamsDict` 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 mrconvert_clear_property_cargs(
    params: MrconvertClearPropertyParamsDict,
    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("-clear_property")
    cargs.append(params.get("key", None))
    return cargs


def mrconvert_set_property(
    key: str,
    value: str,
) -> MrconvertSetPropertyParamsDictTagged:
    """
    Build parameters.
    
    Args:
        key: set the value of the specified key in the image header.
        value: set the value of the specified key in the image header.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "set_property",
        "key": key,
        "value": value,
    }
    return params


def mrconvert_set_property_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertSetPropertyParamsDict` 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 mrconvert_set_property_cargs(
    params: MrconvertSetPropertyParamsDict,
    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("-set_property")
    cargs.append(params.get("key", None))
    cargs.append(params.get("value", None))
    return cargs


def mrconvert_append_property(
    key: str,
    value: str,
) -> MrconvertAppendPropertyParamsDictTagged:
    """
    Build parameters.
    
    Args:
        key: append the given value to the specified key in the image header\
            (this adds the value specified as a new line in the header value).
        value: append the given value to the specified key in the image header\
            (this adds the value specified as a new line in the header value).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "append_property",
        "key": key,
        "value": value,
    }
    return params


def mrconvert_append_property_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertAppendPropertyParamsDict` 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 mrconvert_append_property_cargs(
    params: MrconvertAppendPropertyParamsDict,
    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("-append_property")
    cargs.append(params.get("key", None))
    cargs.append(params.get("value", None))
    return cargs


def mrconvert_various_string(
    obj: str,
) -> MrconvertVariousStringParamsDictTagged:
    """
    Build parameters.
    
    Args:
        obj: String object.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "VariousString",
        "obj": obj,
    }
    return params


def mrconvert_various_string_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertVariousStringParamsDict` 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 mrconvert_various_string_cargs(
    params: MrconvertVariousStringParamsDict,
    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 mrconvert_various_file(
    obj: InputPathType,
) -> MrconvertVariousFileParamsDictTagged:
    """
    Build parameters.
    
    Args:
        obj: File object.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "VariousFile",
        "obj": obj,
    }
    return params


def mrconvert_various_file_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertVariousFileParamsDict` 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 mrconvert_various_file_cargs(
    params: MrconvertVariousFileParamsDict,
    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 mrconvert_various_string_1(
    obj: str,
) -> MrconvertVariousString1ParamsDictTagged:
    """
    Build parameters.
    
    Args:
        obj: String object.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "VariousString_1",
        "obj": obj,
    }
    return params


def mrconvert_various_string_1_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertVariousString1ParamsDict` 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 mrconvert_various_string_1_cargs(
    params: MrconvertVariousString1ParamsDict,
    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 mrconvert_various_file_1(
    obj: InputPathType,
) -> MrconvertVariousFile1ParamsDictTagged:
    """
    Build parameters.
    
    Args:
        obj: File object.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "VariousFile_1",
        "obj": obj,
    }
    return params


def mrconvert_various_file_1_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertVariousFile1ParamsDict` 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 mrconvert_various_file_1_cargs(
    params: MrconvertVariousFile1ParamsDict,
    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 mrconvert_fslgrad(
    bvecs: InputPathType,
    bvals: InputPathType,
) -> MrconvertFslgradParamsDictTagged:
    """
    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 mrconvert_fslgrad_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertFslgradParamsDict` 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 mrconvert_fslgrad_cargs(
    params: MrconvertFslgradParamsDict,
    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 MrconvertExportGradFslOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MrconvertExportGradFslParamsDict | 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 mrconvert_export_grad_fsl(
    bvecs_path: str,
    bvals_path: str,
) -> MrconvertExportGradFslParamsDictTagged:
    """
    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 mrconvert_export_grad_fsl_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertExportGradFslParamsDict` 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 mrconvert_export_grad_fsl_cargs(
    params: MrconvertExportGradFslParamsDict,
    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 mrconvert_export_grad_fsl_outputs(
    params: MrconvertExportGradFslParamsDict,
    execution: Execution,
) -> MrconvertExportGradFslOutputs:
    """
    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 = MrconvertExportGradFslOutputs(
        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


def mrconvert_import_pe_eddy(
    config: InputPathType,
    indices: InputPathType,
) -> MrconvertImportPeEddyParamsDictTagged:
    """
    Build parameters.
    
    Args:
        config: import phase-encoding information from an EDDY-style config /\
            index file pair.
        indices: import phase-encoding information from an EDDY-style config /\
            index file pair.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "import_pe_eddy",
        "config": config,
        "indices": indices,
    }
    return params


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


def mrconvert_import_pe_eddy_cargs(
    params: MrconvertImportPeEddyParamsDict,
    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("-import_pe_eddy")
    cargs.append(execution.input_file(params.get("config", None)))
    cargs.append(execution.input_file(params.get("indices", None)))
    return cargs


class MrconvertExportPeEddyOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MrconvertExportPeEddyParamsDict | 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 mrconvert_export_pe_eddy(
    config: str,
    indices: str,
) -> MrconvertExportPeEddyParamsDictTagged:
    """
    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 mrconvert_export_pe_eddy_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertExportPeEddyParamsDict` 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 mrconvert_export_pe_eddy_cargs(
    params: MrconvertExportPeEddyParamsDict,
    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 mrconvert_export_pe_eddy_outputs(
    params: MrconvertExportPeEddyParamsDict,
    execution: Execution,
) -> MrconvertExportPeEddyOutputs:
    """
    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 = MrconvertExportPeEddyOutputs(
        root=execution.output_file("."),
        config=execution.output_file(params.get("config", None)),
        indices=execution.output_file(params.get("indices", None)),
    )
    return ret


def mrconvert_config(
    key: str,
    value: str,
) -> MrconvertConfigParamsDictTagged:
    """
    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 mrconvert_config_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertConfigParamsDict` 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 mrconvert_config_cargs(
    params: MrconvertConfigParamsDict,
    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 MrconvertOutputs(typing.NamedTuple):
    """
    Output object returned when calling `MrconvertParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output: OutputPathType
    """the output image."""
    json_export: OutputPathType | None
    """export data from an image header key-value pairs into 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: MrconvertExportGradFslOutputs | None
    """Outputs from `mrconvert_export_grad_fsl_outputs`."""
    export_pe_eddy: MrconvertExportPeEddyOutputs | None
    """Outputs from `mrconvert_export_pe_eddy_outputs`."""


def mrconvert_params(
    input_: InputPathType,
    output: str,
    coord: list[MrconvertCoordParamsDict] | None = None,
    vox: list[float] | None = None,
    axes: list[int] | None = None,
    scaling: list[float] | None = None,
    json_import: InputPathType | None = None,
    json_export: str | None = None,
    clear_property: list[MrconvertClearPropertyParamsDict] | None = None,
    set_property: list[MrconvertSetPropertyParamsDict] | None = None,
    append_property: list[MrconvertAppendPropertyParamsDict] | None = None,
    copy_properties: typing.Union[MrconvertVariousStringParamsDictTagged, MrconvertVariousFileParamsDictTagged] | None = None,
    strides: typing.Union[MrconvertVariousString1ParamsDictTagged, MrconvertVariousFile1ParamsDictTagged] | None = None,
    datatype: str | None = None,
    grad: InputPathType | None = None,
    fslgrad: MrconvertFslgradParamsDict | None = None,
    bvalue_scaling: str | None = None,
    export_grad_mrtrix: str | None = None,
    export_grad_fsl: MrconvertExportGradFslParamsDict | None = None,
    import_pe_table: InputPathType | None = None,
    import_pe_eddy: MrconvertImportPeEddyParamsDict | None = None,
    export_pe_table: str | None = None,
    export_pe_eddy: MrconvertExportPeEddyParamsDict | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MrconvertConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
) -> MrconvertParamsDictTagged:
    """
    Build parameters.
    
    Args:
        input_: the input image.
        output: the output image.
        coord: retain data from the input image only at the coordinates\
            specified in the selection along the specified axis. The selection\
            argument expects a number sequence, which can also include the 'end'\
            keyword.
        vox: change the voxel dimensions reported in the output image header.
        axes: specify the axes from the input image that will be used to form\
            the output image.
        scaling: specify the data scaling parameters used to rescale the\
            intensity values.
        json_import: import data from a JSON file into header key-value pairs.
        json_export: export data from an image header key-value pairs into a\
            JSON file.
        clear_property: remove the specified key from the image header\
            altogether.
        set_property: set the value of the specified key in the image header.
        append_property: append the given value to the specified key in the\
            image header (this adds the value specified as a new line in the header\
            value).
        copy_properties: clear all generic properties and replace with the\
            properties from the image / file specified.
        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.
        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.
        import_pe_table: import a phase-encoding table from file.
        import_pe_eddy: import phase-encoding information from an EDDY-style\
            config / index file pair.
        export_pe_table: export phase-encoding table to file.
        export_pe_eddy: export phase-encoding information to an EDDY-style\
            config / index file pair.
        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/mrconvert",
        "info": info,
        "quiet": quiet,
        "debug": debug,
        "force": force,
        "help": help_,
        "version": version,
        "input": input_,
        "output": output,
    }
    if coord is not None:
        params["coord"] = coord
    if vox is not None:
        params["vox"] = vox
    if axes is not None:
        params["axes"] = axes
    if scaling is not None:
        params["scaling"] = scaling
    if json_import is not None:
        params["json_import"] = json_import
    if json_export is not None:
        params["json_export"] = json_export
    if clear_property is not None:
        params["clear_property"] = clear_property
    if set_property is not None:
        params["set_property"] = set_property
    if append_property is not None:
        params["append_property"] = append_property
    if copy_properties is not None:
        params["copy_properties"] = copy_properties
    if strides is not None:
        params["strides"] = strides
    if datatype is not None:
        params["datatype"] = datatype
    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 import_pe_table is not None:
        params["import_pe_table"] = import_pe_table
    if import_pe_eddy is not None:
        params["import_pe_eddy"] = import_pe_eddy
    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 mrconvert_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `MrconvertParamsDict` 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("coord", None) is not None:
        if not isinstance(params["coord"], list):
            raise StyxValidationError(f'`coord` has the wrong type: Received `{type(params.get("coord", None))}` expected `list[MrconvertCoordParamsDict] | None`')
        for e in params["coord"]:
            mrconvert_coord_validate(e)
    if params.get("vox", None) is not None:
        if not isinstance(params["vox"], list):
            raise StyxValidationError(f'`vox` has the wrong type: Received `{type(params.get("vox", None))}` expected `list[float] | None`')
        for e in params["vox"]:
            if not isinstance(e, (float, int)):
                raise StyxValidationError(f'`vox` has the wrong type: Received `{type(params.get("vox", None))}` expected `list[float] | None`')
    if params.get("axes", None) is not None:
        if not isinstance(params["axes"], list):
            raise StyxValidationError(f'`axes` has the wrong type: Received `{type(params.get("axes", None))}` expected `list[int] | None`')
        for e in params["axes"]:
            if not isinstance(e, int):
                raise StyxValidationError(f'`axes` has the wrong type: Received `{type(params.get("axes", None))}` expected `list[int] | None`')
    if params.get("scaling", None) is not None:
        if not isinstance(params["scaling"], list):
            raise StyxValidationError(f'`scaling` has the wrong type: Received `{type(params.get("scaling", None))}` expected `list[float] | None`')
        for e in params["scaling"]:
            if not isinstance(e, (float, int)):
                raise StyxValidationError(f'`scaling` has the wrong type: Received `{type(params.get("scaling", None))}` expected `list[float] | None`')
    if params.get("json_import", None) is not None:
        if not isinstance(params["json_import"], (pathlib.Path, str)):
            raise StyxValidationError(f'`json_import` has the wrong type: Received `{type(params.get("json_import", None))}` expected `InputPathType | None`')
    if params.get("json_export", None) is not None:
        if not isinstance(params["json_export"], str):
            raise StyxValidationError(f'`json_export` has the wrong type: Received `{type(params.get("json_export", None))}` expected `str | None`')
    if params.get("clear_property", None) is not None:
        if not isinstance(params["clear_property"], list):
            raise StyxValidationError(f'`clear_property` has the wrong type: Received `{type(params.get("clear_property", None))}` expected `list[MrconvertClearPropertyParamsDict] | None`')
        for e in params["clear_property"]:
            mrconvert_clear_property_validate(e)
    if params.get("set_property", None) is not None:
        if not isinstance(params["set_property"], list):
            raise StyxValidationError(f'`set_property` has the wrong type: Received `{type(params.get("set_property", None))}` expected `list[MrconvertSetPropertyParamsDict] | None`')
        for e in params["set_property"]:
            mrconvert_set_property_validate(e)
    if params.get("append_property", None) is not None:
        if not isinstance(params["append_property"], list):
            raise StyxValidationError(f'`append_property` has the wrong type: Received `{type(params.get("append_property", None))}` expected `list[MrconvertAppendPropertyParamsDict] | None`')
        for e in params["append_property"]:
            mrconvert_append_property_validate(e)
    if params.get("copy_properties", None) is not None:
        if not isinstance(params["copy_properties"], dict):
            raise StyxValidationError(f'Params object has the wrong type \'{type(params["copy_properties"])}\'')
        if "@type" not in params["copy_properties"]:
            raise StyxValidationError("Params object is missing `@type`")
        if params["copy_properties"]["@type"] not in ["VariousString", "VariousFile"]:
            raise StyxValidationError("Parameter `copy_properties`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
        mrconvert_copy_properties_validate_dyn_fn(params["copy_properties"]["@type"])(params["copy_properties"])
    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_1", "VariousFile_1"]:
            raise StyxValidationError("Parameter `strides`s `@type` must be one of [\"VariousString_1\", \"VariousFile_1\"]")
        mrconvert_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("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:
        mrconvert_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:
        mrconvert_export_grad_fsl_validate(params["export_grad_fsl"])
    if params.get("import_pe_table", None) is not None:
        if not isinstance(params["import_pe_table"], (pathlib.Path, str)):
            raise StyxValidationError(f'`import_pe_table` has the wrong type: Received `{type(params.get("import_pe_table", None))}` expected `InputPathType | None`')
    if params.get("import_pe_eddy", None) is not None:
        mrconvert_import_pe_eddy_validate(params["import_pe_eddy"])
    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:
        mrconvert_export_pe_eddy_validate(params["export_pe_eddy"])
    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[MrconvertConfigParamsDict] | None`')
        for e in params["config"]:
            mrconvert_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("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 mrconvert_cargs(
    params: MrconvertParamsDict,
    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("mrconvert")
    if params.get("coord", None) is not None:
        cargs.extend([a for c in [mrconvert_coord_cargs(s, execution) for s in params.get("coord", None)] for a in c])
    if params.get("vox", None) is not None:
        cargs.extend([
            "-vox",
            *map(str, params.get("vox", None))
        ])
    if params.get("axes", None) is not None:
        cargs.extend([
            "-axes",
            ",".join(map(str, params.get("axes", None)))
        ])
    if params.get("scaling", None) is not None:
        cargs.extend([
            "-scaling",
            *map(str, params.get("scaling", None))
        ])
    if params.get("json_import", None) is not None:
        cargs.extend([
            "-json_import",
            execution.input_file(params.get("json_import", None))
        ])
    if params.get("json_export", None) is not None:
        cargs.extend([
            "-json_export",
            params.get("json_export", None)
        ])
    if params.get("clear_property", None) is not None:
        cargs.extend([a for c in [mrconvert_clear_property_cargs(s, execution) for s in params.get("clear_property", None)] for a in c])
    if params.get("set_property", None) is not None:
        cargs.extend([a for c in [mrconvert_set_property_cargs(s, execution) for s in params.get("set_property", None)] for a in c])
    if params.get("append_property", None) is not None:
        cargs.extend([a for c in [mrconvert_append_property_cargs(s, execution) for s in params.get("append_property", None)] for a in c])
    if params.get("copy_properties", None) is not None:
        cargs.extend([
            "-copy_properties",
            *mrconvert_copy_properties_cargs_dyn_fn(params.get("copy_properties", None)["@type"])(params.get("copy_properties", None), execution)
        ])
    if params.get("strides", None) is not None:
        cargs.extend([
            "-strides",
            *mrconvert_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("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(mrconvert_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(mrconvert_export_grad_fsl_cargs(params.get("export_grad_fsl", None), execution))
    if params.get("import_pe_table", None) is not None:
        cargs.extend([
            "-import_pe_table",
            execution.input_file(params.get("import_pe_table", None))
        ])
    if params.get("import_pe_eddy", None) is not None:
        cargs.extend(mrconvert_import_pe_eddy_cargs(params.get("import_pe_eddy", None), execution))
    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(mrconvert_export_pe_eddy_cargs(params.get("export_pe_eddy", 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 [mrconvert_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(params.get("output", None))
    return cargs


def mrconvert_outputs(
    params: MrconvertParamsDict,
    execution: Execution,
) -> MrconvertOutputs:
    """
    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 = MrconvertOutputs(
        root=execution.output_file("."),
        output=execution.output_file(params.get("output", None)),
        json_export=execution.output_file(params.get("json_export", None)) if (params.get("json_export") 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=mrconvert_export_grad_fsl_outputs(params.get("export_grad_fsl"), execution) if params.get("export_grad_fsl") else None,
        export_pe_eddy=mrconvert_export_pe_eddy_outputs(params.get("export_pe_eddy"), execution) if params.get("export_pe_eddy") else None,
    )
    return ret


def mrconvert_execute(
    params: MrconvertParamsDict,
    runner: Runner | None = None,
) -> MrconvertOutputs:
    """
    mrconvert
    
    Perform conversion between different file types and optionally extract a
    subset of the input image.
    
    If used correctly, this program can be a very useful workhorse. In addition
    to converting images between different formats, it can be used to extract
    specific studies from a data set, extract a specific region of interest, or
    flip the images. Some of the possible operations are described in more
    detail below.
    
    Note that for both the -coord and -axes options, indexing starts from 0
    rather than 1. E.g. -coord 3 <#> selects volumes (the fourth dimension) from
    the series; -axes 0,1,2 includes only the three spatial axes in the output
    image.
    
    Additionally, for the second input to the -coord option and the -axes
    option, you can use any valid number sequence in the selection, as well as
    the 'end' keyword (see the main documentation for details); this can be
    particularly useful to select multiple coordinates.
    
    The -vox option is used to change the size of the voxels in the output image
    as reported in the image header; note however that this does not re-sample
    the image based on a new voxel size (that is done using the mrgrid command).
    
    By default, the intensity scaling parameters in the input image header are
    passed through to the output image header when writing to an integer image,
    and reset to 0,1 (i.e. no scaling) for floating-point and binary images.
    Note that the -scaling option will therefore have no effect for
    floating-point or binary output images.
    
    The -axes option specifies which axes from the input image will be used to
    form the output image. This allows the permutation, omission, or addition of
    axes into the output image. The axes should be supplied as a comma-separated
    list of axis indices. If an axis from the input image is to be omitted from
    the output image, it must either already have a size of 1, or a single
    coordinate along that axis must be selected by the user by using the -coord
    option. Examples are provided further below.
    
    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 `MrconvertOutputs`).
    """
    mrconvert_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRCONVERT_METADATA)
    params = execution.params(params)
    cargs = mrconvert_cargs(params, execution)
    ret = mrconvert_outputs(params, execution)
    execution.run(cargs)
    return ret


def mrconvert(
    input_: InputPathType,
    output: str,
    coord: list[MrconvertCoordParamsDict] | None = None,
    vox: list[float] | None = None,
    axes: list[int] | None = None,
    scaling: list[float] | None = None,
    json_import: InputPathType | None = None,
    json_export: str | None = None,
    clear_property: list[MrconvertClearPropertyParamsDict] | None = None,
    set_property: list[MrconvertSetPropertyParamsDict] | None = None,
    append_property: list[MrconvertAppendPropertyParamsDict] | None = None,
    copy_properties: typing.Union[MrconvertVariousStringParamsDictTagged, MrconvertVariousFileParamsDictTagged] | None = None,
    strides: typing.Union[MrconvertVariousString1ParamsDictTagged, MrconvertVariousFile1ParamsDictTagged] | None = None,
    datatype: str | None = None,
    grad: InputPathType | None = None,
    fslgrad: MrconvertFslgradParamsDict | None = None,
    bvalue_scaling: str | None = None,
    export_grad_mrtrix: str | None = None,
    export_grad_fsl: MrconvertExportGradFslParamsDict | None = None,
    import_pe_table: InputPathType | None = None,
    import_pe_eddy: MrconvertImportPeEddyParamsDict | None = None,
    export_pe_table: str | None = None,
    export_pe_eddy: MrconvertExportPeEddyParamsDict | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MrconvertConfigParamsDict] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> MrconvertOutputs:
    """
    mrconvert
    
    Perform conversion between different file types and optionally extract a
    subset of the input image.
    
    If used correctly, this program can be a very useful workhorse. In addition
    to converting images between different formats, it can be used to extract
    specific studies from a data set, extract a specific region of interest, or
    flip the images. Some of the possible operations are described in more
    detail below.
    
    Note that for both the -coord and -axes options, indexing starts from 0
    rather than 1. E.g. -coord 3 <#> selects volumes (the fourth dimension) from
    the series; -axes 0,1,2 includes only the three spatial axes in the output
    image.
    
    Additionally, for the second input to the -coord option and the -axes
    option, you can use any valid number sequence in the selection, as well as
    the 'end' keyword (see the main documentation for details); this can be
    particularly useful to select multiple coordinates.
    
    The -vox option is used to change the size of the voxels in the output image
    as reported in the image header; note however that this does not re-sample
    the image based on a new voxel size (that is done using the mrgrid command).
    
    By default, the intensity scaling parameters in the input image header are
    passed through to the output image header when writing to an integer image,
    and reset to 0,1 (i.e. no scaling) for floating-point and binary images.
    Note that the -scaling option will therefore have no effect for
    floating-point or binary output images.
    
    The -axes option specifies which axes from the input image will be used to
    form the output image. This allows the permutation, omission, or addition of
    axes into the output image. The axes should be supplied as a comma-separated
    list of axis indices. If an axis from the input image is to be omitted from
    the output image, it must either already have a size of 1, or a single
    coordinate along that axis must be selected by the user by using the -coord
    option. Examples are provided further below.
    
    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:
        input_: the input image.
        output: the output image.
        coord: retain data from the input image only at the coordinates\
            specified in the selection along the specified axis. The selection\
            argument expects a number sequence, which can also include the 'end'\
            keyword.
        vox: change the voxel dimensions reported in the output image header.
        axes: specify the axes from the input image that will be used to form\
            the output image.
        scaling: specify the data scaling parameters used to rescale the\
            intensity values.
        json_import: import data from a JSON file into header key-value pairs.
        json_export: export data from an image header key-value pairs into a\
            JSON file.
        clear_property: remove the specified key from the image header\
            altogether.
        set_property: set the value of the specified key in the image header.
        append_property: append the given value to the specified key in the\
            image header (this adds the value specified as a new line in the header\
            value).
        copy_properties: clear all generic properties and replace with the\
            properties from the image / file specified.
        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.
        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.
        import_pe_table: import a phase-encoding table from file.
        import_pe_eddy: import phase-encoding information from an EDDY-style\
            config / index file pair.
        export_pe_table: export phase-encoding table to file.
        export_pe_eddy: export phase-encoding information to an EDDY-style\
            config / index file pair.
        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 `MrconvertOutputs`).
    """
    params = mrconvert_params(
        coord=coord,
        vox=vox,
        axes=axes,
        scaling=scaling,
        json_import=json_import,
        json_export=json_export,
        clear_property=clear_property,
        set_property=set_property,
        append_property=append_property,
        copy_properties=copy_properties,
        strides=strides,
        datatype=datatype,
        grad=grad,
        fslgrad=fslgrad,
        bvalue_scaling=bvalue_scaling,
        export_grad_mrtrix=export_grad_mrtrix,
        export_grad_fsl=export_grad_fsl,
        import_pe_table=import_pe_table,
        import_pe_eddy=import_pe_eddy,
        export_pe_table=export_pe_table,
        export_pe_eddy=export_pe_eddy,
        info=info,
        quiet=quiet,
        debug=debug,
        force=force,
        nthreads=nthreads,
        config=config,
        help_=help_,
        version=version,
        input_=input_,
        output=output,
    )
    return mrconvert_execute(params, runner)


__all__ = [
    "MRCONVERT_METADATA",
    "MrconvertAppendPropertyParamsDict",
    "MrconvertAppendPropertyParamsDictTagged",
    "MrconvertClearPropertyParamsDict",
    "MrconvertClearPropertyParamsDictTagged",
    "MrconvertConfigParamsDict",
    "MrconvertConfigParamsDictTagged",
    "MrconvertCoordParamsDict",
    "MrconvertCoordParamsDictTagged",
    "MrconvertExportGradFslOutputs",
    "MrconvertExportGradFslParamsDict",
    "MrconvertExportGradFslParamsDictTagged",
    "MrconvertExportPeEddyOutputs",
    "MrconvertExportPeEddyParamsDict",
    "MrconvertExportPeEddyParamsDictTagged",
    "MrconvertFslgradParamsDict",
    "MrconvertFslgradParamsDictTagged",
    "MrconvertImportPeEddyParamsDict",
    "MrconvertImportPeEddyParamsDictTagged",
    "MrconvertOutputs",
    "MrconvertParamsDict",
    "MrconvertParamsDictTagged",
    "MrconvertSetPropertyParamsDict",
    "MrconvertSetPropertyParamsDictTagged",
    "MrconvertVariousFile1ParamsDict",
    "MrconvertVariousFile1ParamsDictTagged",
    "MrconvertVariousFileParamsDict",
    "MrconvertVariousFileParamsDictTagged",
    "MrconvertVariousString1ParamsDict",
    "MrconvertVariousString1ParamsDictTagged",
    "MrconvertVariousStringParamsDict",
    "MrconvertVariousStringParamsDictTagged",
    "mrconvert",
    "mrconvert_append_property",
    "mrconvert_clear_property",
    "mrconvert_config",
    "mrconvert_coord",
    "mrconvert_execute",
    "mrconvert_export_grad_fsl",
    "mrconvert_export_pe_eddy",
    "mrconvert_fslgrad",
    "mrconvert_import_pe_eddy",
    "mrconvert_params",
    "mrconvert_set_property",
    "mrconvert_various_file",
    "mrconvert_various_file_1",
    "mrconvert_various_string",
    "mrconvert_various_string_1",
]
