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

import typing
import pathlib
from styxdefs import *
import dataclasses

APARC_STATS_ASEG_METADATA = Metadata(
    id="f369685392146e6aac3bec57244b528c1438fc58.boutiques",
    name="aparc_stats_aseg",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def aparc_stats_aseg(
    subject_name: str,
    gcs_name: str,
    subject_dir: str | None = None,
    gcs_dir: str | None = None,
    parc_name: str | None = None,
    output_dir: str | None = None,
    log_file: str | None = None,
    lh_flag: bool = False,
    rh_flag: bool = False,
    a2009s_flag: bool = False,
    no_aseg_flag: bool = False,
    no_cortparc_flag: bool = False,
    no_parcstats_flag: bool = False,
    no_aparc2aseg_flag: bool = False,
    random_seed: float | None = None,
    th3_flag: bool = False,
    no_th3_flag: bool = False,
    longitudinal: list[str] | None = None,
    expert_file: str | None = None,
    expert_use_flag: bool = False,
    expert_clean_flag: bool = False,
    expert_overwrite_flag: bool = False,
    runner: Runner | None = None,
) -> AparcStatsAsegOutputs:
    """
    This program runs mris_ca_label, mris_anatomical_stats and mri_aparc2aseg.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject_name: Subject name.
        gcs_name: GCS file name.
        subject_dir: Specify a subjects directory\
            (default=/usr/local/freesurfer/subjects).
        gcs_dir: GCS file directory (default=/usr/local/freesurfer/average).
        parc_name: Specify the parcellation name (default=gcs name).
        output_dir: Specify the output directory.
        log_file: Specify the log file.
        lh_flag: Left hemisphere only.
        rh_flag: Right hemisphere only.
        a2009s_flag: Use Christophe Destrieux cortical parcellation atlas.
        no_aseg_flag: Do not use aseg.
        no_cortparc_flag: Do not do cortical parcellation.
        no_parcstats_flag: Do not do surface anatomical statistics.
        no_aparc2aseg_flag: Do not do aparc2aseg.
        random_seed: Random seed (default=1234).
        th3_flag: Use -th3 flag, turn on new volume calculation for\
            mris_anatomical_stats.
        no_th3_flag: Use -no-th3 flag for mris_anatomical_stats.
        longitudinal: Longitudinal Processing.
        expert_file: Read-in expert options file.
        expert_use_flag: Use pre-existing expert options file.
        expert_clean_flag: Delete pre-existing expert options file.
        expert_overwrite_flag: Overwrite pre-existing expert options file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AparcStatsAsegOutputs`).
    """
    if longitudinal is not None and (len(longitudinal) != 2): 
        raise ValueError(f"Length of 'longitudinal' must be 2 but was {len(longitudinal)}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(APARC_STATS_ASEG_METADATA)
    cargs = []
    cargs.append("aparc_stats_aseg")
    cargs.extend([
        "-s",
        subject_name
    ])
    cargs.extend([
        "-gcs",
        gcs_name
    ])
    if subject_dir is not None:
        cargs.extend([
            "-sd",
            subject_dir
        ])
    if gcs_dir is not None:
        cargs.extend([
            "-gcsd",
            gcs_dir
        ])
    if parc_name is not None:
        cargs.extend([
            "-name",
            parc_name
        ])
    if output_dir is not None:
        cargs.extend([
            "-o",
            output_dir
        ])
    if log_file is not None:
        cargs.extend([
            "-log",
            log_file
        ])
    if lh_flag:
        cargs.append("-lh")
    if rh_flag:
        cargs.append("-rh")
    if a2009s_flag:
        cargs.append("-a2009s")
    if no_aseg_flag:
        cargs.append("-noaseg")
    if no_cortparc_flag:
        cargs.append("-nocortparc")
    if no_parcstats_flag:
        cargs.append("-noparcstats")
    if no_aparc2aseg_flag:
        cargs.append("-noaparc2aseg")
    if random_seed is not None:
        cargs.extend([
            "-seed",
            str(random_seed)
        ])
    if th3_flag:
        cargs.append("-th3")
    if no_th3_flag:
        cargs.append("-no-th3")
    if longitudinal is not None:
        cargs.extend([
            "-long",
            *longitudinal
        ])
    if expert_file is not None:
        cargs.extend([
            "-expert",
            expert_file
        ])
    if expert_use_flag:
        cargs.append("-xopts-use")
    if expert_clean_flag:
        cargs.append("-xopts-clean")
    if expert_overwrite_flag:
        cargs.append("-xopts-overwrite")
    ret = AparcStatsAsegOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "APARC_STATS_ASEG_METADATA",
    "AparcStatsAsegOutputs",
    "aparc_stats_aseg",
]
