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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_VOLMASK_VTK_METADATA = Metadata(
    id="800007184636ff21baf1531ccc9b9b9b778933b9.boutiques",
    name="mris_volmask_vtk",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisVolmaskVtkOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_volmask_vtk(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_volume_mask: OutputPathType | None
    """Output volume mask file."""
    left_ribbon_output: OutputPathType | None
    """Left hemisphere ribbon output file."""
    right_ribbon_output: OutputPathType | None
    """Right hemisphere ribbon output file."""
    edited_aseg_output: OutputPathType
    """Edited aseg output using ribbons."""
    dwhite_output: OutputPathType
    """Signed distance output for the white matter."""
    dpial_output: OutputPathType
    """Signed distance output for the pial surface."""


def mris_volmask_vtk(
    io_param: str,
    cap_distance: float | None = None,
    label_background: float | None = None,
    label_left_white: float | None = None,
    label_left_ribbon: float | None = None,
    label_right_white: float | None = None,
    label_right_ribbon: float | None = None,
    surf_white: str | None = None,
    surf_pial: str | None = None,
    aseg_name: str | None = None,
    out_root: str | None = None,
    subjects_dir: str | None = None,
    save_distance: bool = False,
    lh_only: bool = False,
    rh_only: bool = False,
    parallel: bool = False,
    edit_aseg: bool = False,
    save_ribbon: bool = False,
    runner: Runner | None = None,
) -> MrisVolmaskVtkOutputs:
    """
    Computes a volume mask at the resolution of the brain.mgz file, containing
    labels for various brain structures using surface files.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        io_param: Input-Output parameter as positional argument.
        cap_distance: Maximum distance up to which the signed distance function\
            computation is accurate.
        label_background: Override the default background label value (0).
        label_left_white: Override the default left white matter label (20).
        label_left_ribbon: Override the default left ribbon label (10).
        label_right_white: Override the default right white matter label (120).
        label_right_ribbon: Override the default right ribbon label (110).
        surf_white: Surface root name for white matter surfaces (default:\
            white).
        surf_pial: Surface root name for pial surfaces (default: pial).
        aseg_name: Specify a different name for the aseg input file (default:\
            aseg).
        out_root: Output root name (default: ribbon) for generated output\
            files.
        subjects_dir: Specify the SUBJECTS_DIR, default is read from\
            environment.
        save_distance: Option to save the signed distance function.
        lh_only: Only process left hemisphere.
        rh_only: Only process right hemisphere.
        parallel: Run hemispheres in parallel and combine the result.
        edit_aseg: Edit the aseg using the ribbons and save it.
        save_ribbon: Save only the ribbon for the hemispheres.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisVolmaskVtkOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_VOLMASK_VTK_METADATA)
    cargs = []
    cargs.append("mris_volmask")
    if cap_distance is not None:
        cargs.extend([
            "--cap_distance",
            str(cap_distance)
        ])
    if label_background is not None:
        cargs.extend([
            "--label_background",
            str(label_background)
        ])
    if label_left_white is not None:
        cargs.extend([
            "--label_left_white",
            str(label_left_white)
        ])
    if label_left_ribbon is not None:
        cargs.extend([
            "--label_left_ribbon",
            str(label_left_ribbon)
        ])
    if label_right_white is not None:
        cargs.extend([
            "--label_right_white",
            str(label_right_white)
        ])
    if label_right_ribbon is not None:
        cargs.extend([
            "--label_right_ribbon",
            str(label_right_ribbon)
        ])
    if surf_white is not None:
        cargs.extend([
            "--surf_white",
            surf_white
        ])
    if surf_pial is not None:
        cargs.extend([
            "--surf_pial",
            surf_pial
        ])
    if aseg_name is not None:
        cargs.extend([
            "--aseg_name",
            aseg_name
        ])
    if out_root is not None:
        cargs.extend([
            "--out_root",
            out_root
        ])
    if subjects_dir is not None:
        cargs.extend([
            "--sd",
            subjects_dir
        ])
    if save_distance:
        cargs.append("--save_distance")
    if lh_only:
        cargs.append("--lh-only")
    if rh_only:
        cargs.append("--rh-only")
    if parallel:
        cargs.append("--parallel")
    if edit_aseg:
        cargs.append("--edit_aseg")
    if save_ribbon:
        cargs.append("--save_ribbon")
    cargs.append(io_param)
    ret = MrisVolmaskVtkOutputs(
        root=execution.output_file("."),
        output_volume_mask=execution.output_file("mri/" + out_root + ".mgz") if (out_root is not None) else None,
        left_ribbon_output=execution.output_file("mri/lh." + out_root + ".mgz") if (out_root is not None) else None,
        right_ribbon_output=execution.output_file("mri/rh." + out_root + ".mgz") if (out_root is not None) else None,
        edited_aseg_output=execution.output_file("mri/aseg.ribbon.mgz"),
        dwhite_output=execution.output_file("mri/?h.dwhite.mgz"),
        dpial_output=execution.output_file("mri/?h.dpial.mgz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_VOLMASK_VTK_METADATA",
    "MrisVolmaskVtkOutputs",
    "mris_volmask_vtk",
]
