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

import typing
import pathlib
from styxdefs import *
import dataclasses

SEGMENT_HA_T1_SH_METADATA = Metadata(
    id="33c1985d7e603bd0c84961ad260a84289d2bd93f.boutiques",
    name="segmentHA_T1.sh",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class SegmentHaT1ShOutputs(typing.NamedTuple):
    """
    Output object returned when calling `segment_ha_t1_sh(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    hippocampus_aseg: OutputPathType
    """Segmented hippocampal subfields."""
    amygdala_aseg: OutputPathType
    """Segmented amygdalar subfields."""


def segment_ha_t1_sh(
    input_image: InputPathType,
    output_directory: str,
    brain_mask: InputPathType | None = None,
    verbose: bool = False,
    debug: bool = False,
    runner: Runner | None = None,
) -> SegmentHaT1ShOutputs:
    """
    Tool for hippocampal/amygdalar subfield segmentation.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_image: The input T1-weighted MRI image for hippocampal/amygdalar\
            segmentation.
        output_directory: The directory where the output will be saved.
        brain_mask: Use a specific brain mask for segmentation.
        verbose: Increase the verbosity of the output.
        debug: Enable debugging mode.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SegmentHaT1ShOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SEGMENT_HA_T1_SH_METADATA)
    cargs = []
    cargs.append("segmentHA_T1.sh")
    cargs.append(execution.input_file(input_image))
    cargs.append(output_directory)
    if brain_mask is not None:
        cargs.extend([
            "--brainmask",
            execution.input_file(brain_mask)
        ])
    if verbose:
        cargs.append("--verbose")
    if debug:
        cargs.append("--debug")
    ret = SegmentHaT1ShOutputs(
        root=execution.output_file("."),
        hippocampus_aseg=execution.output_file(output_directory + "/hippocampus_aseg.mgz"),
        amygdala_aseg=execution.output_file(output_directory + "/amygdala_aseg.mgz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SEGMENT_HA_T1_SH_METADATA",
    "SegmentHaT1ShOutputs",
    "segment_ha_t1_sh",
]
