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

import typing
import pathlib
from styxdefs import *
import dataclasses

SEGPONS_METADATA = Metadata(
    id="4b38e194fdd9fe1d16fc15d6ac746b2dffa56e0f.boutiques",
    name="segpons",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class SegponsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `segpons(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    pons_output: OutputPathType
    """Output pons segmentation file."""


def segpons(
    subject: str,
    aseg: bool = False,
    apas: bool = False,
    seg: InputPathType | None = None,
    no_refine: bool = False,
    pons152_mask: InputPathType | None = None,
    runner: Runner | None = None,
) -> SegponsOutputs:
    """
    Approximate segmentation of pons using MNI152 space registration.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: Subject identifier.
        aseg: Use and refine aseg (default, output will be aseg+pons.mgz).
        apas: Use aparc+aseg.mgz (output will be apas+pons.mgz).
        seg: Specify your own segmentation file.
        no_refine: Do not refine when using aseg.
        pons152_mask: Mask of pons in MNI152 space.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SegponsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SEGPONS_METADATA)
    cargs = []
    cargs.append("segpons")
    cargs.extend([
        "-s",
        "-" + subject
    ])
    if aseg:
        cargs.append("--aseg")
    if apas:
        cargs.append("--apas")
    if seg is not None:
        cargs.extend([
            "--seg",
            execution.input_file(seg)
        ])
    if no_refine:
        cargs.append("--no-refine")
    if pons152_mask is not None:
        cargs.extend([
            "--pons152",
            execution.input_file(pons152_mask)
        ])
    ret = SegponsOutputs(
        root=execution.output_file("."),
        pons_output=execution.output_file(subject + "+pons.mgz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SEGPONS_METADATA",
    "SegponsOutputs",
    "segpons",
]
