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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_REMOVE_INTERSECTION_METADATA = Metadata(
    id="96ab5df1b694c34b019d2062381f43e1e69cf9b2.boutiques",
    name="mris_remove_intersection",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisRemoveIntersectionOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_remove_intersection(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    out_corrected_surface: OutputPathType
    """Corrected surface output file."""
    out_map_file: OutputPathType | None
    """Binary map of intersections."""


def mris_remove_intersection(
    surface_in_file: InputPathType,
    corrected_surface_out_file: InputPathType,
    fill_holes: bool = False,
    map_option: InputPathType | None = None,
    projdistmm: float | None = None,
    runner: Runner | None = None,
) -> MrisRemoveIntersectionOutputs:
    """
    Tool to remove intersections in surface files.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        surface_in_file: Input surface file.
        corrected_surface_out_file: Corrected output surface file.
        fill_holes: Fill any holes in the intersection mark map and include\
            them in the fix.
        map_option: Create a binary map of intersections.
        projdistmm: Projection distance in mm when using -map option.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisRemoveIntersectionOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_REMOVE_INTERSECTION_METADATA)
    cargs = []
    cargs.append("mris_remove_intersection")
    cargs.append(execution.input_file(surface_in_file))
    cargs.append(execution.input_file(corrected_surface_out_file))
    if fill_holes:
        cargs.append("-fill-holes")
    if map_option is not None:
        cargs.extend([
            "-map",
            execution.input_file(map_option)
        ])
    if projdistmm is not None:
        cargs.append(str(projdistmm))
    ret = MrisRemoveIntersectionOutputs(
        root=execution.output_file("."),
        out_corrected_surface=execution.output_file(pathlib.Path(corrected_surface_out_file).name),
        out_map_file=execution.output_file(pathlib.Path(map_option).name) if (map_option is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_REMOVE_INTERSECTION_METADATA",
    "MrisRemoveIntersectionOutputs",
    "mris_remove_intersection",
]
