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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_AUTODET_GWSTATS_METADATA = Metadata(
    id="2408fc8252de26e31ffbcec5b0f37d3113618a46.boutiques",
    name="mris_autodet_gwstats",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisAutodetGwstatsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_autodet_gwstats(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """Output text file with gray/white statistics"""


def mris_autodet_gwstats(
    output_file: str,
    t1w_volume: InputPathType,
    wm_volume: InputPathType,
    surf: InputPathType,
    subject: str,
    subjects_dir: str,
    lhsurf: InputPathType | None = None,
    rhsurf: InputPathType | None = None,
    min_border_white: float | None = None,
    max_border_white: float | None = None,
    min_gray_at_white_border: float | None = None,
    max_gray: float | None = None,
    max_gray_at_csf_border: float | None = None,
    min_gray_at_csf_border: float | None = None,
    max_csf: float | None = None,
    runner: Runner | None = None,
) -> MrisAutodetGwstatsOutputs:
    """
    Manages the computation of the gray/white statistics used to place the white and
    pial surfaces.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        output_file: Output text file with stats.
        t1w_volume: T1 weighted volume (usually brain.finalsurfs.mgz).
        wm_volume: White matter volume (usually wm.mgz).
        surf: Surface (usually ?h.orig).
        subject: Subject: reads in brain.finalsurfs.mgz, wm.mgz, lh.orig and\
            rh.orig.
        subjects_dir: SUBJECTS_DIR.
        lhsurf: Left hemisphere surface.
        rhsurf: Right hemisphere surface.
        min_border_white: Minimum border white (MinBW).
        max_border_white: Maximum border white (MaxBW).
        min_gray_at_white_border: Minimum gray at white border (MinGWB).
        max_gray: Maximum gray (MaxG).
        max_gray_at_csf_border: Maximum gray at CSF border (MaxGCSFB).
        min_gray_at_csf_border: Minimum gray at CSF border (MinGCSFB).
        max_csf: Maximum CSF (MaxCSF).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisAutodetGwstatsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_AUTODET_GWSTATS_METADATA)
    cargs = []
    cargs.append("mris_autodet_gwstats")
    cargs.extend([
        "--o",
        output_file
    ])
    cargs.extend([
        "--i",
        execution.input_file(t1w_volume)
    ])
    cargs.extend([
        "--wm",
        execution.input_file(wm_volume)
    ])
    cargs.extend([
        "--surf",
        execution.input_file(surf)
    ])
    if lhsurf is not None:
        cargs.extend([
            "--lh-surf",
            execution.input_file(lhsurf)
        ])
    if rhsurf is not None:
        cargs.extend([
            "--rh-surf",
            execution.input_file(rhsurf)
        ])
    cargs.extend([
        "--s",
        subject
    ])
    cargs.extend([
        "--sd",
        subjects_dir
    ])
    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_at_white_border is not None:
        cargs.extend([
            "--min_gray_at_white_border",
            str(min_gray_at_white_border)
        ])
    if max_gray is not None:
        cargs.extend([
            "--max_gray",
            str(max_gray)
        ])
    if max_gray_at_csf_border is not None:
        cargs.extend([
            "--max_gray_at_csf_border",
            str(max_gray_at_csf_border)
        ])
    if min_gray_at_csf_border is not None:
        cargs.extend([
            "--min_gray_at_csf_border",
            str(min_gray_at_csf_border)
        ])
    if max_csf is not None:
        cargs.extend([
            "--max_csf",
            str(max_csf)
        ])
    ret = MrisAutodetGwstatsOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(output_file),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_AUTODET_GWSTATS_METADATA",
    "MrisAutodetGwstatsOutputs",
    "mris_autodet_gwstats",
]
