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

import typing
import pathlib
from styxdefs import *
import dataclasses

LONG_STATS_TPS_METADATA = Metadata(
    id="bc2f340c25927fb0b4a967b198182aa268f9cf9f.boutiques",
    name="long_stats_tps",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class LongStatsTpsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `long_stats_tps(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    stacked_results: OutputPathType
    """File containing stacked results for individual time points."""


def long_stats_tps(
    qdec_table: InputPathType,
    stats_file: str,
    measure: str,
    subjects_dir: str,
    time_point: float,
    output_file: str,
    qcolumn: str | None = None,
    cross_sectional: bool = False,
    runner: Runner | None = None,
) -> LongStatsTpsOutputs:
    """
    Stack results for individual time points based on longitudinal qdec table.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        qdec_table: qdec.table.dat file with first columns: fsid fsid-base.
        stats_file: Stats file without path: e.g. aseg.stats or lh.aparc.stats.
        measure: Stats measure, e.g. volume, thickness, mean, std.
        subjects_dir: Full path to FreeSurfer subjects directory.
        time_point: Time point number.
        output_file: File name of output.
        qcolumn: Select a column from the qdec table itself (then --stats,\
            --meas and --sd are not necessary).
        cross_sectional: Use cross sectional results (for testing only).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `LongStatsTpsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(LONG_STATS_TPS_METADATA)
    cargs = []
    cargs.append("long_stats_tps")
    cargs.extend([
        "--qdec",
        "--qdec=" + execution.input_file(qdec_table)
    ])
    cargs.extend([
        "--stats",
        "--stats=" + stats_file
    ])
    cargs.extend([
        "--meas",
        "--meas=" + measure
    ])
    cargs.extend([
        "--sd",
        "--sd=" + subjects_dir
    ])
    cargs.extend([
        "--tp",
        "--tp=" + str(time_point)
    ])
    cargs.extend([
        "--out",
        "--out=" + output_file
    ])
    if qcolumn is not None:
        cargs.extend([
            "--qcol",
            qcolumn
        ])
    if cross_sectional:
        cargs.append("--cross")
    ret = LongStatsTpsOutputs(
        root=execution.output_file("."),
        stacked_results=execution.output_file(output_file),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "LONG_STATS_TPS_METADATA",
    "LongStatsTpsOutputs",
    "long_stats_tps",
]
