# 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="a6f5b36fba078762807c4f82e3c0374ec2f78287.boutiques",
    name="cifti-resample",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


CiftiResampleWeightedParameters = typing.TypedDict('CiftiResampleWeightedParameters', {
    "@type": typing.NotRequired[typing.Literal["weighted"]],
    "opt_exponent_exponent": typing.NotRequired[float | None],
    "opt_legacy_cutoff": bool,
})
CiftiResampleWeightedParametersTagged = typing.TypedDict('CiftiResampleWeightedParametersTagged', {
    "@type": typing.Literal["weighted"],
    "opt_exponent_exponent": typing.NotRequired[float | None],
    "opt_legacy_cutoff": bool,
})


CiftiResampleVolumePredilateParameters = typing.TypedDict('CiftiResampleVolumePredilateParameters', {
    "@type": typing.NotRequired[typing.Literal["volume_predilate"]],
    "dilate_mm": float,
    "opt_nearest": bool,
    "weighted": typing.NotRequired[CiftiResampleWeightedParameters | None],
})
CiftiResampleVolumePredilateParametersTagged = typing.TypedDict('CiftiResampleVolumePredilateParametersTagged', {
    "@type": typing.Literal["volume_predilate"],
    "dilate_mm": float,
    "opt_nearest": bool,
    "weighted": typing.NotRequired[CiftiResampleWeightedParameters | None],
})


CiftiResampleWeighted1Parameters = typing.TypedDict('CiftiResampleWeighted1Parameters', {
    "@type": typing.NotRequired[typing.Literal["weighted_1"]],
    "opt_exponent_exponent": typing.NotRequired[float | None],
    "opt_legacy_cutoff": bool,
})
CiftiResampleWeighted1ParametersTagged = typing.TypedDict('CiftiResampleWeighted1ParametersTagged', {
    "@type": typing.Literal["weighted_1"],
    "opt_exponent_exponent": typing.NotRequired[float | None],
    "opt_legacy_cutoff": bool,
})


CiftiResampleSurfacePostdilateParameters = typing.TypedDict('CiftiResampleSurfacePostdilateParameters', {
    "@type": typing.NotRequired[typing.Literal["surface_postdilate"]],
    "dilate_mm": float,
    "opt_nearest": bool,
    "opt_linear": bool,
    "weighted": typing.NotRequired[CiftiResampleWeighted1Parameters | None],
})
CiftiResampleSurfacePostdilateParametersTagged = typing.TypedDict('CiftiResampleSurfacePostdilateParametersTagged', {
    "@type": typing.Literal["surface_postdilate"],
    "dilate_mm": float,
    "opt_nearest": bool,
    "opt_linear": bool,
    "weighted": typing.NotRequired[CiftiResampleWeighted1Parameters | None],
})


CiftiResampleFlirtParameters = typing.TypedDict('CiftiResampleFlirtParameters', {
    "@type": typing.NotRequired[typing.Literal["flirt"]],
    "source_volume": str,
    "target_volume": str,
})
CiftiResampleFlirtParametersTagged = typing.TypedDict('CiftiResampleFlirtParametersTagged', {
    "@type": typing.Literal["flirt"],
    "source_volume": str,
    "target_volume": str,
})


CiftiResampleAffineParameters = typing.TypedDict('CiftiResampleAffineParameters', {
    "@type": typing.NotRequired[typing.Literal["affine"]],
    "affine_file": str,
    "flirt": typing.NotRequired[CiftiResampleFlirtParameters | None],
})
CiftiResampleAffineParametersTagged = typing.TypedDict('CiftiResampleAffineParametersTagged', {
    "@type": typing.Literal["affine"],
    "affine_file": str,
    "flirt": typing.NotRequired[CiftiResampleFlirtParameters | None],
})


CiftiResampleWarpfieldParameters = typing.TypedDict('CiftiResampleWarpfieldParameters', {
    "@type": typing.NotRequired[typing.Literal["warpfield"]],
    "warpfield": str,
    "opt_fnirt_source_volume": typing.NotRequired[str | None],
})
CiftiResampleWarpfieldParametersTagged = typing.TypedDict('CiftiResampleWarpfieldParametersTagged', {
    "@type": typing.Literal["warpfield"],
    "warpfield": str,
    "opt_fnirt_source_volume": typing.NotRequired[str | None],
})


CiftiResampleLeftAreaSurfsParameters = typing.TypedDict('CiftiResampleLeftAreaSurfsParameters', {
    "@type": typing.NotRequired[typing.Literal["left_area_surfs"]],
    "current_area": InputPathType,
    "new_area": InputPathType,
})
CiftiResampleLeftAreaSurfsParametersTagged = typing.TypedDict('CiftiResampleLeftAreaSurfsParametersTagged', {
    "@type": typing.Literal["left_area_surfs"],
    "current_area": InputPathType,
    "new_area": InputPathType,
})


CiftiResampleLeftAreaMetricsParameters = typing.TypedDict('CiftiResampleLeftAreaMetricsParameters', {
    "@type": typing.NotRequired[typing.Literal["left_area_metrics"]],
    "current_area": InputPathType,
    "new_area": InputPathType,
})
CiftiResampleLeftAreaMetricsParametersTagged = typing.TypedDict('CiftiResampleLeftAreaMetricsParametersTagged', {
    "@type": typing.Literal["left_area_metrics"],
    "current_area": InputPathType,
    "new_area": InputPathType,
})


CiftiResampleLeftSpheresParameters = typing.TypedDict('CiftiResampleLeftSpheresParameters', {
    "@type": typing.NotRequired[typing.Literal["left_spheres"]],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "left_area_surfs": typing.NotRequired[CiftiResampleLeftAreaSurfsParameters | None],
    "left_area_metrics": typing.NotRequired[CiftiResampleLeftAreaMetricsParameters | None],
})
CiftiResampleLeftSpheresParametersTagged = typing.TypedDict('CiftiResampleLeftSpheresParametersTagged', {
    "@type": typing.Literal["left_spheres"],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "left_area_surfs": typing.NotRequired[CiftiResampleLeftAreaSurfsParameters | None],
    "left_area_metrics": typing.NotRequired[CiftiResampleLeftAreaMetricsParameters | None],
})


CiftiResampleRightAreaSurfsParameters = typing.TypedDict('CiftiResampleRightAreaSurfsParameters', {
    "@type": typing.NotRequired[typing.Literal["right_area_surfs"]],
    "current_area": InputPathType,
    "new_area": InputPathType,
})
CiftiResampleRightAreaSurfsParametersTagged = typing.TypedDict('CiftiResampleRightAreaSurfsParametersTagged', {
    "@type": typing.Literal["right_area_surfs"],
    "current_area": InputPathType,
    "new_area": InputPathType,
})


CiftiResampleRightAreaMetricsParameters = typing.TypedDict('CiftiResampleRightAreaMetricsParameters', {
    "@type": typing.NotRequired[typing.Literal["right_area_metrics"]],
    "current_area": InputPathType,
    "new_area": InputPathType,
})
CiftiResampleRightAreaMetricsParametersTagged = typing.TypedDict('CiftiResampleRightAreaMetricsParametersTagged', {
    "@type": typing.Literal["right_area_metrics"],
    "current_area": InputPathType,
    "new_area": InputPathType,
})


CiftiResampleRightSpheresParameters = typing.TypedDict('CiftiResampleRightSpheresParameters', {
    "@type": typing.NotRequired[typing.Literal["right_spheres"]],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "right_area_surfs": typing.NotRequired[CiftiResampleRightAreaSurfsParameters | None],
    "right_area_metrics": typing.NotRequired[CiftiResampleRightAreaMetricsParameters | None],
})
CiftiResampleRightSpheresParametersTagged = typing.TypedDict('CiftiResampleRightSpheresParametersTagged', {
    "@type": typing.Literal["right_spheres"],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "right_area_surfs": typing.NotRequired[CiftiResampleRightAreaSurfsParameters | None],
    "right_area_metrics": typing.NotRequired[CiftiResampleRightAreaMetricsParameters | None],
})


CiftiResampleCerebellumAreaSurfsParameters = typing.TypedDict('CiftiResampleCerebellumAreaSurfsParameters', {
    "@type": typing.NotRequired[typing.Literal["cerebellum_area_surfs"]],
    "current_area": InputPathType,
    "new_area": InputPathType,
})
CiftiResampleCerebellumAreaSurfsParametersTagged = typing.TypedDict('CiftiResampleCerebellumAreaSurfsParametersTagged', {
    "@type": typing.Literal["cerebellum_area_surfs"],
    "current_area": InputPathType,
    "new_area": InputPathType,
})


CiftiResampleCerebellumAreaMetricsParameters = typing.TypedDict('CiftiResampleCerebellumAreaMetricsParameters', {
    "@type": typing.NotRequired[typing.Literal["cerebellum_area_metrics"]],
    "current_area": InputPathType,
    "new_area": InputPathType,
})
CiftiResampleCerebellumAreaMetricsParametersTagged = typing.TypedDict('CiftiResampleCerebellumAreaMetricsParametersTagged', {
    "@type": typing.Literal["cerebellum_area_metrics"],
    "current_area": InputPathType,
    "new_area": InputPathType,
})


CiftiResampleCerebellumSpheresParameters = typing.TypedDict('CiftiResampleCerebellumSpheresParameters', {
    "@type": typing.NotRequired[typing.Literal["cerebellum_spheres"]],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "cerebellum_area_surfs": typing.NotRequired[CiftiResampleCerebellumAreaSurfsParameters | None],
    "cerebellum_area_metrics": typing.NotRequired[CiftiResampleCerebellumAreaMetricsParameters | None],
})
CiftiResampleCerebellumSpheresParametersTagged = typing.TypedDict('CiftiResampleCerebellumSpheresParametersTagged', {
    "@type": typing.Literal["cerebellum_spheres"],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "cerebellum_area_surfs": typing.NotRequired[CiftiResampleCerebellumAreaSurfsParameters | None],
    "cerebellum_area_metrics": typing.NotRequired[CiftiResampleCerebellumAreaMetricsParameters | None],
})


CiftiResampleParameters = typing.TypedDict('CiftiResampleParameters', {
    "@type": typing.NotRequired[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,
    "opt_surface_largest": bool,
    "volume_predilate": typing.NotRequired[CiftiResampleVolumePredilateParameters | None],
    "surface_postdilate": typing.NotRequired[CiftiResampleSurfacePostdilateParameters | None],
    "affine": typing.NotRequired[CiftiResampleAffineParameters | None],
    "warpfield": typing.NotRequired[CiftiResampleWarpfieldParameters | None],
    "left_spheres": typing.NotRequired[CiftiResampleLeftSpheresParameters | None],
    "right_spheres": typing.NotRequired[CiftiResampleRightSpheresParameters | None],
    "cerebellum_spheres": typing.NotRequired[CiftiResampleCerebellumSpheresParameters | None],
})
CiftiResampleParametersTagged = typing.TypedDict('CiftiResampleParametersTagged', {
    "@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,
    "opt_surface_largest": bool,
    "volume_predilate": typing.NotRequired[CiftiResampleVolumePredilateParameters | None],
    "surface_postdilate": typing.NotRequired[CiftiResampleSurfacePostdilateParameters | None],
    "affine": typing.NotRequired[CiftiResampleAffineParameters | None],
    "warpfield": typing.NotRequired[CiftiResampleWarpfieldParameters | None],
    "left_spheres": typing.NotRequired[CiftiResampleLeftSpheresParameters | None],
    "right_spheres": typing.NotRequired[CiftiResampleRightSpheresParameters | None],
    "cerebellum_spheres": typing.NotRequired[CiftiResampleCerebellumSpheresParameters | None],
})


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


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


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


def cifti_resample_volume_predilate_cargs(
    params: CiftiResampleVolumePredilateParameters,
    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("-volume-predilate")
    cargs.append(str(params.get("dilate_mm", None)))
    if params.get("opt_nearest", False):
        cargs.append("-nearest")
    if params.get("weighted", None) is not None:
        cargs.extend(cifti_resample_weighted_cargs(params.get("weighted", None), execution))
    return cargs


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


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


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


def cifti_resample_surface_postdilate_cargs(
    params: CiftiResampleSurfacePostdilateParameters,
    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("-surface-postdilate")
    cargs.append(str(params.get("dilate_mm", None)))
    if params.get("opt_nearest", False):
        cargs.append("-nearest")
    if params.get("opt_linear", False):
        cargs.append("-linear")
    if params.get("weighted", None) is not None:
        cargs.extend(cifti_resample_weighted_1_cargs(params.get("weighted", None), execution))
    return cargs


def cifti_resample_flirt_params(
    source_volume: str,
    target_volume: str,
) -> CiftiResampleFlirtParametersTagged:
    """
    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_cargs(
    params: CiftiResampleFlirtParameters,
    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("-flirt")
    cargs.append(params.get("source_volume", None))
    cargs.append(params.get("target_volume", None))
    return cargs


def cifti_resample_affine_params(
    affine_file: str,
    flirt: CiftiResampleFlirtParameters | None = None,
) -> CiftiResampleAffineParametersTagged:
    """
    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_cargs(
    params: CiftiResampleAffineParameters,
    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("-affine")
    cargs.append(params.get("affine_file", None))
    if params.get("flirt", None) is not None:
        cargs.extend(cifti_resample_flirt_cargs(params.get("flirt", None), execution))
    return cargs


def cifti_resample_warpfield_params(
    warpfield: str,
    opt_fnirt_source_volume: str | None = None,
) -> CiftiResampleWarpfieldParametersTagged:
    """
    Build parameters.
    
    Args:
        warpfield: the warpfield to use.
        opt_fnirt_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 opt_fnirt_source_volume is not None:
        params["opt_fnirt_source_volume"] = opt_fnirt_source_volume
    return params


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


def cifti_resample_left_area_surfs_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleLeftAreaSurfsParametersTagged:
    """
    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_cargs(
    params: CiftiResampleLeftAreaSurfsParameters,
    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("-left-area-surfs")
    cargs.append(execution.input_file(params.get("current_area", None)))
    cargs.append(execution.input_file(params.get("new_area", None)))
    return cargs


def cifti_resample_left_area_metrics_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleLeftAreaMetricsParametersTagged:
    """
    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_cargs(
    params: CiftiResampleLeftAreaMetricsParameters,
    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("-left-area-metrics")
    cargs.append(execution.input_file(params.get("current_area", None)))
    cargs.append(execution.input_file(params.get("new_area", None)))
    return cargs


def cifti_resample_left_spheres_params(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    left_area_surfs: CiftiResampleLeftAreaSurfsParameters | None = None,
    left_area_metrics: CiftiResampleLeftAreaMetricsParameters | None = None,
) -> CiftiResampleLeftSpheresParametersTagged:
    """
    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_cargs(
    params: CiftiResampleLeftSpheresParameters,
    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("-left-spheres")
    cargs.append(execution.input_file(params.get("current_sphere", None)))
    cargs.append(execution.input_file(params.get("new_sphere", None)))
    if params.get("left_area_surfs", None) is not None:
        cargs.extend(cifti_resample_left_area_surfs_cargs(params.get("left_area_surfs", None), execution))
    if params.get("left_area_metrics", None) is not None:
        cargs.extend(cifti_resample_left_area_metrics_cargs(params.get("left_area_metrics", None), execution))
    return cargs


def cifti_resample_right_area_surfs_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleRightAreaSurfsParametersTagged:
    """
    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_cargs(
    params: CiftiResampleRightAreaSurfsParameters,
    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("-right-area-surfs")
    cargs.append(execution.input_file(params.get("current_area", None)))
    cargs.append(execution.input_file(params.get("new_area", None)))
    return cargs


def cifti_resample_right_area_metrics_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleRightAreaMetricsParametersTagged:
    """
    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_cargs(
    params: CiftiResampleRightAreaMetricsParameters,
    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("-right-area-metrics")
    cargs.append(execution.input_file(params.get("current_area", None)))
    cargs.append(execution.input_file(params.get("new_area", None)))
    return cargs


def cifti_resample_right_spheres_params(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    right_area_surfs: CiftiResampleRightAreaSurfsParameters | None = None,
    right_area_metrics: CiftiResampleRightAreaMetricsParameters | None = None,
) -> CiftiResampleRightSpheresParametersTagged:
    """
    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_cargs(
    params: CiftiResampleRightSpheresParameters,
    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("-right-spheres")
    cargs.append(execution.input_file(params.get("current_sphere", None)))
    cargs.append(execution.input_file(params.get("new_sphere", None)))
    if params.get("right_area_surfs", None) is not None:
        cargs.extend(cifti_resample_right_area_surfs_cargs(params.get("right_area_surfs", None), execution))
    if params.get("right_area_metrics", None) is not None:
        cargs.extend(cifti_resample_right_area_metrics_cargs(params.get("right_area_metrics", None), execution))
    return cargs


def cifti_resample_cerebellum_area_surfs_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleCerebellumAreaSurfsParametersTagged:
    """
    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_cargs(
    params: CiftiResampleCerebellumAreaSurfsParameters,
    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("-cerebellum-area-surfs")
    cargs.append(execution.input_file(params.get("current_area", None)))
    cargs.append(execution.input_file(params.get("new_area", None)))
    return cargs


def cifti_resample_cerebellum_area_metrics_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleCerebellumAreaMetricsParametersTagged:
    """
    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_cargs(
    params: CiftiResampleCerebellumAreaMetricsParameters,
    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("-cerebellum-area-metrics")
    cargs.append(execution.input_file(params.get("current_area", None)))
    cargs.append(execution.input_file(params.get("new_area", None)))
    return cargs


def cifti_resample_cerebellum_spheres_params(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    cerebellum_area_surfs: CiftiResampleCerebellumAreaSurfsParameters | None = None,
    cerebellum_area_metrics: CiftiResampleCerebellumAreaMetricsParameters | None = None,
) -> CiftiResampleCerebellumSpheresParametersTagged:
    """
    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_cargs(
    params: CiftiResampleCerebellumSpheresParameters,
    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("-cerebellum-spheres")
    cargs.append(execution.input_file(params.get("current_sphere", None)))
    cargs.append(execution.input_file(params.get("new_sphere", None)))
    if params.get("cerebellum_area_surfs", None) is not None:
        cargs.extend(cifti_resample_cerebellum_area_surfs_cargs(params.get("cerebellum_area_surfs", None), execution))
    if params.get("cerebellum_area_metrics", None) is not None:
        cargs.extend(cifti_resample_cerebellum_area_metrics_cargs(params.get("cerebellum_area_metrics", None), execution))
    return cargs


class CiftiResampleOutputs(typing.NamedTuple):
    """
    Output object returned when calling `CiftiResampleParameters(...)`.
    """
    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,
    opt_surface_largest: bool = False,
    volume_predilate: CiftiResampleVolumePredilateParameters | None = None,
    surface_postdilate: CiftiResampleSurfacePostdilateParameters | None = None,
    affine: CiftiResampleAffineParameters | None = None,
    warpfield: CiftiResampleWarpfieldParameters | None = None,
    left_spheres: CiftiResampleLeftSpheresParameters | None = None,
    right_spheres: CiftiResampleRightSpheresParameters | None = None,
    cerebellum_spheres: CiftiResampleCerebellumSpheresParameters | None = None,
) -> CiftiResampleParametersTagged:
    """
    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.
        opt_surface_largest: use largest weight instead of weighted average or\
            popularity when doing surface resampling.
        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.
    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,
        "opt_surface_largest": opt_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_cargs(
    params: CiftiResampleParameters,
    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("wb_command")
    cargs.append("-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("opt_surface_largest", False):
        cargs.append("-surface-largest")
    if params.get("volume_predilate", None) is not None:
        cargs.extend(cifti_resample_volume_predilate_cargs(params.get("volume_predilate", None), execution))
    if params.get("surface_postdilate", None) is not None:
        cargs.extend(cifti_resample_surface_postdilate_cargs(params.get("surface_postdilate", None), execution))
    if params.get("affine", None) is not None:
        cargs.extend(cifti_resample_affine_cargs(params.get("affine", None), execution))
    if params.get("warpfield", None) is not None:
        cargs.extend(cifti_resample_warpfield_cargs(params.get("warpfield", None), execution))
    if params.get("left_spheres", None) is not None:
        cargs.extend(cifti_resample_left_spheres_cargs(params.get("left_spheres", None), execution))
    if params.get("right_spheres", None) is not None:
        cargs.extend(cifti_resample_right_spheres_cargs(params.get("right_spheres", None), execution))
    if params.get("cerebellum_spheres", None) is not None:
        cargs.extend(cifti_resample_cerebellum_spheres_cargs(params.get("cerebellum_spheres", None), execution))
    return cargs


def cifti_resample_outputs(
    params: CiftiResampleParameters,
    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: CiftiResampleParameters,
    runner: Runner | None = None,
) -> CiftiResampleOutputs:
    """
    cifti-resample
    
    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
    .
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiResampleOutputs`).
    """
    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,
    opt_surface_largest: bool = False,
    volume_predilate: CiftiResampleVolumePredilateParameters | None = None,
    surface_postdilate: CiftiResampleSurfacePostdilateParameters | None = None,
    affine: CiftiResampleAffineParameters | None = None,
    warpfield: CiftiResampleWarpfieldParameters | None = None,
    left_spheres: CiftiResampleLeftSpheresParameters | None = None,
    right_spheres: CiftiResampleRightSpheresParameters | None = None,
    cerebellum_spheres: CiftiResampleCerebellumSpheresParameters | None = None,
    runner: Runner | None = None,
) -> CiftiResampleOutputs:
    """
    cifti-resample
    
    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
    .
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    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.
        opt_surface_largest: use largest weight instead of weighted average or\
            popularity when doing surface resampling.
        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.
        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,
        opt_surface_largest=opt_surface_largest,
        volume_predilate=volume_predilate,
        surface_postdilate=surface_postdilate,
        affine=affine,
        warpfield=warpfield,
        left_spheres=left_spheres,
        right_spheres=right_spheres,
        cerebellum_spheres=cerebellum_spheres,
    )
    return cifti_resample_execute(params, runner)


__all__ = [
    "CIFTI_RESAMPLE_METADATA",
    "CiftiResampleOutputs",
    "cifti_resample",
    "cifti_resample_affine_params",
    "cifti_resample_cerebellum_area_metrics_params",
    "cifti_resample_cerebellum_area_surfs_params",
    "cifti_resample_cerebellum_spheres_params",
    "cifti_resample_execute",
    "cifti_resample_flirt_params",
    "cifti_resample_left_area_metrics_params",
    "cifti_resample_left_area_surfs_params",
    "cifti_resample_left_spheres_params",
    "cifti_resample_params",
    "cifti_resample_right_area_metrics_params",
    "cifti_resample_right_area_surfs_params",
    "cifti_resample_right_spheres_params",
    "cifti_resample_surface_postdilate_params",
    "cifti_resample_volume_predilate_params",
    "cifti_resample_warpfield_params",
    "cifti_resample_weighted_1_params",
    "cifti_resample_weighted_params",
]
