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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_NLFILTER_METADATA = Metadata(
    id="c44a60efcccca403f44c82f08afd31e3af464d00.boutiques",
    name="mri_nlfilter",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriNlfilterOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_nlfilter(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """The processed image output file."""


def mri_nlfilter(
    input_image: InputPathType,
    output_image: str,
    blur_sigma: float | None = None,
    gaussian_sigma: float | None = None,
    mean_flag: bool = False,
    window_size: float | None = None,
    cplov_flag: bool = False,
    minmax_flag: bool = False,
    no_offsets_flag: bool = False,
    no_crop_flag: bool = False,
    version_flag: bool = False,
    help_flag: bool = False,
    runner: Runner | None = None,
) -> MriNlfilterOutputs:
    """
    This program processes an image using a nonlocal filter and writes the results
    to an output file. It supports different filtering methods such as median,
    Gaussian, and mean.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_image: The input image file to be processed.
        output_image: The output image file where the processed image will be\
            saved.
        blur_sigma: Specify sigma of the blurring kernel. Default is 0.500.
        gaussian_sigma: Filter with Gaussian instead of median. Requires sigma\
            value.
        mean_flag: Filter with mean instead of median.
        window_size: Specify window size used for offset calculation. Default\
            is 3.
        cplov_flag: Filter with cplov.
        minmax_flag: Filter with minmax.
        no_offsets_flag: Don't use offsets, just apply standard filters.
        no_crop_flag: Don't crop to >0 region of image.
        version_flag: Display version number.
        help_flag: Display help message.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriNlfilterOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_NLFILTER_METADATA)
    cargs = []
    cargs.append("mri_nlfilter")
    cargs.append(execution.input_file(input_image))
    cargs.append(output_image)
    if blur_sigma is not None:
        cargs.extend([
            "-blur",
            str(blur_sigma)
        ])
    if gaussian_sigma is not None:
        cargs.extend([
            "-gaussian",
            str(gaussian_sigma)
        ])
    if mean_flag:
        cargs.append("-mean")
    if window_size is not None:
        cargs.extend([
            "-w",
            str(window_size)
        ])
    if cplov_flag:
        cargs.append("-cplov")
    if minmax_flag:
        cargs.append("-minmax")
    if no_offsets_flag:
        cargs.append("-n")
    if no_crop_flag:
        cargs.append("-nc")
    if version_flag:
        cargs.append("--version")
    if help_flag:
        cargs.append("--help")
    ret = MriNlfilterOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(output_image),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_NLFILTER_METADATA",
    "MriNlfilterOutputs",
    "mri_nlfilter",
]
