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

import typing
import pathlib
from styxdefs import *

CIFTI_RESAMPLE_DCONN_MEMORY_METADATA = Metadata(
    id="d729ea969be03fe9e202413b7e489346783a1ac2.boutiques",
    name="cifti-resample-dconn-memory",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


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


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


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


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


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


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


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


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


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


CiftiResampleDconnMemoryLeftSpheresParameters = typing.TypedDict('CiftiResampleDconnMemoryLeftSpheresParameters', {
    "@type": typing.NotRequired[typing.Literal["left_spheres"]],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "left_area_surfs": typing.NotRequired[CiftiResampleDconnMemoryLeftAreaSurfsParameters | None],
    "left_area_metrics": typing.NotRequired[CiftiResampleDconnMemoryLeftAreaMetricsParameters | None],
})
CiftiResampleDconnMemoryLeftSpheresParametersTagged = typing.TypedDict('CiftiResampleDconnMemoryLeftSpheresParametersTagged', {
    "@type": typing.Literal["left_spheres"],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "left_area_surfs": typing.NotRequired[CiftiResampleDconnMemoryLeftAreaSurfsParameters | None],
    "left_area_metrics": typing.NotRequired[CiftiResampleDconnMemoryLeftAreaMetricsParameters | None],
})


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


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


CiftiResampleDconnMemoryRightSpheresParameters = typing.TypedDict('CiftiResampleDconnMemoryRightSpheresParameters', {
    "@type": typing.NotRequired[typing.Literal["right_spheres"]],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "right_area_surfs": typing.NotRequired[CiftiResampleDconnMemoryRightAreaSurfsParameters | None],
    "right_area_metrics": typing.NotRequired[CiftiResampleDconnMemoryRightAreaMetricsParameters | None],
})
CiftiResampleDconnMemoryRightSpheresParametersTagged = typing.TypedDict('CiftiResampleDconnMemoryRightSpheresParametersTagged', {
    "@type": typing.Literal["right_spheres"],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "right_area_surfs": typing.NotRequired[CiftiResampleDconnMemoryRightAreaSurfsParameters | None],
    "right_area_metrics": typing.NotRequired[CiftiResampleDconnMemoryRightAreaMetricsParameters | None],
})


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


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


CiftiResampleDconnMemoryCerebellumSpheresParameters = typing.TypedDict('CiftiResampleDconnMemoryCerebellumSpheresParameters', {
    "@type": typing.NotRequired[typing.Literal["cerebellum_spheres"]],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "cerebellum_area_surfs": typing.NotRequired[CiftiResampleDconnMemoryCerebellumAreaSurfsParameters | None],
    "cerebellum_area_metrics": typing.NotRequired[CiftiResampleDconnMemoryCerebellumAreaMetricsParameters | None],
})
CiftiResampleDconnMemoryCerebellumSpheresParametersTagged = typing.TypedDict('CiftiResampleDconnMemoryCerebellumSpheresParametersTagged', {
    "@type": typing.Literal["cerebellum_spheres"],
    "current_sphere": InputPathType,
    "new_sphere": InputPathType,
    "cerebellum_area_surfs": typing.NotRequired[CiftiResampleDconnMemoryCerebellumAreaSurfsParameters | None],
    "cerebellum_area_metrics": typing.NotRequired[CiftiResampleDconnMemoryCerebellumAreaMetricsParameters | None],
})


CiftiResampleDconnMemoryParameters = typing.TypedDict('CiftiResampleDconnMemoryParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/cifti-resample-dconn-memory"]],
    "cifti_in": InputPathType,
    "cifti_template": InputPathType,
    "template_direction": str,
    "surface_method": str,
    "volume_method": str,
    "cifti_out": str,
    "opt_surface_largest": bool,
    "volume_predilate": typing.NotRequired[CiftiResampleDconnMemoryVolumePredilateParameters | None],
    "surface_postdilate": typing.NotRequired[CiftiResampleDconnMemorySurfacePostdilateParameters | None],
    "affine": typing.NotRequired[CiftiResampleDconnMemoryAffineParameters | None],
    "warpfield": typing.NotRequired[CiftiResampleDconnMemoryWarpfieldParameters | None],
    "left_spheres": typing.NotRequired[CiftiResampleDconnMemoryLeftSpheresParameters | None],
    "right_spheres": typing.NotRequired[CiftiResampleDconnMemoryRightSpheresParameters | None],
    "cerebellum_spheres": typing.NotRequired[CiftiResampleDconnMemoryCerebellumSpheresParameters | None],
})
CiftiResampleDconnMemoryParametersTagged = typing.TypedDict('CiftiResampleDconnMemoryParametersTagged', {
    "@type": typing.Literal["workbench/cifti-resample-dconn-memory"],
    "cifti_in": InputPathType,
    "cifti_template": InputPathType,
    "template_direction": str,
    "surface_method": str,
    "volume_method": str,
    "cifti_out": str,
    "opt_surface_largest": bool,
    "volume_predilate": typing.NotRequired[CiftiResampleDconnMemoryVolumePredilateParameters | None],
    "surface_postdilate": typing.NotRequired[CiftiResampleDconnMemorySurfacePostdilateParameters | None],
    "affine": typing.NotRequired[CiftiResampleDconnMemoryAffineParameters | None],
    "warpfield": typing.NotRequired[CiftiResampleDconnMemoryWarpfieldParameters | None],
    "left_spheres": typing.NotRequired[CiftiResampleDconnMemoryLeftSpheresParameters | None],
    "right_spheres": typing.NotRequired[CiftiResampleDconnMemoryRightSpheresParameters | None],
    "cerebellum_spheres": typing.NotRequired[CiftiResampleDconnMemoryCerebellumSpheresParameters | None],
})


def cifti_resample_dconn_memory_weighted_params(
    opt_exponent_exponent: float | None = None,
    opt_legacy_cutoff: bool = False,
) -> CiftiResampleDconnMemoryWeightedParametersTagged:
    """
    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_dconn_memory_weighted_cargs(
    params: CiftiResampleDconnMemoryWeightedParameters,
    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_dconn_memory_volume_predilate_params(
    dilate_mm: float,
    opt_nearest: bool = False,
    weighted: CiftiResampleDconnMemoryWeightedParameters | None = None,
) -> CiftiResampleDconnMemoryVolumePredilateParametersTagged:
    """
    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_dconn_memory_volume_predilate_cargs(
    params: CiftiResampleDconnMemoryVolumePredilateParameters,
    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_dconn_memory_weighted_cargs(params.get("weighted", None), execution))
    return cargs


def cifti_resample_dconn_memory_weighted_1_params(
    opt_exponent_exponent: float | None = None,
    opt_legacy_cutoff: bool = False,
) -> CiftiResampleDconnMemoryWeighted1ParametersTagged:
    """
    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_dconn_memory_weighted_1_cargs(
    params: CiftiResampleDconnMemoryWeighted1Parameters,
    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_dconn_memory_surface_postdilate_params(
    dilate_mm: float,
    opt_nearest: bool = False,
    opt_linear: bool = False,
    weighted: CiftiResampleDconnMemoryWeighted1Parameters | None = None,
) -> CiftiResampleDconnMemorySurfacePostdilateParametersTagged:
    """
    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).
    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_dconn_memory_surface_postdilate_cargs(
    params: CiftiResampleDconnMemorySurfacePostdilateParameters,
    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_dconn_memory_weighted_1_cargs(params.get("weighted", None), execution))
    return cargs


def cifti_resample_dconn_memory_flirt_params(
    source_volume: str,
    target_volume: str,
) -> CiftiResampleDconnMemoryFlirtParametersTagged:
    """
    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_dconn_memory_flirt_cargs(
    params: CiftiResampleDconnMemoryFlirtParameters,
    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_dconn_memory_affine_params(
    affine_file: str,
    flirt: CiftiResampleDconnMemoryFlirtParameters | None = None,
) -> CiftiResampleDconnMemoryAffineParametersTagged:
    """
    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_dconn_memory_affine_cargs(
    params: CiftiResampleDconnMemoryAffineParameters,
    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_dconn_memory_flirt_cargs(params.get("flirt", None), execution))
    return cargs


def cifti_resample_dconn_memory_warpfield_params(
    warpfield: str,
    opt_fnirt_source_volume: str | None = None,
) -> CiftiResampleDconnMemoryWarpfieldParametersTagged:
    """
    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_dconn_memory_warpfield_cargs(
    params: CiftiResampleDconnMemoryWarpfieldParameters,
    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_dconn_memory_left_area_surfs_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleDconnMemoryLeftAreaSurfsParametersTagged:
    """
    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_dconn_memory_left_area_surfs_cargs(
    params: CiftiResampleDconnMemoryLeftAreaSurfsParameters,
    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_dconn_memory_left_area_metrics_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleDconnMemoryLeftAreaMetricsParametersTagged:
    """
    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_dconn_memory_left_area_metrics_cargs(
    params: CiftiResampleDconnMemoryLeftAreaMetricsParameters,
    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_dconn_memory_left_spheres_params(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    left_area_surfs: CiftiResampleDconnMemoryLeftAreaSurfsParameters | None = None,
    left_area_metrics: CiftiResampleDconnMemoryLeftAreaMetricsParameters | None = None,
) -> CiftiResampleDconnMemoryLeftSpheresParametersTagged:
    """
    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_dconn_memory_left_spheres_cargs(
    params: CiftiResampleDconnMemoryLeftSpheresParameters,
    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_dconn_memory_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_dconn_memory_left_area_metrics_cargs(params.get("left_area_metrics", None), execution))
    return cargs


def cifti_resample_dconn_memory_right_area_surfs_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleDconnMemoryRightAreaSurfsParametersTagged:
    """
    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_dconn_memory_right_area_surfs_cargs(
    params: CiftiResampleDconnMemoryRightAreaSurfsParameters,
    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_dconn_memory_right_area_metrics_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleDconnMemoryRightAreaMetricsParametersTagged:
    """
    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_dconn_memory_right_area_metrics_cargs(
    params: CiftiResampleDconnMemoryRightAreaMetricsParameters,
    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_dconn_memory_right_spheres_params(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    right_area_surfs: CiftiResampleDconnMemoryRightAreaSurfsParameters | None = None,
    right_area_metrics: CiftiResampleDconnMemoryRightAreaMetricsParameters | None = None,
) -> CiftiResampleDconnMemoryRightSpheresParametersTagged:
    """
    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_dconn_memory_right_spheres_cargs(
    params: CiftiResampleDconnMemoryRightSpheresParameters,
    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_dconn_memory_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_dconn_memory_right_area_metrics_cargs(params.get("right_area_metrics", None), execution))
    return cargs


def cifti_resample_dconn_memory_cerebellum_area_surfs_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleDconnMemoryCerebellumAreaSurfsParametersTagged:
    """
    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_dconn_memory_cerebellum_area_surfs_cargs(
    params: CiftiResampleDconnMemoryCerebellumAreaSurfsParameters,
    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_dconn_memory_cerebellum_area_metrics_params(
    current_area: InputPathType,
    new_area: InputPathType,
) -> CiftiResampleDconnMemoryCerebellumAreaMetricsParametersTagged:
    """
    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_dconn_memory_cerebellum_area_metrics_cargs(
    params: CiftiResampleDconnMemoryCerebellumAreaMetricsParameters,
    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_dconn_memory_cerebellum_spheres_params(
    current_sphere: InputPathType,
    new_sphere: InputPathType,
    cerebellum_area_surfs: CiftiResampleDconnMemoryCerebellumAreaSurfsParameters | None = None,
    cerebellum_area_metrics: CiftiResampleDconnMemoryCerebellumAreaMetricsParameters | None = None,
) -> CiftiResampleDconnMemoryCerebellumSpheresParametersTagged:
    """
    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_dconn_memory_cerebellum_spheres_cargs(
    params: CiftiResampleDconnMemoryCerebellumSpheresParameters,
    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_dconn_memory_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_dconn_memory_cerebellum_area_metrics_cargs(params.get("cerebellum_area_metrics", None), execution))
    return cargs


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


def cifti_resample_dconn_memory_params(
    cifti_in: InputPathType,
    cifti_template: InputPathType,
    template_direction: str,
    surface_method: str,
    volume_method: str,
    cifti_out: str,
    opt_surface_largest: bool = False,
    volume_predilate: CiftiResampleDconnMemoryVolumePredilateParameters | None = None,
    surface_postdilate: CiftiResampleDconnMemorySurfacePostdilateParameters | None = None,
    affine: CiftiResampleDconnMemoryAffineParameters | None = None,
    warpfield: CiftiResampleDconnMemoryWarpfieldParameters | None = None,
    left_spheres: CiftiResampleDconnMemoryLeftSpheresParameters | None = None,
    right_spheres: CiftiResampleDconnMemoryRightSpheresParameters | None = None,
    cerebellum_spheres: CiftiResampleDconnMemoryCerebellumSpheresParameters | None = None,
) -> CiftiResampleDconnMemoryParametersTagged:
    """
    Build parameters.
    
    Args:
        cifti_in: the cifti file to resample.
        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\
            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-dconn-memory",
        "cifti_in": cifti_in,
        "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_dconn_memory_cargs(
    params: CiftiResampleDconnMemoryParameters,
    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-dconn-memory")
    cargs.append(execution.input_file(params.get("cifti_in", 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_dconn_memory_volume_predilate_cargs(params.get("volume_predilate", None), execution))
    if params.get("surface_postdilate", None) is not None:
        cargs.extend(cifti_resample_dconn_memory_surface_postdilate_cargs(params.get("surface_postdilate", None), execution))
    if params.get("affine", None) is not None:
        cargs.extend(cifti_resample_dconn_memory_affine_cargs(params.get("affine", None), execution))
    if params.get("warpfield", None) is not None:
        cargs.extend(cifti_resample_dconn_memory_warpfield_cargs(params.get("warpfield", None), execution))
    if params.get("left_spheres", None) is not None:
        cargs.extend(cifti_resample_dconn_memory_left_spheres_cargs(params.get("left_spheres", None), execution))
    if params.get("right_spheres", None) is not None:
        cargs.extend(cifti_resample_dconn_memory_right_spheres_cargs(params.get("right_spheres", None), execution))
    if params.get("cerebellum_spheres", None) is not None:
        cargs.extend(cifti_resample_dconn_memory_cerebellum_spheres_cargs(params.get("cerebellum_spheres", None), execution))
    return cargs


def cifti_resample_dconn_memory_outputs(
    params: CiftiResampleDconnMemoryParameters,
    execution: Execution,
) -> CiftiResampleDconnMemoryOutputs:
    """
    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 = CiftiResampleDconnMemoryOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(params.get("cifti_out", None)),
    )
    return ret


def cifti_resample_dconn_memory_execute(
    params: CiftiResampleDconnMemoryParameters,
    runner: Runner | None = None,
) -> CiftiResampleDconnMemoryOutputs:
    """
    cifti-resample-dconn-memory
    
    Use lots of memory to resample dconn.
    
    This command does the same thing as running -cifti-resample twice, but uses
    memory up to approximately 2x the size that the intermediate file would be.
    This is because the intermediate dconn is kept in memory, rather than
    written to disk, and the components before and after resampling/dilation
    have to be in memory at the same time during the relevant computation. 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.
    
    To get the v1.3.2 and earlier behavior of weighted dilation, specify
    exponent of 2 for surface and volume, and -legacy-cutoff for both surface
    and volume.
    
    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 `CiftiResampleDconnMemoryOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_RESAMPLE_DCONN_MEMORY_METADATA)
    params = execution.params(params)
    cargs = cifti_resample_dconn_memory_cargs(params, execution)
    ret = cifti_resample_dconn_memory_outputs(params, execution)
    execution.run(cargs)
    return ret


def cifti_resample_dconn_memory(
    cifti_in: InputPathType,
    cifti_template: InputPathType,
    template_direction: str,
    surface_method: str,
    volume_method: str,
    cifti_out: str,
    opt_surface_largest: bool = False,
    volume_predilate: CiftiResampleDconnMemoryVolumePredilateParameters | None = None,
    surface_postdilate: CiftiResampleDconnMemorySurfacePostdilateParameters | None = None,
    affine: CiftiResampleDconnMemoryAffineParameters | None = None,
    warpfield: CiftiResampleDconnMemoryWarpfieldParameters | None = None,
    left_spheres: CiftiResampleDconnMemoryLeftSpheresParameters | None = None,
    right_spheres: CiftiResampleDconnMemoryRightSpheresParameters | None = None,
    cerebellum_spheres: CiftiResampleDconnMemoryCerebellumSpheresParameters | None = None,
    runner: Runner | None = None,
) -> CiftiResampleDconnMemoryOutputs:
    """
    cifti-resample-dconn-memory
    
    Use lots of memory to resample dconn.
    
    This command does the same thing as running -cifti-resample twice, but uses
    memory up to approximately 2x the size that the intermediate file would be.
    This is because the intermediate dconn is kept in memory, rather than
    written to disk, and the components before and after resampling/dilation
    have to be in memory at the same time during the relevant computation. 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.
    
    To get the v1.3.2 and earlier behavior of weighted dilation, specify
    exponent of 2 for surface and volume, and -legacy-cutoff for both surface
    and volume.
    
    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.
        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\
            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 `CiftiResampleDconnMemoryOutputs`).
    """
    params = cifti_resample_dconn_memory_params(
        cifti_in=cifti_in,
        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_dconn_memory_execute(params, runner)


__all__ = [
    "CIFTI_RESAMPLE_DCONN_MEMORY_METADATA",
    "CiftiResampleDconnMemoryOutputs",
    "cifti_resample_dconn_memory",
    "cifti_resample_dconn_memory_affine_params",
    "cifti_resample_dconn_memory_cerebellum_area_metrics_params",
    "cifti_resample_dconn_memory_cerebellum_area_surfs_params",
    "cifti_resample_dconn_memory_cerebellum_spheres_params",
    "cifti_resample_dconn_memory_execute",
    "cifti_resample_dconn_memory_flirt_params",
    "cifti_resample_dconn_memory_left_area_metrics_params",
    "cifti_resample_dconn_memory_left_area_surfs_params",
    "cifti_resample_dconn_memory_left_spheres_params",
    "cifti_resample_dconn_memory_params",
    "cifti_resample_dconn_memory_right_area_metrics_params",
    "cifti_resample_dconn_memory_right_area_surfs_params",
    "cifti_resample_dconn_memory_right_spheres_params",
    "cifti_resample_dconn_memory_surface_postdilate_params",
    "cifti_resample_dconn_memory_volume_predilate_params",
    "cifti_resample_dconn_memory_warpfield_params",
    "cifti_resample_dconn_memory_weighted_1_params",
    "cifti_resample_dconn_memory_weighted_params",
]
