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

import typing
import pathlib
from styxdefs import *
import dataclasses

QATOOLS_PY_METADATA = Metadata(
    id="4d18f6a5ac40096b70dbf7ebf5df96bcffd4d1fe.boutiques",
    name="qatools.py",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class QatoolsPyOutputs(typing.NamedTuple):
    """
    Output object returned when calling `qatools_py(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    summary_csv: OutputPathType
    """Summary CSV file containing quality metrics."""
    screenshots_output: OutputPathType
    """Directory containing screenshots of individual brains if screenshots
    option is selected."""


def qatools_py(
    subjects_dir: str,
    output_dir: str,
    subjects: list[str] | None = None,
    screenshots: bool = False,
    fornix: bool = False,
    outlier: bool = False,
    outlier_table: InputPathType | None = None,
    runner: Runner | None = None,
) -> QatoolsPyOutputs:
    """
    A tool to compute quality metrics from Freesurfer 6.0 analysis results.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subjects_dir: Subjects directory containing a set of Freesurfer 6.0\
            processed individual datasets.
        output_dir: Output directory for the generated results.
        subjects: List of subject IDs. If omitted, all suitable subdirectories\
            within the subjects directory will be used.
        screenshots: Create screenshots of individual brains.
        fornix: Check fornix segmentation.
        outlier: Run outlier detection.
        outlier_table: Specify normative values for outlier detection.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `QatoolsPyOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(QATOOLS_PY_METADATA)
    cargs = []
    cargs.append("qatools.py")
    cargs.extend([
        "--subjects_dir",
        subjects_dir
    ])
    cargs.extend([
        "--output_dir",
        output_dir
    ])
    if subjects is not None:
        cargs.extend([
            "--subjects",
            *subjects
        ])
    if screenshots:
        cargs.append("--screenshots")
    if fornix:
        cargs.append("--fornix")
    if outlier:
        cargs.append("--outlier")
    if outlier_table is not None:
        cargs.extend([
            "--outlier-table",
            execution.input_file(outlier_table)
        ])
    ret = QatoolsPyOutputs(
        root=execution.output_file("."),
        summary_csv=execution.output_file(output_dir + "/summary.csv"),
        screenshots_output=execution.output_file(output_dir + "/screenshots/"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "QATOOLS_PY_METADATA",
    "QatoolsPyOutputs",
    "qatools_py",
]
