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

import typing
import pathlib
from styxdefs import *
import dataclasses

STEM2FNAME_METADATA = Metadata(
    id="b941ff1daaefec18565e73dea38778f44521acf7.boutiques",
    name="stem2fname",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class Stem2fnameOutputs(typing.NamedTuple):
    """
    Output object returned when calling `stem2fname(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """Full filename with the detected format. Format could be one of mgh, mgz,
    nii, nii.gz, bhdr, img, or w."""


def stem2fname(
    stem: str,
    runner: Runner | None = None,
) -> Stem2fnameOutputs:
    """
    Determines the full filename with extension for a given file stem by checking
    various formats.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        stem: The stem of the file (without extension).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Stem2fnameOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(STEM2FNAME_METADATA)
    cargs = []
    cargs.append("stem2fname")
    cargs.append(stem)
    ret = Stem2fnameOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(stem + ".[FORMAT]"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "STEM2FNAME_METADATA",
    "Stem2fnameOutputs",
    "stem2fname",
]
