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

import typing
import pathlib
from styxdefs import *
import dataclasses

GROUPSTATS_METADATA = Metadata(
    id="b3ed2b7c0070683b40d589d0c64dbdd96b53715f.boutiques",
    name="groupstats",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class GroupstatsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `groupstats(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_files: OutputPathType
    """Output files generated by groupstats."""


def groupstats(
    outdir: str,
    subjectfile: InputPathType | None = None,
    fwhm: list[float] | None = None,
    subject_dir: str | None = None,
    mapname: str | None = None,
    srcsurfreg: str | None = None,
    keep53: bool = False,
    runner: Runner | None = None,
) -> GroupstatsOutputs:
    """
    A script for comprehensive group analysis on both maps and ROI results within
    FreeSurfer.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        outdir: Output folder.
        subjectfile: Subject list file.
        fwhm: Specify smoothing level(s).
        subject_dir: Subject directory.
        mapname: Use the given map name.
        srcsurfreg: Source surface registration (default is sphere.reg).
        keep53: Keep 5.3 aseg names (e.g., Thalamus-Proper).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `GroupstatsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(GROUPSTATS_METADATA)
    cargs = []
    cargs.append("groupstats")
    cargs.extend([
        "--o",
        outdir
    ])
    if subjectfile is not None:
        cargs.extend([
            "--f",
            execution.input_file(subjectfile)
        ])
    if fwhm is not None:
        cargs.extend([
            "--fwhm",
            *map(str, fwhm)
        ])
    if subject_dir is not None:
        cargs.extend([
            "--sd",
            subject_dir
        ])
    if mapname is not None:
        cargs.extend([
            "--m",
            mapname
        ])
    if srcsurfreg is not None:
        cargs.extend([
            "--srcsurfreg",
            srcsurfreg
        ])
    if keep53:
        cargs.append("--keep53")
    ret = GroupstatsOutputs(
        root=execution.output_file("."),
        output_files=execution.output_file(outdir + "/<output_file>.ext"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "GROUPSTATS_METADATA",
    "GroupstatsOutputs",
    "groupstats",
]
