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

import typing
import pathlib
from styxdefs import *
import dataclasses

METRIC_FILL_HOLES_METADATA = Metadata(
    id="01f9f706378f6ba0092f279b104ef0c8e161e9ce.boutiques",
    name="metric-fill-holes",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


class MetricFillHolesOutputs(typing.NamedTuple):
    """
    Output object returned when calling `metric_fill_holes(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    metric_out: OutputPathType
    """the output ROI metric"""


def metric_fill_holes(
    surface: InputPathType,
    metric_in: InputPathType,
    metric_out: str,
    opt_corrected_areas_area_metric: InputPathType | None = None,
    runner: Runner | None = None,
) -> MetricFillHolesOutputs:
    """
    Fill holes in an roi metric.
    
    Finds all connected areas that are not included in the ROI, and writes ones
    into all but the largest one, in terms of surface area.
    
    Author: Washington University School of Medicin
    
    Args:
        surface: the surface to use for neighbor information.
        metric_in: the input ROI metric.
        metric_out: the output ROI metric.
        opt_corrected_areas_area_metric: vertex areas to use instead of\
            computing them from the surface: the corrected vertex areas, as a\
            metric.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MetricFillHolesOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(METRIC_FILL_HOLES_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-metric-fill-holes")
    cargs.append(execution.input_file(surface))
    cargs.append(execution.input_file(metric_in))
    cargs.append(metric_out)
    if opt_corrected_areas_area_metric is not None:
        cargs.extend([
            "-corrected-areas",
            execution.input_file(opt_corrected_areas_area_metric)
        ])
    ret = MetricFillHolesOutputs(
        root=execution.output_file("."),
        metric_out=execution.output_file(metric_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "METRIC_FILL_HOLES_METADATA",
    "MetricFillHolesOutputs",
    "metric_fill_holes",
]
