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

import typing
import pathlib
from styxdefs import *
import dataclasses

CONNECTEDCOMP_METADATA = Metadata(
    id="4d630a5c9dd96234ed4b80fc339005c5f4b78137.boutiques",
    name="connectedcomp",
    package="fsl",
    container_image_tag="mcin/fsl:6.0.5",
)


class ConnectedcompOutputs(typing.NamedTuple):
    """
    Output object returned when calling `connectedcomp(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    outfile: OutputPathType | None
    """The output image volume"""


def connectedcomp(
    in_volume: InputPathType,
    output_volume: InputPathType | None = None,
    num_connect: int | None = None,
    runner: Runner | None = None,
) -> ConnectedcompOutputs:
    """
    Connected component analysis tool.
    
    Author: Unknown
    
    Args:
        in_volume: Input image volume.
        output_volume: Output image volume.
        num_connect: Number of connected components.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ConnectedcompOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CONNECTEDCOMP_METADATA)
    cargs = []
    cargs.append("connectedcomp")
    cargs.append(execution.input_file(in_volume))
    if output_volume is not None:
        cargs.append(execution.input_file(output_volume))
    if num_connect is not None:
        cargs.append(str(num_connect))
    ret = ConnectedcompOutputs(
        root=execution.output_file("."),
        outfile=execution.output_file(pathlib.Path(output_volume).name) if (output_volume is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "CONNECTEDCOMP_METADATA",
    "ConnectedcompOutputs",
    "connectedcomp",
]
