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

import typing
import pathlib
from styxdefs import *

CIFTI_RESAMPLE_METADATA = Metadata(
    id="e71a66883dbc661cfc445c13c6c8a3b6b4db7894.workbench",
    name="cifti-resample",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_CiftiResampleWeightedParamsDictNoTag = typing.TypedDict('_CiftiResampleWeightedParamsDictNoTag', {
    "exponent": typing.NotRequired[float | None],
    "legacy-cutoff": bool,
})
CiftiResampleWeightedParamsDictTagged = typing.TypedDict('CiftiResampleWeightedParamsDictTagged', {
    "@type": typing.Literal["weighted"],
    "exponent": typing.NotRequired[float | None],
    "legacy-cutoff": bool,
})
CiftiResampleWeightedParamsDict = _CiftiResampleWeightedParamsDictNoTag | CiftiResampleWeightedParamsDictTagged


_CiftiResampleVolumePredilateParamsDictNoTag = typing.TypedDict('_CiftiResampleVolumePredilateParamsDictNoTag', {
    "dilate-mm": float,
    "weighted": typing.NotRequired[CiftiResampleWeightedParamsDict | None],
    "nearest": bool,
})
CiftiResampleVolumePredilateParamsDictTagged = typing.TypedDict('CiftiResampleVolumePredilateParamsDictTagged', {
    "@type": typing.Literal["volume-predilate"],
    "dilate-mm": float,
    "weighted": typing.NotRequired[CiftiResampleWeightedParamsDict | None],
    "nearest": bool,
})
CiftiResampleVolumePredilateParamsDict = _CiftiResampleVolumePredilateParamsDictNoTag | CiftiResampleVolumePredilateParamsDictTagged


_CiftiResampleWeightedParamsDict_NoTag = typing.TypedDict('_CiftiResampleWeightedParamsDict_NoTag', {
    "exponent": typing.NotRequired[float | None],
    "legacy-cutoff": bool,
})
CiftiResampleWeightedParamsDictTagged_ = typing.TypedDict('CiftiResampleWeightedParamsDictTagged_', {
    "@type": typing.Literal["weighted"],
    "exponent": typing.NotRequired[float | None],
    "legacy-cutoff": bool,
})
CiftiResampleWeightedParamsDict_ = _CiftiResampleWeightedParamsDict_NoTag | CiftiResampleWeightedParamsDictTagged_


_CiftiResampleSurfacePostdilateParamsDictNoTag = typing.TypedDict('_CiftiResampleSurfacePostdilateParamsDictNoTag', {
    "dilate-mm": float,
    "weighted": typing.NotRequired[CiftiResampleWeightedParamsDict_ | None],
    "linear": bool,
    "nearest": bool,
})
CiftiResampleSurfacePostdilateParamsDictTagged = typing.TypedDict('CiftiResampleSurfacePostdilateParamsDictTagged', {
    "@type": typing.Literal["surface-postdilate"],
    "dilate-mm": float,
    "weighted": typing.NotRequired[CiftiResampleWeightedParamsDict_ | None],
    "linear": bool,
    "nearest": bool,
})
CiftiResampleSurfacePostdilateParamsDict = _CiftiResampleSurfacePostdilateParamsDictNoTag | CiftiResampleSurfacePostdilateParamsDictTagged


_CiftiResampleFlirtParamsDictNoTag = typing.TypedDict('_CiftiResampleFlirtParamsDictNoTag', {
    "source-volume": str,
    "target-volume": str,
})
CiftiResampleFlirtParamsDictTagged = typing.TypedDict('CiftiResampleFlirtParamsDictTagged', {
    "@type": typing.Literal["flirt"],
    "source-volume": str,
    "target-volume": str,
})
CiftiResampleFlirtParamsDict = _CiftiResampleFlirtParamsDictNoTag | CiftiResampleFlirtParamsDictTagged


_CiftiResampleAffineParamsDictNoTag = typing.TypedDict('_CiftiResampleAffineParamsDictNoTag', {
    "affine-file": str,
    "flirt": typing.NotRequired[CiftiResampleFlirtParamsDict | None],
})
CiftiResampleAffineParamsDictTagged = typing.TypedDict('CiftiResampleAffineParamsDictTagged', {
    "@type": typing.Literal["affine"],
    "affine-file": str,
    "flirt": typing.NotRequired[CiftiResampleFlirtParamsDict | None],
})
CiftiResampleAffineParamsDict = _CiftiResampleAffineParamsDictNoTag | CiftiResampleAffineParamsDictTagged


_CiftiResampleWarpfieldParamsDictNoTag = typing.TypedDict('_CiftiResampleWarpfieldParamsDictNoTag', {
    "warpfield": str,
    "source-volume": typing.NotRequired[str | None],
})
CiftiResampleWarpfieldParamsDictTagged = typing.TypedDict('CiftiResampleWarpfieldParamsDictTagged', {
    "@type": typing.Literal["warpfield"],
    "warpfield": str,
    "source-volume": typing.NotRequired[str | None],
})
CiftiResampleWarpfieldParamsDict = _CiftiResampleWarpfieldParamsDictNoTag | CiftiResampleWarpfieldParamsDictTagged


_CiftiResampleLeftAreaSurfsParamsDictNoTag = typing.TypedDict('_CiftiResampleLeftAreaSurfsParamsDictNoTag', {
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleLeftAreaSurfsParamsDictTagged = typing.TypedDict('CiftiResampleLeftAreaSurfsParamsDictTagged', {
    "@type": typing.Literal["left-area-surfs"],
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleLeftAreaSurfsParamsDict = _CiftiResampleLeftAreaSurfsParamsDictNoTag | CiftiResampleLeftAreaSurfsParamsDictTagged


_CiftiResampleLeftAreaMetricsParamsDictNoTag = typing.TypedDict('_CiftiResampleLeftAreaMetricsParamsDictNoTag', {
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleLeftAreaMetricsParamsDictTagged = typing.TypedDict('CiftiResampleLeftAreaMetricsParamsDictTagged', {
    "@type": typing.Literal["left-area-metrics"],
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleLeftAreaMetricsParamsDict = _CiftiResampleLeftAreaMetricsParamsDictNoTag | CiftiResampleLeftAreaMetricsParamsDictTagged


_CiftiResampleLeftSpheresParamsDictNoTag = typing.TypedDict('_CiftiResampleLeftSpheresParamsDictNoTag', {
    "current-sphere": InputPathType,
    "new-sphere": InputPathType,
    "left-area-surfs": typing.NotRequired[CiftiResampleLeftAreaSurfsParamsDict | None],
    "left-area-metrics": typing.NotRequired[CiftiResampleLeftAreaMetricsParamsDict | None],
})
CiftiResampleLeftSpheresParamsDictTagged = typing.TypedDict('CiftiResampleLeftSpheresParamsDictTagged', {
    "@type": typing.Literal["left-spheres"],
    "current-sphere": InputPathType,
    "new-sphere": InputPathType,
    "left-area-surfs": typing.NotRequired[CiftiResampleLeftAreaSurfsParamsDict | None],
    "left-area-metrics": typing.NotRequired[CiftiResampleLeftAreaMetricsParamsDict | None],
})
CiftiResampleLeftSpheresParamsDict = _CiftiResampleLeftSpheresParamsDictNoTag | CiftiResampleLeftSpheresParamsDictTagged


_CiftiResampleRightAreaSurfsParamsDictNoTag = typing.TypedDict('_CiftiResampleRightAreaSurfsParamsDictNoTag', {
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleRightAreaSurfsParamsDictTagged = typing.TypedDict('CiftiResampleRightAreaSurfsParamsDictTagged', {
    "@type": typing.Literal["right-area-surfs"],
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleRightAreaSurfsParamsDict = _CiftiResampleRightAreaSurfsParamsDictNoTag | CiftiResampleRightAreaSurfsParamsDictTagged


_CiftiResampleRightAreaMetricsParamsDictNoTag = typing.TypedDict('_CiftiResampleRightAreaMetricsParamsDictNoTag', {
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleRightAreaMetricsParamsDictTagged = typing.TypedDict('CiftiResampleRightAreaMetricsParamsDictTagged', {
    "@type": typing.Literal["right-area-metrics"],
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleRightAreaMetricsParamsDict = _CiftiResampleRightAreaMetricsParamsDictNoTag | CiftiResampleRightAreaMetricsParamsDictTagged


_CiftiResampleRightSpheresParamsDictNoTag = typing.TypedDict('_CiftiResampleRightSpheresParamsDictNoTag', {
    "current-sphere": InputPathType,
    "new-sphere": InputPathType,
    "right-area-surfs": typing.NotRequired[CiftiResampleRightAreaSurfsParamsDict | None],
    "right-area-metrics": typing.NotRequired[CiftiResampleRightAreaMetricsParamsDict | None],
})
CiftiResampleRightSpheresParamsDictTagged = typing.TypedDict('CiftiResampleRightSpheresParamsDictTagged', {
    "@type": typing.Literal["right-spheres"],
    "current-sphere": InputPathType,
    "new-sphere": InputPathType,
    "right-area-surfs": typing.NotRequired[CiftiResampleRightAreaSurfsParamsDict | None],
    "right-area-metrics": typing.NotRequired[CiftiResampleRightAreaMetricsParamsDict | None],
})
CiftiResampleRightSpheresParamsDict = _CiftiResampleRightSpheresParamsDictNoTag | CiftiResampleRightSpheresParamsDictTagged


_CiftiResampleCerebellumAreaSurfsParamsDictNoTag = typing.TypedDict('_CiftiResampleCerebellumAreaSurfsParamsDictNoTag', {
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleCerebellumAreaSurfsParamsDictTagged = typing.TypedDict('CiftiResampleCerebellumAreaSurfsParamsDictTagged', {
    "@type": typing.Literal["cerebellum-area-surfs"],
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleCerebellumAreaSurfsParamsDict = _CiftiResampleCerebellumAreaSurfsParamsDictNoTag | CiftiResampleCerebellumAreaSurfsParamsDictTagged


_CiftiResampleCerebellumAreaMetricsParamsDictNoTag = typing.TypedDict('_CiftiResampleCerebellumAreaMetricsParamsDictNoTag', {
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleCerebellumAreaMetricsParamsDictTagged = typing.TypedDict('CiftiResampleCerebellumAreaMetricsParamsDictTagged', {
    "@type": typing.Literal["cerebellum-area-metrics"],
    "current-area": InputPathType,
    "new-area": InputPathType,
})
CiftiResampleCerebellumAreaMetricsParamsDict = _CiftiResampleCerebellumAreaMetricsParamsDictNoTag | CiftiResampleCerebellumAreaMetricsParamsDictTagged


_CiftiResampleCerebellumSpheresParamsDictNoTag = typing.TypedDict('_CiftiResampleCerebellumSpheresParamsDictNoTag', {
    "current-sphere": InputPathType,
    "new-sphere": InputPathType,
    "cerebellum-area-surfs": typing.NotRequired[CiftiResampleCerebellumAreaSurfsParamsDict | None],
    "cerebellum-area-metrics": typing.NotRequired[CiftiResampleCerebellumAreaMetricsParamsDict | None],
})
CiftiResampleCerebellumSpheresParamsDictTagged = typing.TypedDict('CiftiResampleCerebellumSpheresParamsDictTagged', {
    "@type": typing.Literal["cerebellum-spheres"],
    "current-sphere": InputPathType,
    "new-sphere": InputPathType,
    "cerebellum-area-surfs": typing.NotRequired[CiftiResampleCerebellumAreaSurfsParamsDict | None],
    "cerebellum-area-metrics": typing.NotRequired[CiftiResampleCerebellumAreaMetricsParamsDict | None],
})
CiftiResampleCerebellumSpheresParamsDict = _CiftiResampleCerebellumSpheresParamsDictNoTag | CiftiResampleCerebellumSpheresParamsDictTagged


_CiftiResampleParamsDictNoTag = typing.TypedDict('_CiftiResampleParamsDictNoTag', {
    "cifti-in": InputPathType,
    "direction": str,
    "cifti-template": InputPathType,
    "template-direction": str,
    "surface-method": str,
    "volume-method": str,
    "cifti-out": str,
    "volume-predilate": typing.NotRequired[CiftiResampleVolumePredilateParamsDict | None],
    "surface-postdilate": typing.NotRequired[CiftiResampleSurfacePostdilateParamsDict | None],
    "affine": typing.NotRequired[CiftiResampleAffineParamsDict | None],
    "warpfield": typing.NotRequired[CiftiResampleWarpfieldParamsDict | None],
    "left-spheres": typing.NotRequired[CiftiResampleLeftSpheresParamsDict | None],
    "right-spheres": typing.NotRequired[CiftiResampleRightSpheresParamsDict | None],
    "cerebellum-spheres": typing.NotRequired[CiftiResampleCerebellumSpheresParamsDict | None],
    "surface-largest": bool,
})
CiftiResampleParamsDictTagged = typing.TypedDict('CiftiResampleParamsDictTagged', {
    "@type": typing.Literal["workbench/cifti-resample"],
    "cifti-in": InputPathType,
    "direction": str,
    "cifti-template": InputPathType,
    "template-direction": str,
    "surface-method": str,
    "volume-method": str,
    "cifti-out": str,
    "volume-predilate": typing.NotRequired[CiftiResampleVolumePredilateParamsDict | None],
    "surface-postdilate": typing.NotRequired[CiftiResampleSurfacePostdilateParamsDict | None],
    "affine": typing.NotRequired[CiftiResampleAffineParamsDict | None],
    "warpfield": typing.NotRequired[CiftiResampleWarpfieldParamsDict | None],
    "left-spheres": typing.NotRequired[CiftiResampleLeftSpheresParamsDict | None],
    "right-spheres": typing.NotRequired[CiftiResampleRightSpheresParamsDict | None],
    "cerebellum-spheres": typing.NotRequired[CiftiResampleCerebellumSpheresParamsDict | None],
    "surface-largest": bool,
})
CiftiResampleParamsDict = _CiftiResampleParamsDictNoTag | CiftiResampleParamsDictTagged


def cifti_resample_weighted(
    exponent: float | None = None,
    legacy_cutoff: bool = False,
) -> CiftiResampleWeightedParamsDictTagged:
    """
    Build parameters.
    
    Args:
        exponent: specify exponent in weighting function\
            \
            exponent 'n' to use in (1 / (distance ^ n)) as the weighting\
            function (default 7).
        legacy_cutoff: use v1.3.2 logic for the kernel cutoff.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "weighted",
        "legacy-cutoff": legacy_cutoff,
    }
    if exponent is not None:
        params["exponent"] = exponent
    return params


def cifti_resample_weighted_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleWeightedParamsDict` 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("exponent", None) is not None:
        if not isinstance(params["exponent"], (float, int)):
            raise StyxValidationError(f'`exponent` has the wrong type: Received `{type(params.get("exponent", None))}` expected `float | None`')
    if params.get("legacy-cutoff", False) is None:
        raise StyxValidationError("`legacy-cutoff` must not be None")
    if not isinstance(params["legacy-cutoff"], bool):
        raise StyxValidationError(f'`legacy-cutoff` has the wrong type: Received `{type(params.get("legacy-cutoff", False))}` expected `bool`')


def cifti_resample_weighted_cargs(
    params: CiftiResampleWeightedParamsDict,
    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("-weighted")
    if params.get("exponent", None) is not None:
        cargs.extend([
            "-exponent",
            str(params.get("exponent", None))
        ])
    if params.get("legacy-cutoff", False):
        cargs.append("-legacy-cutoff")
    return cargs


def cifti_resample_volume_predilate(
    dilate_mm: float,
    weighted: CiftiResampleWeightedParamsDict | None = None,
    nearest: bool = False,
) -> CiftiResampleVolumePredilateParamsDictTagged:
    """
    Build parameters.
    
    Args:
        dilate_mm: distance, in mm, to dilate.
        weighted: use weighted dilation (default).
        nearest: use nearest value dilation.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "volume-predilate",
        "dilate-mm": dilate_mm,
        "nearest": nearest,
    }
    if weighted is not None:
        params["weighted"] = weighted
    return params


def cifti_resample_volume_predilate_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleVolumePredilateParamsDict` 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("dilate-mm", None) is None:
        raise StyxValidationError("`dilate-mm` must not be None")
    if not isinstance(params["dilate-mm"], (float, int)):
        raise StyxValidationError(f'`dilate-mm` has the wrong type: Received `{type(params.get("dilate-mm", None))}` expected `float`')
    if params.get("weighted", None) is not None:
        cifti_resample_weighted_validate(params["weighted"])
    if params.get("nearest", False) is None:
        raise StyxValidationError("`nearest` must not be None")
    if not isinstance(params["nearest"], bool):
        raise StyxValidationError(f'`nearest` has the wrong type: Received `{type(params.get("nearest", False))}` expected `bool`')


def cifti_resample_volume_predilate_cargs(
    params: CiftiResampleVolumePredilateParamsDict,
    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.extend([
        "-volume-predilate",
        str(params.get("dilate-mm", None)),
        *(cifti_resample_weighted_cargs(params.get("weighted", None), execution) if (params.get("weighted", None) is not None) else [])
    ])
    if params.get("nearest", False):
        cargs.append("-nearest")
    return cargs


def cifti_resample_weighted_(
    exponent: float | None = None,
    legacy_cutoff: bool = False,
) -> CiftiResampleWeightedParamsDictTagged_:
    """
    Build parameters.
    
    Args:
        exponent: specify exponent in weighting function\
            \
            exponent 'n' to use in (area / (distance ^ n)) as the weighting\
            function (default 6).
        legacy_cutoff: use v1.3.2 logic for the kernel cutoff.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "weighted",
        "legacy-cutoff": legacy_cutoff,
    }
    if exponent is not None:
        params["exponent"] = exponent
    return params


def cifti_resample_weighted_validate_(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleWeightedParamsDict_` 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("exponent", None) is not None:
        if not isinstance(params["exponent"], (float, int)):
            raise StyxValidationError(f'`exponent` has the wrong type: Received `{type(params.get("exponent", None))}` expected `float | None`')
    if params.get("legacy-cutoff", False) is None:
        raise StyxValidationError("`legacy-cutoff` must not be None")
    if not isinstance(params["legacy-cutoff"], bool):
        raise StyxValidationError(f'`legacy-cutoff` has the wrong type: Received `{type(params.get("legacy-cutoff", False))}` expected `bool`')


def cifti_resample_weighted_cargs_(
    params: CiftiResampleWeightedParamsDict_,
    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("-weighted")
    if params.get("exponent", None) is not None:
        cargs.extend([
            "-exponent",
            str(params.get("exponent", None))
        ])
    if params.get("legacy-cutoff", False):
        cargs.append("-legacy-cutoff")
    return cargs


def cifti_resample_surface_postdilate(
    dilate_mm: float,
    weighted: CiftiResampleWeightedParamsDict_ | None = None,
    linear: bool = False,
    nearest: bool = False,
) -> CiftiResampleSurfacePostdilateParamsDictTagged:
    """
    Build parameters.
    
    Args:
        dilate_mm: distance, in mm, to dilate.
        weighted: use weighted dilation (default for non-label data).
        linear: use linear dilation.
        nearest: use nearest value dilation.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "surface-postdilate",
        "dilate-mm": dilate_mm,
        "linear": linear,
        "nearest": nearest,
    }
    if weighted is not None:
        params["weighted"] = weighted
    return params


def cifti_resample_surface_postdilate_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleSurfacePostdilateParamsDict` 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("dilate-mm", None) is None:
        raise StyxValidationError("`dilate-mm` must not be None")
    if not isinstance(params["dilate-mm"], (float, int)):
        raise StyxValidationError(f'`dilate-mm` has the wrong type: Received `{type(params.get("dilate-mm", None))}` expected `float`')
    if params.get("weighted", None) is not None:
        cifti_resample_weighted_validate_(params["weighted"])
    if params.get("linear", False) is None:
        raise StyxValidationError("`linear` must not be None")
    if not isinstance(params["linear"], bool):
        raise StyxValidationError(f'`linear` has the wrong type: Received `{type(params.get("linear", False))}` expected `bool`')
    if params.get("nearest", False) is None:
        raise StyxValidationError("`nearest` must not be None")
    if not isinstance(params["nearest"], bool):
        raise StyxValidationError(f'`nearest` has the wrong type: Received `{type(params.get("nearest", False))}` expected `bool`')


def cifti_resample_surface_postdilate_cargs(
    params: CiftiResampleSurfacePostdilateParamsDict,
    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.extend([
        "-surface-postdilate",
        str(params.get("dilate-mm", None)),
        *(cifti_resample_weighted_cargs_(params.get("weighted", None), execution) if (params.get("weighted", None) is not None) else [])
    ])
    if params.get("linear", False):
        cargs.append("-linear")
    if params.get("nearest", False):
        cargs.append("-nearest")
    return cargs


def cifti_resample_flirt(
    source_volume: str,
    target_volume: str,
) -> CiftiResampleFlirtParamsDictTagged:
    """
    Build parameters.
    
    Args:
        source_volume: the source volume used when generating the affine.
        target_volume: the target volume used when generating the affine.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "flirt",
        "source-volume": source_volume,
        "target-volume": target_volume,
    }
    return params


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


def cifti_resample_flirt_cargs(
    params: CiftiResampleFlirtParamsDict,
    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.extend([
        "-flirt",
        params.get("source-volume", None),
        params.get("target-volume", None)
    ])
    return cargs


def cifti_resample_affine(
    affine_file: str,
    flirt: CiftiResampleFlirtParamsDict | None = None,
) -> CiftiResampleAffineParamsDictTagged:
    """
    Build parameters.
    
    Args:
        affine_file: the affine file to use.
        flirt: MUST be used if affine is a flirt affine.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "affine",
        "affine-file": affine_file,
    }
    if flirt is not None:
        params["flirt"] = flirt
    return params


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


def cifti_resample_affine_cargs(
    params: CiftiResampleAffineParamsDict,
    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.extend([
        "-affine",
        params.get("affine-file", None),
        *(cifti_resample_flirt_cargs(params.get("flirt", None), execution) if (params.get("flirt", None) is not None) else [])
    ])
    return cargs


def cifti_resample_warpfield(
    warpfield: str,
    source_volume: str | None = None,
) -> CiftiResampleWarpfieldParamsDictTagged:
    """
    Build parameters.
    
    Args:
        warpfield: the warpfield to use.
        source_volume: MUST be used if using a fnirt warpfield\
            \
            the source volume used when generating the warpfield.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "warpfield",
        "warpfield": warpfield,
    }
    if source_volume is not None:
        params["source-volume"] = source_volume
    return params


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


def cifti_resample_warpfield_cargs(
    params: CiftiResampleWarpfieldParamsDict,
    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.extend([
        "-warpfield",
        params.get("warpfield", None)
    ])
    if params.get("source-volume", None) is not None:
        cargs.extend([
            "-fnirt",
            params.get("source-volume", None)
        ])
    return cargs


def cifti_resample_left_area_surfs(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleLeftAreaSurfsParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_area: a relevant left anatomical surface with current mesh.
        new_area: a relevant left anatomical surface with new mesh.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "left-area-surfs",
        "current-area": current_area,
        "new-area": new_area,
    }
    return params


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


def cifti_resample_left_area_surfs_cargs(
    params: CiftiResampleLeftAreaSurfsParamsDict,
    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.extend([
        "-left-area-surfs",
        execution.input_file(params.get("current-area", None)),
        execution.input_file(params.get("new-area", None))
    ])
    return cargs


def cifti_resample_left_area_metrics(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleLeftAreaMetricsParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_area: a metric file with vertex areas for the current mesh.
        new_area: a metric file with vertex areas for the new mesh.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "left-area-metrics",
        "current-area": current_area,
        "new-area": new_area,
    }
    return params


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


def cifti_resample_left_area_metrics_cargs(
    params: CiftiResampleLeftAreaMetricsParamsDict,
    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.extend([
        "-left-area-metrics",
        execution.input_file(params.get("current-area", None)),
        execution.input_file(params.get("new-area", None))
    ])
    return cargs


def cifti_resample_left_spheres(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    left_area_surfs: CiftiResampleLeftAreaSurfsParamsDict | None = None,
    left_area_metrics: CiftiResampleLeftAreaMetricsParamsDict | None = None,
) -> CiftiResampleLeftSpheresParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_sphere: a sphere with the same mesh as the current left surface.
        new_sphere: a sphere with the new left mesh that is in register with\
            the current sphere.
        left_area_surfs: specify left surfaces to do vertex area correction\
            based on.
        left_area_metrics: specify left vertex area metrics to do area\
            correction based on.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "left-spheres",
        "current-sphere": current_sphere,
        "new-sphere": new_sphere,
    }
    if left_area_surfs is not None:
        params["left-area-surfs"] = left_area_surfs
    if left_area_metrics is not None:
        params["left-area-metrics"] = left_area_metrics
    return params


def cifti_resample_left_spheres_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleLeftSpheresParamsDict` 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("current-sphere", None) is None:
        raise StyxValidationError("`current-sphere` must not be None")
    if not isinstance(params["current-sphere"], (pathlib.Path, str)):
        raise StyxValidationError(f'`current-sphere` has the wrong type: Received `{type(params.get("current-sphere", None))}` expected `InputPathType`')
    if params.get("new-sphere", None) is None:
        raise StyxValidationError("`new-sphere` must not be None")
    if not isinstance(params["new-sphere"], (pathlib.Path, str)):
        raise StyxValidationError(f'`new-sphere` has the wrong type: Received `{type(params.get("new-sphere", None))}` expected `InputPathType`')
    if params.get("left-area-surfs", None) is not None:
        cifti_resample_left_area_surfs_validate(params["left-area-surfs"])
    if params.get("left-area-metrics", None) is not None:
        cifti_resample_left_area_metrics_validate(params["left-area-metrics"])


def cifti_resample_left_spheres_cargs(
    params: CiftiResampleLeftSpheresParamsDict,
    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.extend([
        "-left-spheres",
        execution.input_file(params.get("current-sphere", None)),
        execution.input_file(params.get("new-sphere", None)),
        *(cifti_resample_left_area_surfs_cargs(params.get("left-area-surfs", None), execution) if (params.get("left-area-surfs", None) is not None) else []),
        *(cifti_resample_left_area_metrics_cargs(params.get("left-area-metrics", None), execution) if (params.get("left-area-metrics", None) is not None) else [])
    ])
    return cargs


def cifti_resample_right_area_surfs(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleRightAreaSurfsParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_area: a relevant right anatomical surface with current mesh.
        new_area: a relevant right anatomical surface with new mesh.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "right-area-surfs",
        "current-area": current_area,
        "new-area": new_area,
    }
    return params


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


def cifti_resample_right_area_surfs_cargs(
    params: CiftiResampleRightAreaSurfsParamsDict,
    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.extend([
        "-right-area-surfs",
        execution.input_file(params.get("current-area", None)),
        execution.input_file(params.get("new-area", None))
    ])
    return cargs


def cifti_resample_right_area_metrics(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleRightAreaMetricsParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_area: a metric file with vertex areas for the current mesh.
        new_area: a metric file with vertex areas for the new mesh.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "right-area-metrics",
        "current-area": current_area,
        "new-area": new_area,
    }
    return params


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


def cifti_resample_right_area_metrics_cargs(
    params: CiftiResampleRightAreaMetricsParamsDict,
    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.extend([
        "-right-area-metrics",
        execution.input_file(params.get("current-area", None)),
        execution.input_file(params.get("new-area", None))
    ])
    return cargs


def cifti_resample_right_spheres(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    right_area_surfs: CiftiResampleRightAreaSurfsParamsDict | None = None,
    right_area_metrics: CiftiResampleRightAreaMetricsParamsDict | None = None,
) -> CiftiResampleRightSpheresParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_sphere: a sphere with the same mesh as the current right\
            surface.
        new_sphere: a sphere with the new right mesh that is in register with\
            the current sphere.
        right_area_surfs: specify right surfaces to do vertex area correction\
            based on.
        right_area_metrics: specify right vertex area metrics to do area\
            correction based on.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "right-spheres",
        "current-sphere": current_sphere,
        "new-sphere": new_sphere,
    }
    if right_area_surfs is not None:
        params["right-area-surfs"] = right_area_surfs
    if right_area_metrics is not None:
        params["right-area-metrics"] = right_area_metrics
    return params


def cifti_resample_right_spheres_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleRightSpheresParamsDict` 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("current-sphere", None) is None:
        raise StyxValidationError("`current-sphere` must not be None")
    if not isinstance(params["current-sphere"], (pathlib.Path, str)):
        raise StyxValidationError(f'`current-sphere` has the wrong type: Received `{type(params.get("current-sphere", None))}` expected `InputPathType`')
    if params.get("new-sphere", None) is None:
        raise StyxValidationError("`new-sphere` must not be None")
    if not isinstance(params["new-sphere"], (pathlib.Path, str)):
        raise StyxValidationError(f'`new-sphere` has the wrong type: Received `{type(params.get("new-sphere", None))}` expected `InputPathType`')
    if params.get("right-area-surfs", None) is not None:
        cifti_resample_right_area_surfs_validate(params["right-area-surfs"])
    if params.get("right-area-metrics", None) is not None:
        cifti_resample_right_area_metrics_validate(params["right-area-metrics"])


def cifti_resample_right_spheres_cargs(
    params: CiftiResampleRightSpheresParamsDict,
    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.extend([
        "-right-spheres",
        execution.input_file(params.get("current-sphere", None)),
        execution.input_file(params.get("new-sphere", None)),
        *(cifti_resample_right_area_surfs_cargs(params.get("right-area-surfs", None), execution) if (params.get("right-area-surfs", None) is not None) else []),
        *(cifti_resample_right_area_metrics_cargs(params.get("right-area-metrics", None), execution) if (params.get("right-area-metrics", None) is not None) else [])
    ])
    return cargs


def cifti_resample_cerebellum_area_surfs(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleCerebellumAreaSurfsParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_area: a relevant cerebellum anatomical surface with current\
            mesh.
        new_area: a relevant cerebellum anatomical surface with new mesh.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "cerebellum-area-surfs",
        "current-area": current_area,
        "new-area": new_area,
    }
    return params


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


def cifti_resample_cerebellum_area_surfs_cargs(
    params: CiftiResampleCerebellumAreaSurfsParamsDict,
    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.extend([
        "-cerebellum-area-surfs",
        execution.input_file(params.get("current-area", None)),
        execution.input_file(params.get("new-area", None))
    ])
    return cargs


def cifti_resample_cerebellum_area_metrics(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleCerebellumAreaMetricsParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_area: a metric file with vertex areas for the current mesh.
        new_area: a metric file with vertex areas for the new mesh.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "cerebellum-area-metrics",
        "current-area": current_area,
        "new-area": new_area,
    }
    return params


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


def cifti_resample_cerebellum_area_metrics_cargs(
    params: CiftiResampleCerebellumAreaMetricsParamsDict,
    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.extend([
        "-cerebellum-area-metrics",
        execution.input_file(params.get("current-area", None)),
        execution.input_file(params.get("new-area", None))
    ])
    return cargs


def cifti_resample_cerebellum_spheres(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    cerebellum_area_surfs: CiftiResampleCerebellumAreaSurfsParamsDict | None = None,
    cerebellum_area_metrics: CiftiResampleCerebellumAreaMetricsParamsDict | None = None,
) -> CiftiResampleCerebellumSpheresParamsDictTagged:
    """
    Build parameters.
    
    Args:
        current_sphere: a sphere with the same mesh as the current cerebellum\
            surface.
        new_sphere: a sphere with the new cerebellum mesh that is in register\
            with the current sphere.
        cerebellum_area_surfs: specify cerebellum surfaces to do vertex area\
            correction based on.
        cerebellum_area_metrics: specify cerebellum vertex area metrics to do\
            area correction based on.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "cerebellum-spheres",
        "current-sphere": current_sphere,
        "new-sphere": new_sphere,
    }
    if cerebellum_area_surfs is not None:
        params["cerebellum-area-surfs"] = cerebellum_area_surfs
    if cerebellum_area_metrics is not None:
        params["cerebellum-area-metrics"] = cerebellum_area_metrics
    return params


def cifti_resample_cerebellum_spheres_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleCerebellumSpheresParamsDict` 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("current-sphere", None) is None:
        raise StyxValidationError("`current-sphere` must not be None")
    if not isinstance(params["current-sphere"], (pathlib.Path, str)):
        raise StyxValidationError(f'`current-sphere` has the wrong type: Received `{type(params.get("current-sphere", None))}` expected `InputPathType`')
    if params.get("new-sphere", None) is None:
        raise StyxValidationError("`new-sphere` must not be None")
    if not isinstance(params["new-sphere"], (pathlib.Path, str)):
        raise StyxValidationError(f'`new-sphere` has the wrong type: Received `{type(params.get("new-sphere", None))}` expected `InputPathType`')
    if params.get("cerebellum-area-surfs", None) is not None:
        cifti_resample_cerebellum_area_surfs_validate(params["cerebellum-area-surfs"])
    if params.get("cerebellum-area-metrics", None) is not None:
        cifti_resample_cerebellum_area_metrics_validate(params["cerebellum-area-metrics"])


def cifti_resample_cerebellum_spheres_cargs(
    params: CiftiResampleCerebellumSpheresParamsDict,
    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.extend([
        "-cerebellum-spheres",
        execution.input_file(params.get("current-sphere", None)),
        execution.input_file(params.get("new-sphere", None)),
        *(cifti_resample_cerebellum_area_surfs_cargs(params.get("cerebellum-area-surfs", None), execution) if (params.get("cerebellum-area-surfs", None) is not None) else []),
        *(cifti_resample_cerebellum_area_metrics_cargs(params.get("cerebellum-area-metrics", None), execution) if (params.get("cerebellum-area-metrics", None) is not None) else [])
    ])
    return cargs


class CiftiResampleOutputs(typing.NamedTuple):
    """
    Output object returned when calling `CiftiResampleParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    cifti_out: OutputPathType
    """the output cifti file"""


def cifti_resample_params(
    cifti_in: InputPathType,
    direction: str,
    cifti_template: InputPathType,
    template_direction: str,
    surface_method: str,
    volume_method: str,
    cifti_out: str,
    volume_predilate: CiftiResampleVolumePredilateParamsDict | None = None,
    surface_postdilate: CiftiResampleSurfacePostdilateParamsDict | None = None,
    affine: CiftiResampleAffineParamsDict | None = None,
    warpfield: CiftiResampleWarpfieldParamsDict | None = None,
    left_spheres: CiftiResampleLeftSpheresParamsDict | None = None,
    right_spheres: CiftiResampleRightSpheresParamsDict | None = None,
    cerebellum_spheres: CiftiResampleCerebellumSpheresParamsDict | None = None,
    surface_largest: bool = False,
) -> CiftiResampleParamsDictTagged:
    """
    Build parameters.
    
    Args:
        cifti_in: the cifti file to resample.
        direction: the direction of the input that should be resampled, ROW or\
            COLUMN.
        cifti_template: a cifti file containing the cifti space to resample to.
        template_direction: the direction of the template to use as the\
            resampling space, ROW or COLUMN.
        surface_method: specify a surface resampling method.
        volume_method: specify a volume interpolation method.
        cifti_out: the output cifti file.
        volume_predilate: dilate the volume components before resampling.
        surface_postdilate: dilate the surface components after resampling.
        affine: use an affine transformation on the volume components.
        warpfield: use a warpfield on the volume components.
        left_spheres: specify spheres for left surface resampling.
        right_spheres: specify spheres for right surface resampling.
        cerebellum_spheres: specify spheres for cerebellum surface resampling.
        surface_largest: use largest weight instead of weighted average or\
            popularity when doing surface resampling.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/cifti-resample",
        "cifti-in": cifti_in,
        "direction": direction,
        "cifti-template": cifti_template,
        "template-direction": template_direction,
        "surface-method": surface_method,
        "volume-method": volume_method,
        "cifti-out": cifti_out,
        "surface-largest": surface_largest,
    }
    if volume_predilate is not None:
        params["volume-predilate"] = volume_predilate
    if surface_postdilate is not None:
        params["surface-postdilate"] = surface_postdilate
    if affine is not None:
        params["affine"] = affine
    if warpfield is not None:
        params["warpfield"] = warpfield
    if left_spheres is not None:
        params["left-spheres"] = left_spheres
    if right_spheres is not None:
        params["right-spheres"] = right_spheres
    if cerebellum_spheres is not None:
        params["cerebellum-spheres"] = cerebellum_spheres
    return params


def cifti_resample_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `CiftiResampleParamsDict` 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("cifti-in", None) is None:
        raise StyxValidationError("`cifti-in` must not be None")
    if not isinstance(params["cifti-in"], (pathlib.Path, str)):
        raise StyxValidationError(f'`cifti-in` has the wrong type: Received `{type(params.get("cifti-in", None))}` expected `InputPathType`')
    if params.get("direction", None) is None:
        raise StyxValidationError("`direction` must not be None")
    if not isinstance(params["direction"], str):
        raise StyxValidationError(f'`direction` has the wrong type: Received `{type(params.get("direction", None))}` expected `str`')
    if params.get("cifti-template", None) is None:
        raise StyxValidationError("`cifti-template` must not be None")
    if not isinstance(params["cifti-template"], (pathlib.Path, str)):
        raise StyxValidationError(f'`cifti-template` has the wrong type: Received `{type(params.get("cifti-template", None))}` expected `InputPathType`')
    if params.get("template-direction", None) is None:
        raise StyxValidationError("`template-direction` must not be None")
    if not isinstance(params["template-direction"], str):
        raise StyxValidationError(f'`template-direction` has the wrong type: Received `{type(params.get("template-direction", None))}` expected `str`')
    if params.get("surface-method", None) is None:
        raise StyxValidationError("`surface-method` must not be None")
    if not isinstance(params["surface-method"], str):
        raise StyxValidationError(f'`surface-method` has the wrong type: Received `{type(params.get("surface-method", None))}` expected `str`')
    if params.get("volume-method", None) is None:
        raise StyxValidationError("`volume-method` must not be None")
    if not isinstance(params["volume-method"], str):
        raise StyxValidationError(f'`volume-method` has the wrong type: Received `{type(params.get("volume-method", None))}` expected `str`')
    if params.get("cifti-out", None) is None:
        raise StyxValidationError("`cifti-out` must not be None")
    if not isinstance(params["cifti-out"], str):
        raise StyxValidationError(f'`cifti-out` has the wrong type: Received `{type(params.get("cifti-out", None))}` expected `str`')
    if params.get("volume-predilate", None) is not None:
        cifti_resample_volume_predilate_validate(params["volume-predilate"])
    if params.get("surface-postdilate", None) is not None:
        cifti_resample_surface_postdilate_validate(params["surface-postdilate"])
    if params.get("affine", None) is not None:
        cifti_resample_affine_validate(params["affine"])
    if params.get("warpfield", None) is not None:
        cifti_resample_warpfield_validate(params["warpfield"])
    if params.get("left-spheres", None) is not None:
        cifti_resample_left_spheres_validate(params["left-spheres"])
    if params.get("right-spheres", None) is not None:
        cifti_resample_right_spheres_validate(params["right-spheres"])
    if params.get("cerebellum-spheres", None) is not None:
        cifti_resample_cerebellum_spheres_validate(params["cerebellum-spheres"])
    if params.get("surface-largest", False) is None:
        raise StyxValidationError("`surface-largest` must not be None")
    if not isinstance(params["surface-largest"], bool):
        raise StyxValidationError(f'`surface-largest` has the wrong type: Received `{type(params.get("surface-largest", False))}` expected `bool`')


def cifti_resample_cargs(
    params: CiftiResampleParamsDict,
    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.extend([
        "wb_command",
        "-cifti-resample"
    ])
    cargs.append(execution.input_file(params.get("cifti-in", None)))
    cargs.append(params.get("direction", None))
    cargs.append(execution.input_file(params.get("cifti-template", None)))
    cargs.append(params.get("template-direction", None))
    cargs.append(params.get("surface-method", None))
    cargs.append(params.get("volume-method", None))
    cargs.append(params.get("cifti-out", None))
    if params.get("volume-predilate", None) is not None or params.get("surface-postdilate", None) is not None or params.get("affine", None) is not None or params.get("warpfield", None) is not None or params.get("left-spheres", None) is not None or params.get("right-spheres", None) is not None or params.get("cerebellum-spheres", None) is not None:
        cargs.extend([
            *(cifti_resample_volume_predilate_cargs(params.get("volume-predilate", None), execution) if (params.get("volume-predilate", None) is not None) else []),
            *(cifti_resample_surface_postdilate_cargs(params.get("surface-postdilate", None), execution) if (params.get("surface-postdilate", None) is not None) else []),
            *(cifti_resample_affine_cargs(params.get("affine", None), execution) if (params.get("affine", None) is not None) else []),
            *(cifti_resample_warpfield_cargs(params.get("warpfield", None), execution) if (params.get("warpfield", None) is not None) else []),
            *(cifti_resample_left_spheres_cargs(params.get("left-spheres", None), execution) if (params.get("left-spheres", None) is not None) else []),
            *(cifti_resample_right_spheres_cargs(params.get("right-spheres", None), execution) if (params.get("right-spheres", None) is not None) else []),
            *(cifti_resample_cerebellum_spheres_cargs(params.get("cerebellum-spheres", None), execution) if (params.get("cerebellum-spheres", None) is not None) else [])
        ])
    if params.get("surface-largest", False):
        cargs.append("-surface-largest")
    return cargs


def cifti_resample_outputs(
    params: CiftiResampleParamsDict,
    execution: Execution,
) -> CiftiResampleOutputs:
    """
    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 = CiftiResampleOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(params.get("cifti-out", None)),
    )
    return ret


def cifti_resample_execute(
    params: CiftiResampleParamsDict,
    runner: Runner | None = None,
) -> CiftiResampleOutputs:
    """
    RESAMPLE A CIFTI FILE TO A NEW CIFTI SPACE.
    
    Resample cifti data to a different brainordinate space. Use COLUMN for the
    direction to resample dscalar, dlabel, or dtseries. Resampling both
    dimensions of a dconn requires running this command twice, once with COLUMN
    and once with ROW. If you are resampling a dconn and your machine has a
    large amount of memory, you might consider using
    -cifti-resample-dconn-memory to avoid writing and rereading an intermediate
    file. The <template-direction> argument should usually be COLUMN, as
    dtseries, dscalar, and dlabel all have brainordinates on that direction. If
    spheres are not specified for a surface structure which exists in the cifti
    files, its data is copied without resampling or dilation. Dilation is done
    with the 'nearest' method, and is done on <new-sphere> for surface data.
    Volume components are padded before dilation so that dilation doesn't run
    into the edge of the component bounding box. If neither -affine nor
    -warpfield are specified, the identity transform is assumed for the volume
    data.
    
    The recommended resampling methods are ADAP_BARY_AREA and CUBIC (cubic
    spline), except for label data which should use ADAP_BARY_AREA and
    ENCLOSING_VOXEL. Using ADAP_BARY_AREA requires specifying an area option to
    each used -*-spheres option.
    
    The <volume-method> argument must be one of the following:
    
    CUBIC
    ENCLOSING_VOXEL
    TRILINEAR
    
    The <surface-method> argument must be one of the following:
    
    ADAP_BARY_AREA
    BARYCENTRIC
    .
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiResampleOutputs`).
    """
    cifti_resample_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_RESAMPLE_METADATA)
    params = execution.params(params)
    cargs = cifti_resample_cargs(params, execution)
    ret = cifti_resample_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_resample(
    cifti_in: InputPathType,
    direction: str,
    cifti_template: InputPathType,
    template_direction: str,
    surface_method: str,
    volume_method: str,
    cifti_out: str,
    volume_predilate: CiftiResampleVolumePredilateParamsDict | None = None,
    surface_postdilate: CiftiResampleSurfacePostdilateParamsDict | None = None,
    affine: CiftiResampleAffineParamsDict | None = None,
    warpfield: CiftiResampleWarpfieldParamsDict | None = None,
    left_spheres: CiftiResampleLeftSpheresParamsDict | None = None,
    right_spheres: CiftiResampleRightSpheresParamsDict | None = None,
    cerebellum_spheres: CiftiResampleCerebellumSpheresParamsDict | None = None,
    surface_largest: bool = False,
    runner: Runner | None = None,
) -> CiftiResampleOutputs:
    """
    RESAMPLE A CIFTI FILE TO A NEW CIFTI SPACE.
    
    Resample cifti data to a different brainordinate space. Use COLUMN for the
    direction to resample dscalar, dlabel, or dtseries. Resampling both
    dimensions of a dconn requires running this command twice, once with COLUMN
    and once with ROW. If you are resampling a dconn and your machine has a
    large amount of memory, you might consider using
    -cifti-resample-dconn-memory to avoid writing and rereading an intermediate
    file. The <template-direction> argument should usually be COLUMN, as
    dtseries, dscalar, and dlabel all have brainordinates on that direction. If
    spheres are not specified for a surface structure which exists in the cifti
    files, its data is copied without resampling or dilation. Dilation is done
    with the 'nearest' method, and is done on <new-sphere> for surface data.
    Volume components are padded before dilation so that dilation doesn't run
    into the edge of the component bounding box. If neither -affine nor
    -warpfield are specified, the identity transform is assumed for the volume
    data.
    
    The recommended resampling methods are ADAP_BARY_AREA and CUBIC (cubic
    spline), except for label data which should use ADAP_BARY_AREA and
    ENCLOSING_VOXEL. Using ADAP_BARY_AREA requires specifying an area option to
    each used -*-spheres option.
    
    The <volume-method> argument must be one of the following:
    
    CUBIC
    ENCLOSING_VOXEL
    TRILINEAR
    
    The <surface-method> argument must be one of the following:
    
    ADAP_BARY_AREA
    BARYCENTRIC
    .
    
    Args:
        cifti_in: the cifti file to resample.
        direction: the direction of the input that should be resampled, ROW or\
            COLUMN.
        cifti_template: a cifti file containing the cifti space to resample to.
        template_direction: the direction of the template to use as the\
            resampling space, ROW or COLUMN.
        surface_method: specify a surface resampling method.
        volume_method: specify a volume interpolation method.
        cifti_out: the output cifti file.
        volume_predilate: dilate the volume components before resampling.
        surface_postdilate: dilate the surface components after resampling.
        affine: use an affine transformation on the volume components.
        warpfield: use a warpfield on the volume components.
        left_spheres: specify spheres for left surface resampling.
        right_spheres: specify spheres for right surface resampling.
        cerebellum_spheres: specify spheres for cerebellum surface resampling.
        surface_largest: use largest weight instead of weighted average or\
            popularity when doing surface resampling.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiResampleOutputs`).
    """
    params = cifti_resample_params(
        cifti_in=cifti_in,
        direction=direction,
        cifti_template=cifti_template,
        template_direction=template_direction,
        surface_method=surface_method,
        volume_method=volume_method,
        cifti_out=cifti_out,
        volume_predilate=volume_predilate,
        surface_postdilate=surface_postdilate,
        affine=affine,
        warpfield=warpfield,
        left_spheres=left_spheres,
        right_spheres=right_spheres,
        cerebellum_spheres=cerebellum_spheres,
        surface_largest=surface_largest,
    )
    return cifti_resample_execute(params, runner)


__all__ = [
    "CIFTI_RESAMPLE_METADATA",
    "CiftiResampleAffineParamsDict",
    "CiftiResampleAffineParamsDictTagged",
    "CiftiResampleCerebellumAreaMetricsParamsDict",
    "CiftiResampleCerebellumAreaMetricsParamsDictTagged",
    "CiftiResampleCerebellumAreaSurfsParamsDict",
    "CiftiResampleCerebellumAreaSurfsParamsDictTagged",
    "CiftiResampleCerebellumSpheresParamsDict",
    "CiftiResampleCerebellumSpheresParamsDictTagged",
    "CiftiResampleFlirtParamsDict",
    "CiftiResampleFlirtParamsDictTagged",
    "CiftiResampleLeftAreaMetricsParamsDict",
    "CiftiResampleLeftAreaMetricsParamsDictTagged",
    "CiftiResampleLeftAreaSurfsParamsDict",
    "CiftiResampleLeftAreaSurfsParamsDictTagged",
    "CiftiResampleLeftSpheresParamsDict",
    "CiftiResampleLeftSpheresParamsDictTagged",
    "CiftiResampleOutputs",
    "CiftiResampleParamsDict",
    "CiftiResampleParamsDictTagged",
    "CiftiResampleRightAreaMetricsParamsDict",
    "CiftiResampleRightAreaMetricsParamsDictTagged",
    "CiftiResampleRightAreaSurfsParamsDict",
    "CiftiResampleRightAreaSurfsParamsDictTagged",
    "CiftiResampleRightSpheresParamsDict",
    "CiftiResampleRightSpheresParamsDictTagged",
    "CiftiResampleSurfacePostdilateParamsDict",
    "CiftiResampleSurfacePostdilateParamsDictTagged",
    "CiftiResampleVolumePredilateParamsDict",
    "CiftiResampleVolumePredilateParamsDictTagged",
    "CiftiResampleWarpfieldParamsDict",
    "CiftiResampleWarpfieldParamsDictTagged",
    "CiftiResampleWeightedParamsDict",
    "CiftiResampleWeightedParamsDictTagged",
    "CiftiResampleWeightedParamsDictTagged_",
    "CiftiResampleWeightedParamsDict_",
    "cifti_resample",
    "cifti_resample_affine",
    "cifti_resample_cerebellum_area_metrics",
    "cifti_resample_cerebellum_area_surfs",
    "cifti_resample_cerebellum_spheres",
    "cifti_resample_execute",
    "cifti_resample_flirt",
    "cifti_resample_left_area_metrics",
    "cifti_resample_left_area_surfs",
    "cifti_resample_left_spheres",
    "cifti_resample_params",
    "cifti_resample_right_area_metrics",
    "cifti_resample_right_area_surfs",
    "cifti_resample_right_spheres",
    "cifti_resample_surface_postdilate",
    "cifti_resample_volume_predilate",
    "cifti_resample_warpfield",
    "cifti_resample_weighted",
    "cifti_resample_weighted_",
]
