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

import typing
import pathlib
from styxdefs import *
import dataclasses

SAMSEG2RECON_METADATA = Metadata(
    id="d187c3e2881ef4e68bbc4c2919f41e8e9ad94cca.boutiques",
    name="samseg2recon",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class Samseg2reconOutputs(typing.NamedTuple):
    """
    Output object returned when calling `samseg2recon(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    filled_mgz: OutputPathType
    """Filled MRI volume for the subject, if --fill is used."""
    norm_mgz: OutputPathType
    """Normalized MRI volume created from brain.mgz if --normalization2 is
    used."""
    orig_mgz: OutputPathType
    """Original MRI conformed volume."""


def samseg2recon(
    subject: str,
    samseg_dir: str | None = None,
    no_cc: bool = False,
    fill: bool = False,
    normalization2: bool = False,
    uchar: bool = False,
    no_keep_exc: bool = False,
    long_tp: float | None = None,
    base: bool = False,
    mask_file: InputPathType | None = None,
    from_recon_all: bool = False,
    force_update: bool = False,
    runner: Runner | None = None,
) -> Samseg2reconOutputs:
    """
    Creates and populates a subjects directory for use with recon-all from SAMSEG
    outputs.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: Subject identifier.
        samseg_dir: Output directory from samseg or samseg-long. Defaults to\
            subject/mri/samseg if not supplied.
        no_cc: Do not do corpus callosum segmentation.
        fill: Use samseg to create the filled.mgz used for tessellation.
        normalization2: Seg brain.mgz to norm.mgz.
        uchar: Convert to uchar.
        no_keep_exc: Do not keep extracerebral segmentations.
        long_tp: Process specific time point (TP) number from samsegdir.
        base: Process base, will find folder called base in samsegdir.
        mask_file: Use provided mask as brainmask instead of computing from seg.
        from_recon_all: Indicates execution from recon-all, preventing\
            overwrite of rawavg.mgz and orig.mgz.
        force_update: Force update of the subject directory.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Samseg2reconOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SAMSEG2RECON_METADATA)
    cargs = []
    cargs.append("samseg2recon")
    cargs.extend([
        "--s",
        subject
    ])
    if samseg_dir is not None:
        cargs.extend([
            "--samseg",
            samseg_dir
        ])
    if no_cc:
        cargs.append("--no-cc")
    if fill:
        cargs.append("--fill")
    if normalization2:
        cargs.append("--normalization2")
    if uchar:
        cargs.append("--uchar")
    if no_keep_exc:
        cargs.append("--no-keep-exc")
    if long_tp is not None:
        cargs.extend([
            "--long",
            str(long_tp)
        ])
    if base:
        cargs.append("--base")
    if mask_file is not None:
        cargs.extend([
            "--m",
            execution.input_file(mask_file)
        ])
    if from_recon_all:
        cargs.append("--from-recon-all")
    if force_update:
        cargs.append("--force-update")
    ret = Samseg2reconOutputs(
        root=execution.output_file("."),
        filled_mgz=execution.output_file(subject + "/mri/filled.mgz"),
        norm_mgz=execution.output_file(subject + "/mri/norm.mgz"),
        orig_mgz=execution.output_file(subject + "/mri/orig/001.mgz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SAMSEG2RECON_METADATA",
    "Samseg2reconOutputs",
    "samseg2recon",
]
