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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_SEGMENT_HYPOTHALAMIC_SUBUNITS_METADATA = Metadata(
    id="f03ac3b7165171b1e5dc19884858113ebce6c791.boutiques",
    name="mri_segment_hypothalamic_subunits",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriSegmentHypothalamicSubunitsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_segment_hypothalamic_subunits(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    segmentation_output_files: OutputPathType | None
    """Segmentation output(s) in T1 mode."""
    posteriors_output: OutputPathType | None
    """Posteriors output(s)."""
    resampled_output: OutputPathType | None
    """Resampled image(s) output."""
    volume_output_csv: OutputPathType | None
    """CSV file with volumes for all structures and subjects."""


def mri_segment_hypothalamic_subunits(
    subjects: list[str] | None = None,
    subjects_dir: str | None = None,
    write_posteriors: bool = False,
    image_input: str | None = None,
    output: str | None = None,
    posteriors: str | None = None,
    resample: str | None = None,
    volume_output: str | None = None,
    crop_size: list[float] | None = None,
    threads: float | None = None,
    cpu: bool = False,
    runner: Runner | None = None,
) -> MriSegmentHypothalamicSubunitsOutputs:
    """
    This module segments hypothalamic subunits and can be run in two modes: on
    FreeSurfer subjects or on any T1-weighted scan(s) of approximately 1mm
    resolution.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subjects: (required in FS mode) Name of one or several subjects in\
            $SUBJECTS_DIR on which to run the module, assuming recon-all has been\
            run on the specified subjects.
        subjects_dir: (FS mode, optional) Override current $SUBJECTS_DIR.
        write_posteriors: (FS mode, optional) Save posteriors; default is\
            False.
        image_input: (required in T1 mode) Image(s) to segment. Can be a path\
            to a single image or to a folder.
        output: (required in T1 mode) Segmentation output(s). Must be a folder\
            if --i designates a folder.
        posteriors: (T1 mode, optional) Posteriors output(s). Must be a folder\
            if --i designates a folder.
        resample: (T1 mode, optional) Resampled image(s). Must be a folder if\
            --i designates a folder.
        volume_output: (T1 mode, optional) Output CSV file with volumes for all\
            structures and subjects.
        crop_size: (both modes, optional) Size of the central patch to analyse\
            (must be divisible by 8). The whole image is analysed by default.
        threads: (both modes, optional) Number of cores to be used. Default\
            uses 1 core.
        cpu: (both modes, optional) Enforce running with CPU rather than GPU.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriSegmentHypothalamicSubunitsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_SEGMENT_HYPOTHALAMIC_SUBUNITS_METADATA)
    cargs = []
    cargs.append("mri_segment_hypothalamic_subunits")
    if subjects is not None:
        cargs.extend([
            "--s",
            *subjects
        ])
    if subjects_dir is not None:
        cargs.extend([
            "--sd",
            subjects_dir
        ])
    if write_posteriors:
        cargs.append("--write_posteriors")
    if image_input is not None:
        cargs.extend([
            "--i",
            image_input
        ])
    if output is not None:
        cargs.extend([
            "--o",
            output
        ])
    if posteriors is not None:
        cargs.extend([
            "--post",
            posteriors
        ])
    if resample is not None:
        cargs.extend([
            "--resample",
            resample
        ])
    if volume_output is not None:
        cargs.extend([
            "--vol",
            volume_output
        ])
    if crop_size is not None:
        cargs.extend([
            "--crop",
            *map(str, crop_size)
        ])
    if threads is not None:
        cargs.extend([
            "--threads",
            str(threads)
        ])
    if cpu:
        cargs.append("--cpu")
    ret = MriSegmentHypothalamicSubunitsOutputs(
        root=execution.output_file("."),
        segmentation_output_files=execution.output_file(output) if (output is not None) else None,
        posteriors_output=execution.output_file(posteriors) if (posteriors is not None) else None,
        resampled_output=execution.output_file(resample) if (resample is not None) else None,
        volume_output_csv=execution.output_file(volume_output) if (volume_output is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_SEGMENT_HYPOTHALAMIC_SUBUNITS_METADATA",
    "MriSegmentHypothalamicSubunitsOutputs",
    "mri_segment_hypothalamic_subunits",
]
