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

import typing
import pathlib
from styxdefs import *
import dataclasses

ASEGSTATS2TABLE_METADATA = Metadata(
    id="75e1aab6262bf11a4bb07f90323b14452beb59b8.boutiques",
    name="asegstats2table",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class Asegstats2tableOutputs(typing.NamedTuple):
    """
    Output object returned when calling `asegstats2table(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_table: OutputPathType
    """The resulting table file with segmentation data."""


def asegstats2table(
    tablefile: str,
    subjects: list[str] | None = None,
    inputs: list[str] | None = None,
    subjectsfile: InputPathType | None = None,
    qdec: InputPathType | None = None,
    qdec_long: InputPathType | None = None,
    fsgd: InputPathType | None = None,
    maxsegno: list[str] | None = None,
    segids_from_file: InputPathType | None = None,
    segno_include: list[str] | None = None,
    segno_exclude: list[str] | None = None,
    measure: str | None = None,
    delimiter: str | None = None,
    statsfile: str | None = None,
    subdir: str | None = None,
    scale: float | None = None,
    write_etiv: bool = False,
    debug: bool = False,
    transpose_flag: bool = False,
    common_segs_flag: bool = False,
    all_segs_flag: bool = False,
    no_vol_extras_flag: bool = False,
    skip_missing_flag: bool = False,
    replace53_flag: bool = False,
    runner: Runner | None = None,
) -> Asegstats2tableOutputs:
    """
    Converts a subcortical stats file created by recon-all and/or mri_segstats
    (e.g., aseg.stats) into a table.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        tablefile: The output table file.
        subjects: List of subjects.
        inputs: List of input stat files.
        subjectsfile: Name of the file which has the list of subjects (one\
            subject per line).
        qdec: Name of the qdec table which has the column of subjects ids\
            (fsid).
        qdec_long: Name of the longitudinal qdec table with column of tp ids\
            (fsid) and subject templates (fsid-base).
        fsgd: Name of the FSGD file to extract subjects from.
        maxsegno: Specify the maximum segmentation number.
        segids_from_file: Output only the segmentations present in the\
            specified file.
        segno_include: Include only the specified segmentation IDs.
        segno_exclude: Exclude the specified segmentation IDs.
        measure: Measure to report: default is volume (alternative: mean, std).
        delimiter: Delimiter between measures in the table. Default is tab\
            (alternative: comma, space, semicolon).
        statsfile: Use specified stats file instead of 'aseg.stats'.
        subdir: Use specified subdir instead of 'stats/'.
        scale: Scale factor for all values written to output file. Default is\
            1.
        write_etiv: Report volume as percent estimated total intracranial\
            volume.
        debug: Increase verbosity for debugging purposes.
        transpose_flag: Transpose the table: subjects in columns and\
            segmentations in rows.
        common_segs_flag: Output only the segmentations common to all stats\
            files.
        all_segs_flag: Output all segmentations in the stats files given.
        no_vol_extras_flag: Do not include global volume measures like\
            BrainSegVol.
        skip_missing_flag: Skip subjects that do not have a stats file.
        replace53_flag: Replace 5.3 structure names with later names.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Asegstats2tableOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ASEGSTATS2TABLE_METADATA)
    cargs = []
    cargs.append("asegstats2table")
    if subjects is not None:
        cargs.extend([
            "--subjects",
            *subjects
        ])
    if inputs is not None:
        cargs.extend([
            "--inputs",
            *inputs
        ])
    cargs.extend([
        "--tablefile",
        tablefile
    ])
    if subjectsfile is not None:
        cargs.extend([
            "--subjectsfile",
            execution.input_file(subjectsfile)
        ])
    if qdec is not None:
        cargs.extend([
            "--qdec",
            execution.input_file(qdec)
        ])
    if qdec_long is not None:
        cargs.extend([
            "--qdec-long",
            execution.input_file(qdec_long)
        ])
    if fsgd is not None:
        cargs.extend([
            "--fsgd",
            execution.input_file(fsgd)
        ])
    if maxsegno is not None:
        cargs.extend([
            "--maxsegno",
            *maxsegno
        ])
    if segids_from_file is not None:
        cargs.extend([
            "--segids-from-file",
            execution.input_file(segids_from_file)
        ])
    if segno_include is not None:
        cargs.extend([
            "--segno",
            *segno_include
        ])
    if segno_exclude is not None:
        cargs.extend([
            "--no-segno",
            *segno_exclude
        ])
    if measure is not None:
        cargs.extend([
            "--meas",
            measure
        ])
    if delimiter is not None:
        cargs.extend([
            "--delimiter",
            delimiter
        ])
    if statsfile is not None:
        cargs.extend([
            "--statsfile",
            statsfile
        ])
    if subdir is not None:
        cargs.extend([
            "--subdir",
            subdir
        ])
    if scale is not None:
        cargs.extend([
            "--scale",
            str(scale)
        ])
    if write_etiv:
        cargs.append("--etiv")
    if debug:
        cargs.append("--debug")
    if transpose_flag:
        cargs.append("--transpose")
    if common_segs_flag:
        cargs.append("--common-segs")
    if all_segs_flag:
        cargs.append("--all-segs")
    if no_vol_extras_flag:
        cargs.append("--no-vol-extras")
    if skip_missing_flag:
        cargs.append("--skip")
    if replace53_flag:
        cargs.append("--replace53")
    ret = Asegstats2tableOutputs(
        root=execution.output_file("."),
        output_table=execution.output_file(tablefile),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ASEGSTATS2TABLE_METADATA",
    "Asegstats2tableOutputs",
    "asegstats2table",
]
