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

import typing
import pathlib
from styxdefs import *
import dataclasses

MKHEADSURF_METADATA = Metadata(
    id="d268c25e144e66d66d451c811baf8b76c969e6ec.boutiques",
    name="mkheadsurf",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def mkheadsurf(
    input_vol: InputPathType,
    output_vol: str,
    output_surf: str,
    subject_id: str,
    nsmooth: float | None = None,
    noseghead: bool = False,
    thresh1: float | None = None,
    thresh2: float | None = None,
    nhitsmin: float | None = None,
    ndilate: float | None = None,
    nerode: float | None = None,
    fillval: float | None = None,
    fhi: float | None = None,
    no_rescale: bool = False,
    no_fill_holes_islands: bool = False,
    or_mask: InputPathType | None = None,
    tessellation_method: str | None = None,
    inflate: bool = False,
    curv: bool = False,
    srcvol: str | None = None,
    headvol: str | None = None,
    headsurf: str | None = None,
    smheadsurf: str | None = None,
    hemi: str | None = None,
    subjects_dir: str | None = None,
    umask: float | None = None,
    logfile: str | None = None,
    runner: Runner | None = None,
) -> MkheadsurfOutputs:
    """
    Segment and create a surface representation of the head for visualization and
    further processing.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_vol: Input volume.
        output_vol: Output volume.
        output_surf: Output surface.
        subject_id: Subject ID.
        nsmooth: Number of smoothing iterations (default 10).
        noseghead: Do not segment the head, only tessellate and smooth existing.
        thresh1: Threshold 1 value (default 20).
        thresh2: Threshold 2 value (default 20).
        nhitsmin: Minimum number of hits (default 2).
        ndilate: Number of dilations (default 0).
        nerode: Number of erosions (default 0).
        fillval: Fill value (default 1).
        fhi: FHI for MRIchangeType; default is to use default in mri_seghead.
        no_rescale: Do not rescale input when converting to uchar.
        no_fill_holes_islands: Do not fill holes and remove islands.
        or_mask: Include all voxels in ormask in the head seg.
        tessellation_method: Tessellation method using mri_tessellate or mri_mc\
            (default is -mc).
        inflate: Inflate and compute sulc.
        curv: Compute curv with smoothing.
        srcvol: Source volume ID (default is T1).
        headvol: Head volume ID (default is seghead).
        headsurf: Head surface ID (default is seghead).
        smheadsurf: Smoothed head surface ID (default is smseghead).
        hemi: Hemisphere (default is lh).
        subjects_dir: Subjects directory (default is SUBJECTS_DIR).
        umask: Umask setting (default is 2).
        logfile: Log file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MkheadsurfOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MKHEADSURF_METADATA)
    cargs = []
    cargs.append("mkheadsurf")
    cargs.extend([
        "-i",
        execution.input_file(input_vol)
    ])
    cargs.extend([
        "-o",
        output_vol
    ])
    cargs.extend([
        "-surf",
        output_surf
    ])
    cargs.extend([
        "-s",
        subject_id
    ])
    if nsmooth is not None:
        cargs.extend([
            "-nsmooth",
            str(nsmooth)
        ])
    if noseghead:
        cargs.append("-noseghead")
    if thresh1 is not None:
        cargs.extend([
            "-thresh1",
            str(thresh1)
        ])
    if thresh2 is not None:
        cargs.extend([
            "-thresh2",
            str(thresh2)
        ])
    if nhitsmin is not None:
        cargs.extend([
            "-nhitsmin",
            str(nhitsmin)
        ])
    if ndilate is not None:
        cargs.extend([
            "-ndilate",
            str(ndilate)
        ])
    if nerode is not None:
        cargs.extend([
            "-nerode",
            str(nerode)
        ])
    if fillval is not None:
        cargs.extend([
            "-fillval",
            str(fillval)
        ])
    if fhi is not None:
        cargs.extend([
            "-fhi",
            str(fhi)
        ])
    if no_rescale:
        cargs.append("-no-rescale")
    if no_fill_holes_islands:
        cargs.append("-no-fill-holes-islands")
    if or_mask is not None:
        cargs.extend([
            "-or-mask",
            execution.input_file(or_mask)
        ])
    if tessellation_method is not None:
        cargs.extend([
            "-tess",
            tessellation_method
        ])
    if inflate:
        cargs.append("-inflate")
    if curv:
        cargs.append("-curv")
    if srcvol is not None:
        cargs.extend([
            "-srcvol",
            srcvol
        ])
    if headvol is not None:
        cargs.extend([
            "-headvol",
            headvol
        ])
    if headsurf is not None:
        cargs.extend([
            "-headsurf",
            headsurf
        ])
    if smheadsurf is not None:
        cargs.extend([
            "-smheadsurf",
            smheadsurf
        ])
    if hemi is not None:
        cargs.extend([
            "-hemi",
            hemi
        ])
    if subjects_dir is not None:
        cargs.extend([
            "-sd",
            subjects_dir
        ])
    if umask is not None:
        cargs.extend([
            "-umask",
            str(umask)
        ])
    if logfile is not None:
        cargs.extend([
            "-log",
            logfile
        ])
    ret = MkheadsurfOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MKHEADSURF_METADATA",
    "MkheadsurfOutputs",
    "mkheadsurf",
]
