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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_APARC2ASEG_METADATA = Metadata(
    id="70399c00183edd73f6d174d9a1c242615869d650.boutiques",
    name="mri_aparc2aseg",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriAparc2asegOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_aparc2aseg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_volume: OutputPathType
    """Output segmentation volume."""


def mri_aparc2aseg(
    subject: str | None = None,
    output_volfile: str | None = None,
    old_ribbon: bool = False,
    new_ribbon: bool = False,
    a2005s: bool = False,
    a2009s: bool = False,
    annot_name: str | None = None,
    annot_table: str | None = None,
    base_offset: float | None = None,
    label_wm: bool = False,
    wmparc_dmax: float | None = None,
    rip_unknown: bool = False,
    hypo_as_wm: bool = False,
    no_fix_parahip: bool = False,
    smooth_normals: float | None = None,
    crs_test: str | None = None,
    right_hemisphere: bool = False,
    threads: float | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> MriAparc2asegOutputs:
    """
    Maps the cortical labels from the automatic cortical parcellation to the
    automatic segmentation volume.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: Name of the subject as found in the SUBJECTS_DIR.
        output_volfile: Full path of file to save the output segmentation in.\
            Default is mri/aparc+aseg.mgz.
        old_ribbon: Use mri/hemi.ribbon.mgz as a mask for the cortex.
        new_ribbon: Mask cortical voxels with mri/ribbon.mgz. Same as --volmask.
        a2005s: Use ?h.aparc.a2005s.annot. Output will be\
            aparc.a2005s+aseg.mgz.
        a2009s: Use ?h.aparc.a2009s.annot. Output will be\
            aparc.a2009s+aseg.mgz.
        annot_name: Use annotname surface annotation. By default, uses\
            ?h.aparc.annot.
        annot_table: Annotation table file. Default is\
            $FREESURFER_HOME/Simple_surface_labels2009.txt.
        base_offset: Add offset to all segmentation ids.
        label_wm: Re-assign white matter voxel labels to the closest cortical\
            point if within distance.
        wmparc_dmax: Max distance (mm) from cortex to be labeled as gyral WM\
            (default 5mm).
        rip_unknown: Do not label WM based on 'unknown' cortical label.
        hypo_as_wm: Label hypointensities as WM.
        no_fix_parahip: Do not remove unconnected regions from WM parahip.
        smooth_normals: Change number of surface normal smoothing steps\
            (default is 10).
        crs_test: Test mapping of column, row, slice.
        right_hemisphere: Only process the right hemisphere.
        threads: Run in parallel with the specified number of threads.
        help_: Print out information on how to use this program.
        version: Print out version and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriAparc2asegOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_APARC2ASEG_METADATA)
    cargs = []
    cargs.append("mri_aparc2aseg")
    if subject is not None:
        cargs.extend([
            "--s",
            subject
        ])
    if output_volfile is not None:
        cargs.extend([
            "--o",
            output_volfile
        ])
    if old_ribbon:
        cargs.append("--old-ribbon")
    if new_ribbon:
        cargs.append("--new-ribbon")
    if a2005s:
        cargs.append("--a2005s")
    if a2009s:
        cargs.append("--a2009s")
    if annot_name is not None:
        cargs.extend([
            "--annot",
            annot_name
        ])
    if annot_table is not None:
        cargs.extend([
            "--annot-table",
            annot_table
        ])
    if base_offset is not None:
        cargs.extend([
            "--base-offset",
            str(base_offset)
        ])
    if label_wm:
        cargs.append("--labelwm")
    if wmparc_dmax is not None:
        cargs.extend([
            "--wmparc-dmax",
            str(wmparc_dmax)
        ])
    if rip_unknown:
        cargs.append("--rip-unknown")
    if hypo_as_wm:
        cargs.append("--hypo-as-wm")
    if no_fix_parahip:
        cargs.append("--no-fix-parahip")
    if smooth_normals is not None:
        cargs.extend([
            "--smooth_normals",
            str(smooth_normals)
        ])
    if crs_test is not None:
        cargs.extend([
            "--crs-test",
            crs_test
        ])
    if right_hemisphere:
        cargs.append("--rh")
    if threads is not None:
        cargs.extend([
            "--threads",
            str(threads)
        ])
    if help_:
        cargs.append("--help")
    if version:
        cargs.append("--version")
    ret = MriAparc2asegOutputs(
        root=execution.output_file("."),
        output_volume=execution.output_file("mri/aparc+aseg.mgz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_APARC2ASEG_METADATA",
    "MriAparc2asegOutputs",
    "mri_aparc2aseg",
]
