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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_MAKE_SURFACES_METADATA = Metadata(
    id="916ed4d56c0e1cd56b8963f58b7e229385c20cb5.boutiques",
    name="mris_make_surfaces",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def mris_make_surfaces(
    subject_name: str,
    hemisphere: str,
    white: str | None = None,
    pial: str | None = None,
    whiteonly: bool = False,
    nowhite: bool = False,
    orig_white: str | None = None,
    orig_pial: str | None = None,
    q: bool = False,
    max_gray_scale: float | None = None,
    c: bool = False,
    cortex: float | None = None,
    w: float | None = None,
    first_wm_peak: bool = False,
    a_avgs: float | None = None,
    pa_avgs: float | None = None,
    wa_avgs: float | None = None,
    t1_vol: str | None = None,
    w_vol: str | None = None,
    long: bool = False,
    dura_thresh: float | None = None,
    sdir: str | None = None,
    erase_cerebellum: bool = False,
    wm_weight: float | None = None,
    nsigma_above: float | None = None,
    nsigma_below: float | None = None,
    t2_min_inside: float | None = None,
    t2_max_inside: float | None = None,
    t2_outside_min: float | None = None,
    t2_outside_max: float | None = None,
    min_peak_pct: float | None = None,
    border_vals_hires: bool = False,
    no_unitize: bool = False,
    intensity: float | None = None,
    curv: float | None = None,
    tspring: float | None = None,
    nspring: float | None = None,
    repulse: float | None = None,
    save_target: bool = False,
    save_res: bool = False,
    v_vertexno: float | None = None,
    diag_vertex: float | None = None,
    rip: str | None = None,
    sigma_white: str | None = None,
    sigma_pial: str | None = None,
    output: str | None = None,
    min_border_white: float | None = None,
    max_border_white: float | None = None,
    min_gray_white_border: float | None = None,
    max_gray: float | None = None,
    max_gray_csf_border: float | None = None,
    min_gray_csf_border: float | None = None,
    max_csf: float | None = None,
    runner: Runner | None = None,
) -> MrisMakeSurfacesOutputs:
    """
    Positions the tessellation of the cortical surface at the white matter surface,
    then the gray matter surface, generating surface files along with a curvature
    file and a surface file for cortical thickness.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject_name: Name of the subject.
        hemisphere: Brain hemisphere (r or l).
        white: Output name for white surface (default is 'white'). Set to\
            NOWHITE to generate but not save white surface.
        pial: Output name for pial surface (default is 'pial').
        whiteonly: Only generate white matter surface.
        nowhite: Only generate pial surface.
        orig_white: Specify a white surface to start with.
        orig_pial: Specify a pial surface to start with.
        q: Omit self-intersection and only generate gray/white surface.
        max_gray_scale: Set maximum gray scale value.
        c: Do not create curvature and area files from white matter surface.
        cortex: Set to 0 to turn off creation of cortex label file.
        w: Unused argument.
        first_wm_peak: Settle WM surface at first peak in intensity profile\
            instead of highest.
        a_avgs: Average curvature values a number of times (default=10).
        pa_avgs: Average pial curvature values a max of a number of times\
            (default=16).
        wa_avgs: Average white curvature values a max of a number of times\
            (default=4).
        t1_vol: Specify T1 volume (default is brain).
        w_vol: Specify white volume and <hires> option.
        long: Run longitudinal analysis.
        dura_thresh: Set a threshold for the multi-echo mprage dura avoidance.
        sdir: Specify SUBJECTS_DIR.
        erase_cerebellum: Erase cerebellar labeled voxels if aseg is loaded.
        wm_weight: Weighting of WM mean in calculating T2 threshold of\
            disallowed GM values, default=3.
        nsigma_above: # of sigmas above the mean to allow gray matter T2\
            intensities.
        nsigma_below: # of sigmas below the mean to allow gray matter T2\
            intensities.
        t2_min_inside: Specify threshold for min T2 value allowed to be\
            interior to the cortical ribbon.
        t2_max_inside: Specify threshold for max T2 value allowed to be\
            interior to the cortical ribbon.
        t2_outside_min: Specify threshold for min T2 value outside of pial\
            surface that will cause surface to deform outwards.
        t2_outside_max: Specify threshold for max T2 value outside of pial\
            surface that will cause surface to deform outwards.
        min_peak_pct: Specify the pct of the histo peak in the local gm\
            histogram to use as threshold for finding the local inside and outside\
            gm thresholds.
        border_vals_hires: Turn on hires options in\
            MRIScomputeBorderValues_new(). May not be helpful.
        no_unitize: Turn off face normal unitization.
        intensity: Set weight of intensity cost.
        curv: Set weight of curvature cost.
        tspring: Set weight of tangential spring cost.
        nspring: Set weight of normal spring cost.
        repulse: Set weight of repulsion force.
        save_target: Save target surface for debugging.
        save_res: Save residual for debugging.
        v_vertexno: Set Gdiag_no to vertex number.
        diag_vertex: Set Gdiag_no to vertex number and turn off writing of\
            cortex label or curvature files.
        rip: Save ripflag as overlay. Specify full path including hemi, suffix,\
            etc.
        sigma_white: Save white surface sigma as overlay. Specify full path\
            including hemi, suffix, etc.
        sigma_pial: Save pial surface sigma as overlay. Specify full path\
            including hemi, suffix, etc.
        output: Append suffix to all outputs to prevent over-writing.
        min_border_white: Minimum border white.
        max_border_white: Maximum border white.
        min_gray_white_border: Minimum gray at white border.
        max_gray: Maximum gray value.
        max_gray_csf_border: Maximum gray at CSF border.
        min_gray_csf_border: Minimum gray at CSF border.
        max_csf: Maximum CSF value.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisMakeSurfacesOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_MAKE_SURFACES_METADATA)
    cargs = []
    cargs.append("mris_make_surfaces")
    cargs.append(subject_name)
    cargs.append(hemisphere)
    if white is not None:
        cargs.extend([
            "-white",
            white
        ])
    if pial is not None:
        cargs.extend([
            "-pial",
            pial
        ])
    if whiteonly:
        cargs.append("-whiteonly")
    if nowhite:
        cargs.append("-nowhite")
    if orig_white is not None:
        cargs.extend([
            "-orig_white",
            orig_white
        ])
    if orig_pial is not None:
        cargs.extend([
            "-orig_pial",
            orig_pial
        ])
    if q:
        cargs.append("-q")
    if max_gray_scale is not None:
        cargs.extend([
            "-max_gray_scale",
            str(max_gray_scale)
        ])
    if c:
        cargs.append("-c")
    if cortex is not None:
        cargs.extend([
            "-cortex",
            str(cortex)
        ])
    if w is not None:
        cargs.extend([
            "-w",
            str(w)
        ])
    if first_wm_peak:
        cargs.append("-first_wm_peak")
    if a_avgs is not None:
        cargs.extend([
            "-a",
            str(a_avgs)
        ])
    if pa_avgs is not None:
        cargs.extend([
            "-pa",
            str(pa_avgs)
        ])
    if wa_avgs is not None:
        cargs.extend([
            "-wa",
            str(wa_avgs)
        ])
    if t1_vol is not None:
        cargs.extend([
            "-T1",
            t1_vol
        ])
    if w_vol is not None:
        cargs.extend([
            "-wvol",
            w_vol
        ])
    if long:
        cargs.append("-long")
    if dura_thresh is not None:
        cargs.extend([
            "-dura_thresh",
            str(dura_thresh)
        ])
    if sdir is not None:
        cargs.extend([
            "-SDIR",
            sdir
        ])
    if erase_cerebellum:
        cargs.append("-erase_cerebellum")
    if wm_weight is not None:
        cargs.extend([
            "-wm_weight",
            str(wm_weight)
        ])
    if nsigma_above is not None:
        cargs.extend([
            "-nsigma_above",
            str(nsigma_above)
        ])
    if nsigma_below is not None:
        cargs.extend([
            "-nsigma_below",
            str(nsigma_below)
        ])
    if t2_min_inside is not None:
        cargs.extend([
            "-T2_min_inside",
            str(t2_min_inside)
        ])
    if t2_max_inside is not None:
        cargs.extend([
            "-T2_max_inside",
            str(t2_max_inside)
        ])
    if t2_outside_min is not None:
        cargs.extend([
            "-T2_outside_min",
            str(t2_outside_min)
        ])
    if t2_outside_max is not None:
        cargs.extend([
            "-T2_outside_max",
            str(t2_outside_max)
        ])
    if min_peak_pct is not None:
        cargs.extend([
            "-min_peak_pct",
            str(min_peak_pct)
        ])
    if border_vals_hires:
        cargs.append("-border-vals-hires")
    if no_unitize:
        cargs.append("-no-unitize")
    if intensity is not None:
        cargs.extend([
            "-intensity",
            str(intensity)
        ])
    if curv is not None:
        cargs.extend([
            "-curv",
            str(curv)
        ])
    if tspring is not None:
        cargs.extend([
            "-tspring",
            str(tspring)
        ])
    if nspring is not None:
        cargs.extend([
            "-nspring",
            str(nspring)
        ])
    if repulse is not None:
        cargs.extend([
            "-repulse",
            str(repulse)
        ])
    if save_target:
        cargs.append("-save-target")
    if save_res:
        cargs.append("-save-res")
    if v_vertexno is not None:
        cargs.extend([
            "-v",
            str(v_vertexno)
        ])
    if diag_vertex is not None:
        cargs.extend([
            "-diag-vertex",
            str(diag_vertex)
        ])
    if rip is not None:
        cargs.extend([
            "-rip",
            rip
        ])
    if sigma_white is not None:
        cargs.extend([
            "-sigma-white",
            sigma_white
        ])
    if sigma_pial is not None:
        cargs.extend([
            "-sigma-pial",
            sigma_pial
        ])
    if output is not None:
        cargs.extend([
            "-output",
            output
        ])
    if min_border_white is not None:
        cargs.extend([
            "-min_border_white",
            str(min_border_white)
        ])
    if max_border_white is not None:
        cargs.extend([
            "-max_border_white",
            str(max_border_white)
        ])
    if min_gray_white_border is not None:
        cargs.extend([
            "-min_gray_at_white_border",
            str(min_gray_white_border)
        ])
    if max_gray is not None:
        cargs.extend([
            "-max_gray",
            str(max_gray)
        ])
    if max_gray_csf_border is not None:
        cargs.extend([
            "-max_gray_at_csf_border",
            str(max_gray_csf_border)
        ])
    if min_gray_csf_border is not None:
        cargs.extend([
            "-min_gray_at_csf_border",
            str(min_gray_csf_border)
        ])
    if max_csf is not None:
        cargs.extend([
            "-max_csf",
            str(max_csf)
        ])
    ret = MrisMakeSurfacesOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_MAKE_SURFACES_METADATA",
    "MrisMakeSurfacesOutputs",
    "mris_make_surfaces",
]
