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

import typing
import pathlib
from styxdefs import *
import dataclasses

METRIC_REMOVE_ISLANDS_METADATA = Metadata(
    id="ccfb20f350c974adee896baa3f5aa1a71a238a25.boutiques",
    name="metric-remove-islands",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


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


def metric_remove_islands(
    surface: InputPathType,
    metric_in: InputPathType,
    metric_out: str,
    opt_corrected_areas_area_metric: InputPathType | None = None,
    runner: Runner | None = None,
) -> MetricRemoveIslandsOutputs:
    """
    Remove islands from an roi metric.
    
    Finds all connected areas in the ROI, and zeros out 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 `MetricRemoveIslandsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(METRIC_REMOVE_ISLANDS_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-metric-remove-islands")
    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 = MetricRemoveIslandsOutputs(
        root=execution.output_file("."),
        metric_out=execution.output_file(metric_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "METRIC_REMOVE_ISLANDS_METADATA",
    "MetricRemoveIslandsOutputs",
    "metric_remove_islands",
]
