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

import typing
import pathlib
from styxdefs import *

VOLUME_FILL_HOLES_METADATA = Metadata(
    id="b215833557d957fc6f98c6569e125d6daf82e9b8.boutiques",
    name="volume-fill-holes",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


VolumeFillHolesParameters = typing.TypedDict('VolumeFillHolesParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/volume-fill-holes"]],
    "volume_in": InputPathType,
    "volume_out": str,
})
VolumeFillHolesParametersTagged = typing.TypedDict('VolumeFillHolesParametersTagged', {
    "@type": typing.Literal["workbench/volume-fill-holes"],
    "volume_in": InputPathType,
    "volume_out": str,
})


class VolumeFillHolesOutputs(typing.NamedTuple):
    """
    Output object returned when calling `VolumeFillHolesParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    volume_out: OutputPathType
    """the output ROI volume"""


def volume_fill_holes_params(
    volume_in: InputPathType,
    volume_out: str,
) -> VolumeFillHolesParametersTagged:
    """
    Build parameters.
    
    Args:
        volume_in: the input ROI volume.
        volume_out: the output ROI volume.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/volume-fill-holes",
        "volume_in": volume_in,
        "volume_out": volume_out,
    }
    return params


def volume_fill_holes_cargs(
    params: VolumeFillHolesParameters,
    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("-volume-fill-holes")
    cargs.append(execution.input_file(params.get("volume_in", None)))
    cargs.append(params.get("volume_out", None))
    return cargs


def volume_fill_holes_outputs(
    params: VolumeFillHolesParameters,
    execution: Execution,
) -> VolumeFillHolesOutputs:
    """
    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 = VolumeFillHolesOutputs(
        root=execution.output_file("."),
        volume_out=execution.output_file(params.get("volume_out", None)),
    )
    return ret


def volume_fill_holes_execute(
    params: VolumeFillHolesParameters,
    runner: Runner | None = None,
) -> VolumeFillHolesOutputs:
    """
    volume-fill-holes
    
    Fill holes in an roi volume.
    
    Finds all face-connected parts that are not included in the ROI, and fills
    all but the largest one with ones.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VolumeFillHolesOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(VOLUME_FILL_HOLES_METADATA)
    params = execution.params(params)
    cargs = volume_fill_holes_cargs(params, execution)
    ret = volume_fill_holes_outputs(params, execution)
    execution.run(cargs)
    return ret


def volume_fill_holes(
    volume_in: InputPathType,
    volume_out: str,
    runner: Runner | None = None,
) -> VolumeFillHolesOutputs:
    """
    volume-fill-holes
    
    Fill holes in an roi volume.
    
    Finds all face-connected parts that are not included in the ROI, and fills
    all but the largest one with ones.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        volume_in: the input ROI volume.
        volume_out: the output ROI volume.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VolumeFillHolesOutputs`).
    """
    params = volume_fill_holes_params(
        volume_in=volume_in,
        volume_out=volume_out,
    )
    return volume_fill_holes_execute(params, runner)


__all__ = [
    "VOLUME_FILL_HOLES_METADATA",
    "VolumeFillHolesOutputs",
    "volume_fill_holes",
    "volume_fill_holes_execute",
    "volume_fill_holes_params",
]
