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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_FWHM_METADATA = Metadata(
    id="3df5d08538916b5e720d481edb2f9270d2c60c51.boutiques",
    name="mris_fwhm",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def mris_fwhm(
    input_file: InputPathType,
    subject: str,
    hemi: str,
    output_file: str,
    surf: str | None = None,
    label_file: InputPathType | None = None,
    cortex_flag: bool = False,
    mask_file: InputPathType | None = None,
    x_matrix: InputPathType | None = None,
    detrend_order: float | None = None,
    smooth_only_flag: bool = False,
    no_detrend_flag: bool = False,
    sqr_flag: bool = False,
    sum_file: str | None = None,
    dat_file: str | None = None,
    ar1dat_file: str | None = None,
    ar1vol: str | None = None,
    fwhmmap: str | None = None,
    prune_flag: bool = False,
    no_prune_flag: bool = False,
    out_mask: str | None = None,
    varnorm_flag: bool = False,
    fwhm: float | None = None,
    niters_only: str | None = None,
    sd: str | None = None,
    synth_flag: bool = False,
    synth_frames: float | None = None,
    threads: float | None = None,
    debug_flag: bool = False,
    checkopts_flag: bool = False,
    version_flag: bool = False,
    runner: Runner | None = None,
) -> MrisFwhmOutputs:
    """
    Smooths surface data and/or estimates FWHM.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_file: Input data file.
        subject: Subject whose surface the input is defined on.
        hemi: Hemifield that the input is defined on. Legal values are lh and\
            rh.
        output_file: Output file to save the processed data.
        surf: Surface name to compute AR1 on. Default is white.
        label_file: Label file to be used as a mask.
        cortex_flag: Use hemi.cortex.label as a mask.
        mask_file: Mask file. Compute AR1 only over voxels in the given mask.
        x_matrix: Detrend data with the matrix in x.mat.
        detrend_order: Order of polynomial detrending.
        smooth_only_flag: Only smooth the data, implies --no-detrend.
        no_detrend_flag: Turn off polynomial detrending.
        sqr_flag: Compute square of input before smoothing.
        sum_file: Prints ascii summary to sumfile.
        dat_file: File for FWHM data.
        ar1dat_file: File containing ar1mean and ar1std.
        ar1vol: Save spatial AR1 as an overlay.
        fwhmmap: Save vertex-wise spatial FWHM as an overlay.
        prune_flag: Remove any voxel that is zero in any subject (after any\
            inversion).
        no_prune_flag: Do not prune (default).
        out_mask: File to save the final mask.
        varnorm_flag: Normalize the variance across space within any mask.
        fwhm: Smooth input by the specified FWHM in mm.
        niters_only: File that reports the number of iterations needed to\
            achieve the specified FWHM.
        sd: Subjects directory.
        synth_flag: Synthesize input with white gaussian noise.
        synth_frames: Number of frames for synthesized input.
        threads: Number of threads to use.
        debug_flag: Turn on debugging.
        checkopts_flag: Don't run anything, just check options and exit.
        version_flag: Print out version and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisFwhmOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_FWHM_METADATA)
    cargs = []
    cargs.append("mris_fwhm")
    cargs.extend([
        "--i",
        execution.input_file(input_file)
    ])
    cargs.extend([
        "--subject",
        subject
    ])
    cargs.extend([
        "--hemi",
        hemi
    ])
    if surf is not None:
        cargs.extend([
            "--surf",
            surf
        ])
    if label_file is not None:
        cargs.extend([
            "--label",
            execution.input_file(label_file)
        ])
    if cortex_flag:
        cargs.append("--cortex")
    if mask_file is not None:
        cargs.extend([
            "--mask",
            execution.input_file(mask_file)
        ])
    if x_matrix is not None:
        cargs.extend([
            "--X",
            execution.input_file(x_matrix)
        ])
    if detrend_order is not None:
        cargs.extend([
            "--detrend",
            str(detrend_order)
        ])
    if smooth_only_flag:
        cargs.append("--smooth-only")
    if no_detrend_flag:
        cargs.append("--no-detrend")
    if sqr_flag:
        cargs.append("--sqr")
    if sum_file is not None:
        cargs.extend([
            "--sum",
            sum_file
        ])
    if dat_file is not None:
        cargs.extend([
            "--dat",
            dat_file
        ])
    if ar1dat_file is not None:
        cargs.extend([
            "--ar1dat",
            ar1dat_file
        ])
    if ar1vol is not None:
        cargs.extend([
            "--ar1",
            ar1vol
        ])
    if fwhmmap is not None:
        cargs.extend([
            "--fwhm-map",
            fwhmmap
        ])
    if prune_flag:
        cargs.append("--prune")
    if no_prune_flag:
        cargs.append("--no-prune")
    if out_mask is not None:
        cargs.extend([
            "--out-mask",
            out_mask
        ])
    if varnorm_flag:
        cargs.append("--varnorm")
    if fwhm is not None:
        cargs.extend([
            "--fwhm",
            str(fwhm)
        ])
    if niters_only is not None:
        cargs.extend([
            "--niters-only",
            niters_only
        ])
    cargs.extend([
        "--o",
        output_file
    ])
    if sd is not None:
        cargs.extend([
            "--sd",
            sd
        ])
    if synth_flag:
        cargs.append("--synth")
    if synth_frames is not None:
        cargs.extend([
            "--synth-frames",
            str(synth_frames)
        ])
    if threads is not None:
        cargs.extend([
            "--threads",
            str(threads)
        ])
    if debug_flag:
        cargs.append("--debug")
    if checkopts_flag:
        cargs.append("--checkopts")
    if version_flag:
        cargs.append("--version")
    ret = MrisFwhmOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_FWHM_METADATA",
    "MrisFwhmOutputs",
    "mris_fwhm",
]
