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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_SEGHEAD_METADATA = Metadata(
    id="08340cd5e951bddba3f6bc9a63145997fab29dc1.boutiques",
    name="mri_seghead",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriSegheadOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_seghead(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def mri_seghead(
    input_volume: str,
    output_volume: str,
    fill_value: float | None = None,
    fhi_value: float | None = None,
    thresh1_value: float | None = None,
    thresh2_value: float | None = None,
    threshold: float | None = None,
    nhitsmin_value: float | None = None,
    hvoldat_file: InputPathType | None = None,
    signal_behind_head: bool = False,
    rescale: bool = False,
    fill_holes_islands: bool = False,
    seed_point: list[float] | None = None,
    or_mask_file: InputPathType | None = None,
    gdiag_option: str | None = None,
    runner: Runner | None = None,
) -> MriSegheadOutputs:
    """
    Binarizes an input volume to identify the head's voxels.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_volume: Input volume identifier, e.g., T1.
        output_volume: Output volume identifier.
        fill_value: Fill value for binarizing the head (default 255).
        fhi_value: FHI value used in type change operation (default 0.999).
        thresh1_value: Threshold value for detecting the skin (e.g., 20).
        thresh2_value: Threshold value for the final binarization (e.g., 20).
        threshold: Single threshold value applied to both thresh1 and thresh2.
        nhitsmin_value: Minimum number of consecutive hits needed to identify\
            skin (default 2).
        hvoldat_file: File to write the volume of the head in mm3 to an ASCII\
            file.
        signal_behind_head: Consider signals behind the head in the\
            binarization process.
        rescale: Rescale the input when converting to uchar.
        fill_holes_islands: Fill holes and remove islands in the binary volume.
        seed_point: Seed point specified by column, row, slice for filling\
            operation.
        or_mask_file: Mask file to include voxels in the binarization process.
        gdiag_option: Optional diagnostic option for internal use.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriSegheadOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_SEGHEAD_METADATA)
    cargs = []
    cargs.append("mri_seghead")
    cargs.extend([
        "--invol",
        input_volume
    ])
    cargs.extend([
        "--outvol",
        output_volume
    ])
    if fill_value is not None:
        cargs.extend([
            "--fill",
            str(fill_value)
        ])
    if fhi_value is not None:
        cargs.extend([
            "--fhi",
            str(fhi_value)
        ])
    if thresh1_value is not None:
        cargs.extend([
            "--thresh1",
            str(thresh1_value)
        ])
    if thresh2_value is not None:
        cargs.extend([
            "--thresh2",
            str(thresh2_value)
        ])
    if threshold is not None:
        cargs.extend([
            "--thresh",
            str(threshold)
        ])
    if nhitsmin_value is not None:
        cargs.extend([
            "--nhitsmin",
            str(nhitsmin_value)
        ])
    if hvoldat_file is not None:
        cargs.extend([
            "--hvoldat",
            execution.input_file(hvoldat_file)
        ])
    if signal_behind_head:
        cargs.append("--get-signal-behind-head")
    if rescale:
        cargs.append("--rescale")
    if fill_holes_islands:
        cargs.append("--fill-holes-islands")
    if seed_point is not None:
        cargs.extend([
            "--seed",
            *map(str, seed_point)
        ])
    if or_mask_file is not None:
        cargs.extend([
            "--or-mask",
            execution.input_file(or_mask_file)
        ])
    if gdiag_option is not None:
        cargs.extend([
            "--gdiag",
            gdiag_option
        ])
    ret = MriSegheadOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_SEGHEAD_METADATA",
    "MriSegheadOutputs",
    "mri_seghead",
]
