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

import typing
import pathlib
from styxdefs import *

SURFACE_MODIFY_SPHERE_METADATA = Metadata(
    id="69965c5b4cd0399d7501f269ec55b50c372e008b.boutiques",
    name="surface-modify-sphere",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SurfaceModifySphereParameters = typing.TypedDict('SurfaceModifySphereParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/surface-modify-sphere"]],
    "sphere_in": InputPathType,
    "radius": float,
    "sphere_out": str,
    "opt_recenter": bool,
})
SurfaceModifySphereParametersTagged = typing.TypedDict('SurfaceModifySphereParametersTagged', {
    "@type": typing.Literal["workbench/surface-modify-sphere"],
    "sphere_in": InputPathType,
    "radius": float,
    "sphere_out": str,
    "opt_recenter": bool,
})


class SurfaceModifySphereOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceModifySphereParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    sphere_out: OutputPathType
    """the output sphere"""


def surface_modify_sphere_params(
    sphere_in: InputPathType,
    radius: float,
    sphere_out: str,
    opt_recenter: bool = False,
) -> SurfaceModifySphereParametersTagged:
    """
    Build parameters.
    
    Args:
        sphere_in: the sphere to modify.
        radius: the radius the output sphere should have.
        sphere_out: the output sphere.
        opt_recenter: recenter the sphere by means of the bounding box.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-modify-sphere",
        "sphere_in": sphere_in,
        "radius": radius,
        "sphere_out": sphere_out,
        "opt_recenter": opt_recenter,
    }
    return params


def surface_modify_sphere_cargs(
    params: SurfaceModifySphereParameters,
    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("-surface-modify-sphere")
    cargs.append(execution.input_file(params.get("sphere_in", None)))
    cargs.append(str(params.get("radius", None)))
    cargs.append(params.get("sphere_out", None))
    if params.get("opt_recenter", False):
        cargs.append("-recenter")
    return cargs


def surface_modify_sphere_outputs(
    params: SurfaceModifySphereParameters,
    execution: Execution,
) -> SurfaceModifySphereOutputs:
    """
    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 = SurfaceModifySphereOutputs(
        root=execution.output_file("."),
        sphere_out=execution.output_file(params.get("sphere_out", None)),
    )
    return ret


def surface_modify_sphere_execute(
    params: SurfaceModifySphereParameters,
    runner: Runner | None = None,
) -> SurfaceModifySphereOutputs:
    """
    surface-modify-sphere
    
    Change radius and optionally recenter a sphere.
    
    This command may be useful if you have used -surface-resample to resample a
    sphere, which can suffer from problems generally not present in
    -surface-sphere-project-unproject. If the sphere should already be centered
    around the origin, using -recenter may still shift it slightly before
    changing the radius, which is likely to be undesireable.
    
    If <sphere-in> is not close to spherical, or not centered around the origin
    and -recenter is not used, a warning is printed.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceModifySphereOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_MODIFY_SPHERE_METADATA)
    params = execution.params(params)
    cargs = surface_modify_sphere_cargs(params, execution)
    ret = surface_modify_sphere_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_modify_sphere(
    sphere_in: InputPathType,
    radius: float,
    sphere_out: str,
    opt_recenter: bool = False,
    runner: Runner | None = None,
) -> SurfaceModifySphereOutputs:
    """
    surface-modify-sphere
    
    Change radius and optionally recenter a sphere.
    
    This command may be useful if you have used -surface-resample to resample a
    sphere, which can suffer from problems generally not present in
    -surface-sphere-project-unproject. If the sphere should already be centered
    around the origin, using -recenter may still shift it slightly before
    changing the radius, which is likely to be undesireable.
    
    If <sphere-in> is not close to spherical, or not centered around the origin
    and -recenter is not used, a warning is printed.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        sphere_in: the sphere to modify.
        radius: the radius the output sphere should have.
        sphere_out: the output sphere.
        opt_recenter: recenter the sphere by means of the bounding box.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceModifySphereOutputs`).
    """
    params = surface_modify_sphere_params(
        sphere_in=sphere_in,
        radius=radius,
        sphere_out=sphere_out,
        opt_recenter=opt_recenter,
    )
    return surface_modify_sphere_execute(params, runner)


__all__ = [
    "SURFACE_MODIFY_SPHERE_METADATA",
    "SurfaceModifySphereOutputs",
    "surface_modify_sphere",
    "surface_modify_sphere_execute",
    "surface_modify_sphere_params",
]
