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

import typing
import pathlib
from styxdefs import *
import dataclasses

LONG_STATS_SLOPES_METADATA = Metadata(
    id="c2f3a04515aabb1b936d652c2eb0e27439e032e8.boutiques",
    name="long_stats_slopes",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def long_stats_slopes(
    qdec_table: InputPathType,
    stats_file: InputPathType,
    measure: str,
    subjects_dir: str,
    do_avg: bool = False,
    do_rate: bool = False,
    do_pc1fit: bool = False,
    do_pc1: bool = False,
    do_spc: bool = False,
    do_stack: bool = False,
    resid: float | None = None,
    time_var: str | None = None,
    generic_time: bool = False,
    cross_sectional: bool = False,
    out_avg: str | None = None,
    out_rate: str | None = None,
    out_pc1fit: str | None = None,
    out_pc1: str | None = None,
    out_spc: str | None = None,
    out_resid: str | None = None,
    out_stack: str | None = None,
    stack_avg: str | None = None,
    stack_rate: str | None = None,
    stack_pc1fit: str | None = None,
    stack_pc1: str | None = None,
    stack_spc: str | None = None,
    stack_resid: str | None = None,
    runner: Runner | None = None,
) -> LongStatsSlopesOutputs:
    """
    Computes slopes of statistics in a longitudinal study for each subject from
    processed results, outputting to designated directories for further analysis.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        qdec_table: QDEC table file specifying the subjects and time points.
        stats_file: The stats file, e.g. aseg.stats or lh.aparc.stats.
        measure: The stats measure (e.g. volume, thickness, mean, std).
        subjects_dir: Full path to FreeSurfer subjects directory.
        do_avg: Compute and output the temporal average.
        do_rate: Compute and output the rate.
        do_pc1fit: Compute and output the percent change with respect to tp1\
            from linear fit.
        do_pc1: Compute and output the percent change with respect to tp1.
        do_spc: Compute and output the symmetric percent change with respect to\
            temporal average.
        do_stack: Compute and output tables showing the time series (row per\
            time point).
        resid: Residual timepoint to export (pass 1 for tp1, etc., pass 0 for\
            average).
        time_var: Variable name for time column variable (e.g., age) in QDEC\
            table.
        generic_time: Time points are ordered in QDEC file; assume\
            time=1,2,3...
        cross_sectional: Use cross-sectional results (for testing only).
        out_avg: Filename to store temporal average in\
            <template>/stats/<OUT_AVG>.
        out_rate: Filename to store rate in <template>/stats/<OUT_RATE>.
        out_pc1fit: Filename to store percent change to tp1fit in\
            <template>/stats/<OUT_PC1FIT>.
        out_pc1: Filename to store percent change to tp1 in\
            <template>/stats/<OUT_PC1>.
        out_spc: Filename to store symmetric percent change in\
            <template>/stats/<OUT_SPC>.
        out_resid: Filename to store residual in <template>/stats/<OUT_RESID>.
        out_stack: Filename to store stacked measure file in\
            <template>/stats/<OUT_STACK>.
        stack_avg: Full filename to stack temporal average tables.
        stack_rate: Full filename to stack rate tables.
        stack_pc1fit: Full filename to stack percent change to tp1fit tables.
        stack_pc1: Full filename to stack percent change to tp1 tables.
        stack_spc: Full filename to stack symmetric percent change tables.
        stack_resid: Full filename to stack residual tables.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `LongStatsSlopesOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(LONG_STATS_SLOPES_METADATA)
    cargs = []
    cargs.append("long_stats_slopes")
    cargs.extend([
        "--qdec",
        execution.input_file(qdec_table)
    ])
    cargs.extend([
        "--stats",
        execution.input_file(stats_file)
    ])
    cargs.extend([
        "--meas",
        measure
    ])
    cargs.extend([
        "--sd",
        subjects_dir
    ])
    if do_avg:
        cargs.append("--do-avg")
    if do_rate:
        cargs.append("--do-rate")
    if do_pc1fit:
        cargs.append("--do-pc1fit")
    if do_pc1:
        cargs.append("--do-pc1")
    if do_spc:
        cargs.append("--do-spc")
    if do_stack:
        cargs.append("--do-stack")
    if resid is not None:
        cargs.extend([
            "--resid",
            str(resid)
        ])
    if time_var is not None:
        cargs.extend([
            "--time",
            time_var
        ])
    if generic_time:
        cargs.append("--generic-time")
    if cross_sectional:
        cargs.append("--cross")
    if out_avg is not None:
        cargs.extend([
            "--out-avg",
            out_avg
        ])
    if out_rate is not None:
        cargs.extend([
            "--out-rate",
            out_rate
        ])
    if out_pc1fit is not None:
        cargs.extend([
            "--out-pc1fit",
            out_pc1fit
        ])
    if out_pc1 is not None:
        cargs.extend([
            "--out-pc1",
            out_pc1
        ])
    if out_spc is not None:
        cargs.extend([
            "--out-spc",
            out_spc
        ])
    if out_resid is not None:
        cargs.extend([
            "--out-resid",
            out_resid
        ])
    if out_stack is not None:
        cargs.extend([
            "--out-stack",
            out_stack
        ])
    if stack_avg is not None:
        cargs.extend([
            "--stack-avg",
            stack_avg
        ])
    if stack_rate is not None:
        cargs.extend([
            "--stack-rate",
            stack_rate
        ])
    if stack_pc1fit is not None:
        cargs.extend([
            "--stack-pc1fit",
            stack_pc1fit
        ])
    if stack_pc1 is not None:
        cargs.extend([
            "--stack-pc1",
            stack_pc1
        ])
    if stack_spc is not None:
        cargs.extend([
            "--stack-spc",
            stack_spc
        ])
    if stack_resid is not None:
        cargs.extend([
            "--stack-resid",
            stack_resid
        ])
    ret = LongStatsSlopesOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "LONG_STATS_SLOPES_METADATA",
    "LongStatsSlopesOutputs",
    "long_stats_slopes",
]
