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

import typing
import pathlib
from styxdefs import *
import dataclasses

VSM_SMOOTH_METADATA = Metadata(
    id="c9910f98cd5b5b7c5c6d2ac12c7a50e16ba9d6d7.boutiques",
    name="vsm-smooth",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class VsmSmoothOutputs(typing.NamedTuple):
    """
    Output object returned when calling `vsm_smooth(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_vsm: OutputPathType
    """The resulting smoothed voxel shift map."""


def vsm_smooth(
    input_file: InputPathType,
    output_file: str,
    fwhm_value: float,
    temp_dir: str,
    runner: Runner | None = None,
) -> VsmSmoothOutputs:
    """
    Implements a masked smoothing in which the input (vsm) is unchanged in voxels
    that have a non-zero value. In voxels with a zero value, the value is replaced
    with vsm smoothed by the given amount. This will likely only change the voxels
    that are near the edge of the non-zero voxels. This is a simple way to
    extrapolate the non-zero voxels beyond their range. This works well for a B0
    distortion correction voxel shift map (vsm), but it can be applied to other
    maps.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_file: Input voxel shift map (vsm).
        output_file: Output smoothed voxel shift map.
        fwhm_value: Full width at half maximum for smoothing.
        temp_dir: Directory for temporary files.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VsmSmoothOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(VSM_SMOOTH_METADATA)
    cargs = []
    cargs.append("vsm-smooth")
    cargs.extend([
        "--i",
        execution.input_file(input_file)
    ])
    cargs.extend([
        "--o",
        output_file
    ])
    cargs.extend([
        "--fwhm",
        str(fwhm_value)
    ])
    cargs.extend([
        "--tmpdir",
        temp_dir
    ])
    ret = VsmSmoothOutputs(
        root=execution.output_file("."),
        output_vsm=execution.output_file(output_file),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "VSM_SMOOTH_METADATA",
    "VsmSmoothOutputs",
    "vsm_smooth",
]
