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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_EXTRACT_LABEL_METADATA = Metadata(
    id="0b9620a7206508bacb4685ef0d5ac119a68d3dd9.boutiques",
    name="mri_extract_label",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriExtractLabelOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_extract_label(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_volume: OutputPathType
    """Extracted labeled voxels output volume."""


def mri_extract_label(
    input_volume: InputPathType,
    labels: list[str],
    output_name: str,
    gaussian_smoothing: float | None = None,
    transform_file: InputPathType | None = None,
    exit_none_found: bool = False,
    dilate: float | None = None,
    erode: float | None = None,
    runner: Runner | None = None,
) -> MriExtractLabelOutputs:
    """
    Extracts a set of labeled voxels from an image.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_volume: Input volume from which to extract labels.
        labels: Labels to extract. Can include one or more labels.
        output_name: Name of the output file.
        gaussian_smoothing: Apply a Gaussian smoothing kernel with sigma.
        transform_file: Apply the transform in xform file to the extracted\
            volume.
        exit_none_found: Exit with error if none of the specified labels are\
            found.
        dilate: Dilate the output volume n times.
        erode: Erode the output volume n times.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriExtractLabelOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_EXTRACT_LABEL_METADATA)
    cargs = []
    cargs.append("mri_extract_label")
    cargs.append(execution.input_file(input_volume))
    cargs.extend(labels)
    cargs.append(output_name)
    if gaussian_smoothing is not None:
        cargs.extend([
            "-s",
            str(gaussian_smoothing)
        ])
    if transform_file is not None:
        cargs.extend([
            "-t",
            execution.input_file(transform_file)
        ])
    if exit_none_found:
        cargs.append("-exit_none_found")
    if dilate is not None:
        cargs.extend([
            "-dilate",
            str(dilate)
        ])
    if erode is not None:
        cargs.extend([
            "-erode",
            str(erode)
        ])
    ret = MriExtractLabelOutputs(
        root=execution.output_file("."),
        output_volume=execution.output_file(output_name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_EXTRACT_LABEL_METADATA",
    "MriExtractLabelOutputs",
    "mri_extract_label",
]
