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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_ENTOWM_SEG_METADATA = Metadata(
    id="77125ad0338a92f9cf723bd7b819f168daf89cd0.boutiques",
    name="mri_entowm_seg",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriEntowmSegOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_entowm_seg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType | None
    """Segmentation output file"""
    label_posteriors: OutputPathType
    """Label posterior probabilities"""
    volume_stats: OutputPathType
    """Volume statistics"""
    qa_stats: OutputPathType
    """Quality assurance statistics"""


def mri_entowm_seg(
    input_image: InputPathType | None = None,
    output_segmentation: InputPathType | None = None,
    recon_subjects: list[str] | None = None,
    subjects_directory: str | None = None,
    runner: Runner | None = None,
) -> MriEntowmSegOutputs:
    """
    Segment white matter near gyrus ambiens entorhinal cortex using a deep learning
    model.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_image: T1-weighted image(s) to segment. Can be a path to a single\
            image or a directory of images.
        output_segmentation: Segmentation output file or directory (required if\
            --i is provided).
        recon_subjects: Process a series of FreeSurfer recon-all subjects,\
            enables subject-mode.
        subjects_directory: Set the subjects directory, overrides the\
            SUBJECTS_DIR env variable.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriEntowmSegOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_ENTOWM_SEG_METADATA)
    cargs = []
    cargs.append("mri_entowm_seg")
    if input_image is not None:
        cargs.extend([
            "-i",
            execution.input_file(input_image)
        ])
    if output_segmentation is not None:
        cargs.extend([
            "-o",
            execution.input_file(output_segmentation)
        ])
    if recon_subjects is not None:
        cargs.extend([
            "-s",
            *recon_subjects
        ])
    if subjects_directory is not None:
        cargs.extend([
            "--sd",
            subjects_directory
        ])
    cargs.append("[OTHER_OPTIONS]")
    ret = MriEntowmSegOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(pathlib.Path(output_segmentation).name) if (output_segmentation is not None) else None,
        label_posteriors=execution.output_file("[OUTPUT_BASE]_posterior.mgz"),
        volume_stats=execution.output_file("[OUTPUT_BASE]_volumes.txt"),
        qa_stats=execution.output_file("[OUTPUT_BASE]_qa_stats.txt"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_ENTOWM_SEG_METADATA",
    "MriEntowmSegOutputs",
    "mri_entowm_seg",
]
