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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_SYNTHSTRIP_METADATA = Metadata(
    id="fb880e3e88b019dc0ec0078b71a89815251f3260.boutiques",
    name="mri_synthstrip",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriSynthstripOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_synthstrip(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    out_image_file: OutputPathType | None
    """File containing the stripped image"""
    mask_image_file: OutputPathType | None
    """File containing the binary brain mask"""
    sdt_image_file: OutputPathType | None
    """File containing the distance transform"""


def mri_synthstrip(
    input_image: InputPathType,
    out_file: str | None = None,
    mask_file: str | None = None,
    sdt_file: str | None = None,
    gpu_flag: bool = False,
    border_threshold: float | None = None,
    num_threads: float | None = None,
    no_csf_flag: bool = False,
    model_file: InputPathType | None = None,
    runner: Runner | None = None,
) -> MriSynthstripOutputs:
    """
    Robust, universal skull-stripping for brain images of any type.
    
    Author: Unknown
    
    URL: https://example.com/universal_skullstrip_docs
    
    Args:
        input_image: Input image to skullstrip.
        out_file: Filename to save the stripped image.
        mask_file: Filename to save the binary brain mask.
        sdt_file: Filename to save the distance transform.
        gpu_flag: Use the GPU.
        border_threshold: Mask border threshold in mm, defaults to 1.
        num_threads: PyTorch CPU threads; uses PyTorch default if unset.
        no_csf_flag: Exclude CSF from the brain border.
        model_file: Alternative model weights.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriSynthstripOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_SYNTHSTRIP_METADATA)
    cargs = []
    cargs.append("mri_synthstrip")
    cargs.extend([
        "-i",
        execution.input_file(input_image)
    ])
    if out_file is not None:
        cargs.extend([
            "-o",
            out_file
        ])
    if mask_file is not None:
        cargs.extend([
            "-m",
            mask_file
        ])
    if sdt_file is not None:
        cargs.extend([
            "-d",
            sdt_file
        ])
    if gpu_flag:
        cargs.append("-g")
    if border_threshold is not None:
        cargs.extend([
            "-b",
            str(border_threshold)
        ])
    if num_threads is not None:
        cargs.extend([
            "-t",
            str(num_threads)
        ])
    if no_csf_flag:
        cargs.append("--no-csf")
    if model_file is not None:
        cargs.extend([
            "--model",
            execution.input_file(model_file)
        ])
    ret = MriSynthstripOutputs(
        root=execution.output_file("."),
        out_image_file=execution.output_file(out_file) if (out_file is not None) else None,
        mask_image_file=execution.output_file(mask_file) if (mask_file is not None) else None,
        sdt_image_file=execution.output_file(sdt_file) if (sdt_file is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_SYNTHSTRIP_METADATA",
    "MriSynthstripOutputs",
    "mri_synthstrip",
]
