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

import typing
import pathlib
from styxdefs import *
import dataclasses

VOLUME_PARCEL_SMOOTHING_METADATA = Metadata(
    id="f27c64a6c0852328393dc55d6325df0de41f496c.boutiques",
    name="volume-parcel-smoothing",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


class VolumeParcelSmoothingOutputs(typing.NamedTuple):
    """
    Output object returned when calling `volume_parcel_smoothing(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    volume_out: OutputPathType
    """the output volume"""


def volume_parcel_smoothing(
    data_volume: InputPathType,
    label_volume: InputPathType,
    kernel: float,
    volume_out: str,
    opt_fwhm: bool = False,
    opt_fix_zeros: bool = False,
    opt_subvolume_subvol: str | None = None,
    runner: Runner | None = None,
) -> VolumeParcelSmoothingOutputs:
    """
    Smooth parcels in a volume separately.
    
    The volume is smoothed within each label in the label volume using data only
    from within the label. Equivalent to running volume smoothing with ROIs
    matching each label separately, then adding the resulting volumes, but
    faster.
    
    Author: Washington University School of Medicin
    
    Args:
        data_volume: the volume to smooth.
        label_volume: a label volume containing the parcels to smooth.
        kernel: the size of the gaussian smoothing kernel in mm, as sigma by\
            default.
        volume_out: the output volume.
        opt_fwhm: smoothing kernel size is FWHM, not sigma.
        opt_fix_zeros: treat zero values as not being data.
        opt_subvolume_subvol: select a single subvolume to smooth: the\
            subvolume number or name.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VolumeParcelSmoothingOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(VOLUME_PARCEL_SMOOTHING_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-volume-parcel-smoothing")
    cargs.append(execution.input_file(data_volume))
    cargs.append(execution.input_file(label_volume))
    cargs.append(str(kernel))
    cargs.append(volume_out)
    if opt_fwhm:
        cargs.append("-fwhm")
    if opt_fix_zeros:
        cargs.append("-fix-zeros")
    if opt_subvolume_subvol is not None:
        cargs.extend([
            "-subvolume",
            opt_subvolume_subvol
        ])
    ret = VolumeParcelSmoothingOutputs(
        root=execution.output_file("."),
        volume_out=execution.output_file(volume_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "VOLUME_PARCEL_SMOOTHING_METADATA",
    "VolumeParcelSmoothingOutputs",
    "volume_parcel_smoothing",
]
