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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSPALM_METADATA = Metadata(
    id="99a4d5403d2183af602919ad014d4db78cf3675b.boutiques",
    name="fspalm",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def fspalm(
    glmdir: str,
    cft: float,
    cwp: float,
    onetail: bool = False,
    twotail: bool = False,
    name: str | None = None,
    iters: float | None = None,
    monly: bool = False,
    pponly: bool = False,
    octave: bool = False,
    centroid: bool = False,
    v_2spaces: bool = False,
    v_3spaces: bool = False,
    pargs: str | None = None,
    runner: Runner | None = None,
) -> FspalmOutputs:
    """
    Prepares and analyzes the output of mri_glmfit for Permutation Analysis of
    Linear Models (PALM) to correct for multiple comparisons.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        glmdir: The mri_glmfit directory to prepare.
        cft: Voxel-wise cluster forming threshold (CFT), -log10(p).
        cwp: Clusterwise p-value threshold.
        onetail: Perform a one-tailed test.
        twotail: Perform a two-tailed test. NOTE: changes CFT.
        name: Name of palm subdirectory (default="palm").
        iters: Number of iterations.
        monly: Only create matlab file, do not run.
        pponly: Only perform post-processing.
        octave: Run with octave, not matlab.
        centroid: Add --centroid flag to mri_surfcluster post-processing.
        v_2spaces: Bonferroni-correct for 2 spaces.
        v_3spaces: Bonferroni-correct for 3 spaces.
        pargs: Supply additional args to be passed to the palm function.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FspalmOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSPALM_METADATA)
    cargs = []
    cargs.append("fspalm")
    cargs.extend([
        "--glmdir",
        glmdir
    ])
    cargs.extend([
        "--cft",
        str(cft)
    ])
    cargs.extend([
        "--cwp",
        str(cwp)
    ])
    if onetail:
        cargs.append("--onetail")
    if twotail:
        cargs.append("--twotail")
    if name is not None:
        cargs.extend([
            "--name",
            name
        ])
    if iters is not None:
        cargs.extend([
            "--iters",
            str(iters)
        ])
    if monly:
        cargs.append("--monly")
    if pponly:
        cargs.append("--pponly")
    if octave:
        cargs.append("--octave")
    if centroid:
        cargs.append("--centroid")
    if v_2spaces:
        cargs.append("--2spaces")
    if v_3spaces:
        cargs.append("--3spaces")
    if pargs is not None:
        cargs.extend([
            "--pargs",
            pargs
        ])
    ret = FspalmOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSPALM_METADATA",
    "FspalmOutputs",
    "fspalm",
]
