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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_DEFACER_METADATA = Metadata(
    id="b7a1aaf9b5947804211cdf0360ab244cd298666a.boutiques",
    name="mri_defacer",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriDefacerOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_defacer(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def mri_defacer(
    input_volume: InputPathType,
    headmask: InputPathType,
    tempsurf: InputPathType,
    defaced_volume: str,
    templabel: list[InputPathType] | None = None,
    watermark: float | None = None,
    facemask: str | None = None,
    exclude_mask: InputPathType | None = None,
    runner: Runner | None = None,
) -> MriDefacerOutputs:
    """
    Tool for defacing MRI images to remove facial features.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_volume: Input volume.
        headmask: Head mask volume.
        tempsurf: Template surface file.
        defaced_volume: Output defaced volume.
        templabel: Template label, specify one or multiple labels.
        watermark: Watermark density.
        facemask: Face mask volume.
        exclude_mask: Mask to exclude from defacing.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriDefacerOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_DEFACER_METADATA)
    cargs = []
    cargs.append("mri_defacer")
    cargs.append("--i")
    cargs.append(execution.input_file(input_volume))
    cargs.append("--hm")
    cargs.append(execution.input_file(headmask))
    cargs.append("--ts")
    cargs.append(execution.input_file(tempsurf))
    cargs.append("--l")
    if templabel is not None:
        cargs.extend([
            "--l",
            *[execution.input_file(f) for f in templabel]
        ])
    cargs.append("--w")
    if watermark is not None:
        cargs.extend([
            "--w",
            str(watermark)
        ])
    cargs.append("--o")
    cargs.append(defaced_volume)
    cargs.append("--m")
    if facemask is not None:
        cargs.extend([
            "--m",
            facemask
        ])
    cargs.append("--fill-const")
    cargs.append("[CONST_IN]")
    cargs.append("[CONST_OUT]")
    cargs.append("--xmask")
    if exclude_mask is not None:
        cargs.extend([
            "--xmask",
            execution.input_file(exclude_mask)
        ])
    cargs.append("[OPTIONS]")
    ret = MriDefacerOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_DEFACER_METADATA",
    "MriDefacerOutputs",
    "mri_defacer",
]
