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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_BRAINVOL_STATS_METADATA = Metadata(
    id="86418de6f4396170ffc91b86701f5d618ef8249c.boutiques",
    name="mri_brainvol_stats",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriBrainvolStatsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_brainvol_stats(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    brain_vol_stats_output: OutputPathType | None
    """Brain volume statistics output file."""


def mri_brainvol_stats(
    subject_id: str,
    xml_string: str | None = None,
    no_surface: bool = False,
    include_segmentation: bool = False,
    output_file: InputPathType | None = None,
    runner: Runner | None = None,
) -> MriBrainvolStatsOutputs:
    """
    Tool for computing brain volume statistics with FreeSurfer.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject_id: The subject ID for which brain volume statistics are\
            computed.
        xml_string: XML string containing input data. The XML is used to define\
            additional parameters for computation.
        no_surface: Flag to specify that surface-based measurements should not\
            be included in the output.
        include_segmentation: Flag to include segmentation information in the\
            brain volume calculations.
        output_file: Output file path to write the brain volume statistics.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriBrainvolStatsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_BRAINVOL_STATS_METADATA)
    cargs = []
    cargs.append("mri_brainvol_stats")
    cargs.extend([
        "--subject",
        subject_id
    ])
    if xml_string is not None:
        cargs.extend([
            "--xml",
            xml_string
        ])
    if no_surface:
        cargs.append("--no-surface")
    if include_segmentation:
        cargs.append("--seg")
    if output_file is not None:
        cargs.extend([
            "--out",
            execution.input_file(output_file)
        ])
    ret = MriBrainvolStatsOutputs(
        root=execution.output_file("."),
        brain_vol_stats_output=execution.output_file(pathlib.Path(output_file).name) if (output_file is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_BRAINVOL_STATS_METADATA",
    "MriBrainvolStatsOutputs",
    "mri_brainvol_stats",
]
