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

import typing
import pathlib
from styxdefs import *
import dataclasses

SPHARM_RECO_METADATA = Metadata(
    id="33f63f74ec6a7870069eec599fbb3c35bec65ba8.boutiques",
    name="SpharmReco",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


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


def spharm_reco(
    input_surface: str,
    decomposition_order: float,
    bases_prefix: str,
    coefficients: list[InputPathType],
    output_prefix: str | None = None,
    output_surface: list[str] | None = None,
    debug: float | None = None,
    smoothing: float | None = None,
    runner: Runner | None = None,
) -> SpharmRecoOutputs:
    """
    Spherical Harmonics Reconstruction from a set of harmonics and their
    corresponding coefficients.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_surface: Surface that provides the topology of the mesh (nodes'\
            connections). TYPE specifies the input surface type.
        decomposition_order: Decomposition order.
        bases_prefix: Prefix of files containing the bases functions (spherical\
            harmonics). These files are generated with SpharmDeco.
        coefficients: Coefficients files used to recompose data columns.\
            Multiple coefficient files can be specified by repeating the option.
        output_prefix: Write out the reconstructed data into dataset PREFIX.\
            The output contains N columns; one for each COEF file.
        output_surface: Write out a new surface with reconstructed coordinates.\
            Requires N to be a multiple of 3.
        debug: Debug levels (1-3).
        smoothing: Smoothing parameter (0 .. 0.001) weighing the contribution\
            of higher order harmonics.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SpharmRecoOutputs`).
    """
    if not (1 <= len(coefficients)): 
        raise ValueError(f"Length of 'coefficients' must be greater than 1 but was {len(coefficients)}")
    if smoothing is not None and not (0 <= smoothing <= 0.001): 
        raise ValueError(f"'smoothing' must be between 0 <= x <= 0.001 but was {smoothing}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(SPHARM_RECO_METADATA)
    cargs = []
    cargs.append("SpharmReco")
    cargs.extend([
        "-i_TYPE",
        input_surface
    ])
    cargs.extend([
        "-l",
        str(decomposition_order)
    ])
    cargs.extend([
        "-bases_prefix",
        bases_prefix
    ])
    cargs.extend([
        "-coef",
        *[execution.input_file(f) for f in coefficients]
    ])
    if output_prefix is not None:
        cargs.extend([
            "-prefix",
            output_prefix
        ])
    if output_surface is not None:
        cargs.extend([
            "-o_TYPE",
            *output_surface
        ])
    if debug is not None:
        cargs.extend([
            "-debug",
            str(debug)
        ])
    if smoothing is not None:
        cargs.extend([
            "-sigma",
            str(smoothing)
        ])
    ret = SpharmRecoOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SPHARM_RECO_METADATA",
    "SpharmRecoOutputs",
    "spharm_reco",
]
