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

import typing
import pathlib
from styxdefs import *
import dataclasses

SEGMENT_SUBREGIONS_METADATA = Metadata(
    id="979b0a18dd6ab667938e69e0395fa4e8339bd23a.boutiques",
    name="segment_subregions",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def segment_subregions(
    structure: str,
    cross: str | None = None,
    long_base: str | None = None,
    sd: str | None = None,
    suffix: str | None = None,
    temp_dir: str | None = None,
    out_dir: str | None = None,
    debug: bool = False,
    threads: float | None = None,
    runner: Runner | None = None,
) -> SegmentSubregionsOutputs:
    """
    Cross-sectional and longitudinal segmentation for brain structures like
    thalamus, brainstem, and hippo-amygdala.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        structure: Structure to segment. Options are: thalamus, brainstem,\
            hippo-amygdala.
        cross: Subject to segment in cross-sectional analysis.
        long_base: Base subject for longitudinal analysis. Timepoints are\
            extracted from the base-tps file.
        sd: Specify subjects directory (will override SUBJECTS_DIR env\
            variable).
        suffix: Optional output file suffix.
        temp_dir: Use alternative temporary directory. This will get deleted\
            unless --debug is enabled.
        out_dir: Use alternative output directory (only for cross-sectional).\
            Default is the subject's `mri` directory.
        debug: Write intermediate debugging outputs.
        threads: Number of threads to use. Defaults to 1.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SegmentSubregionsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SEGMENT_SUBREGIONS_METADATA)
    cargs = []
    cargs.append("segment_subregions")
    cargs.append(structure)
    if cross is not None:
        cargs.extend([
            "--cross",
            cross
        ])
    if long_base is not None:
        cargs.extend([
            "--long-base",
            long_base
        ])
    if sd is not None:
        cargs.extend([
            "--sd",
            sd
        ])
    if suffix is not None:
        cargs.extend([
            "--suffix",
            suffix
        ])
    if temp_dir is not None:
        cargs.extend([
            "--temp-dir",
            temp_dir
        ])
    if out_dir is not None:
        cargs.extend([
            "--out-dir",
            out_dir
        ])
    if debug:
        cargs.append("--debug")
    if threads is not None:
        cargs.extend([
            "--threads",
            str(threads)
        ])
    ret = SegmentSubregionsOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SEGMENT_SUBREGIONS_METADATA",
    "SegmentSubregionsOutputs",
    "segment_subregions",
]
