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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_FILL_METADATA = Metadata(
    id="45567bfdadd532485f2ed2b4fee5ffc3e7f9d609.boutiques",
    name="mri_fill",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriFillOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_fill(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    filled_volume: OutputPathType
    """The filled volume for the cortical reconstruction, used for subsequent
    surface tessellation"""


def mri_fill(
    input_mr_dir: str,
    output_mr_dir: str,
    threshold: float | None = None,
    xform_name: str | None = None,
    segmentation_file: InputPathType | None = None,
    atlas_file: InputPathType | None = None,
    fill_ven: bool = False,
    seed_cc_tal: list[float] | None = None,
    seed_pons_tal: list[float] | None = None,
    seed_lh_tal: list[float] | None = None,
    seed_rh_tal: list[float] | None = None,
    seed_cc_vox: list[float] | None = None,
    seed_pons_vox: list[float] | None = None,
    auto_man_files: list[str] | None = None,
    no_auto_man: bool = False,
    pointset_args: list[str] | None = None,
    ctab_file: InputPathType | None = None,
    runner: Runner | None = None,
) -> MriFillOutputs:
    """
    Tool for creating hemispheric cutting planes and filling white matter for
    surface tessellation.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_mr_dir: Input MR directory.
        output_mr_dir: Output MR directory.
        threshold: Specify fill_holes threshold (default=1).
        xform_name: Use xform dst offset to get an accurate Talairach volume.
        segmentation_file: ASEG volume used to perform fill.
        atlas_file: Specify atlas to use for auto-filling.
        fill_ven: Fill ventricles.
        seed_cc_tal: Talairach coords of the seed for the corpus callosum\
            (three numerical values required).
        seed_pons_tal: Talairach coords of the seed for the pons (three\
            numerical values required).
        seed_lh_tal: Talairach coords of the white matter seed for the left\
            hemisphere (three numerical values required).
        seed_rh_tal: Talairach coords of the white matter seed for the right\
            hemisphere (three numerical values required).
        seed_cc_vox: Voxel coords of the seed for the corpus callosum (three\
            numerical values required).
        seed_pons_vox: Voxel coords of the seed for the pons (three numerical\
            values required).
        auto_man_files: Get edits based on the difference between auto and man\
            and apply to the output.
        no_auto_man: Turns off the -auto-man option.
        pointset_args: Stand-alone option: takes one or more pointsets and\
            fills in all the voxels that intersect lines connecting any two points\
            within a given point set.
        ctab_file: Embed color table in the output.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriFillOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_FILL_METADATA)
    cargs = []
    cargs.append("mri_fill")
    cargs.append(input_mr_dir)
    cargs.append(output_mr_dir)
    if threshold is not None:
        cargs.extend([
            "-T",
            str(threshold)
        ])
    if xform_name is not None:
        cargs.extend([
            "-xform",
            xform_name
        ])
    if segmentation_file is not None:
        cargs.extend([
            "-segmentation",
            execution.input_file(segmentation_file)
        ])
    if atlas_file is not None:
        cargs.extend([
            "-atlas",
            execution.input_file(atlas_file)
        ])
    if fill_ven:
        cargs.append("-fillven")
    if seed_cc_tal is not None:
        cargs.extend([
            "-C",
            *map(str, seed_cc_tal)
        ])
    if seed_pons_tal is not None:
        cargs.extend([
            "-P",
            *map(str, seed_pons_tal)
        ])
    if seed_lh_tal is not None:
        cargs.extend([
            "-lh",
            *map(str, seed_lh_tal)
        ])
    if seed_rh_tal is not None:
        cargs.extend([
            "-rh",
            *map(str, seed_rh_tal)
        ])
    if seed_cc_vox is not None:
        cargs.extend([
            "-CV",
            *map(str, seed_cc_vox)
        ])
    if seed_pons_vox is not None:
        cargs.extend([
            "-PV",
            *map(str, seed_pons_vox)
        ])
    if auto_man_files is not None:
        cargs.extend([
            "-auto-man",
            *auto_man_files
        ])
    if no_auto_man:
        cargs.append("-no-auto-man")
    if pointset_args is not None:
        cargs.extend([
            "-pointset",
            *pointset_args
        ])
    if ctab_file is not None:
        cargs.extend([
            "-ctab",
            execution.input_file(ctab_file)
        ])
    ret = MriFillOutputs(
        root=execution.output_file("."),
        filled_volume=execution.output_file(output_mr_dir + "/filled"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_FILL_METADATA",
    "MriFillOutputs",
    "mri_fill",
]
