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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSLMEANTS_METADATA = Metadata(
    id="fcc95512e4d985215019fd1ae002fbea7f289d21.boutiques",
    name="fslmeants",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class FslmeantsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fslmeants(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_text_matrix: OutputPathType | None
    """Output text matrix from fslmeants"""


def fslmeants(
    input_image: InputPathType,
    output: str | None = None,
    mask: InputPathType | None = None,
    coordinates: list[float] | None = None,
    usemm_flag: bool = False,
    showall_flag: bool = False,
    eigenv_flag: bool = False,
    eigenvariates_order: float | None = None,
    no_bin_flag: bool = False,
    label_image: InputPathType | None = None,
    transpose_flag: bool = False,
    weighted_mean_flag: bool = False,
    verbose_flag: bool = False,
    runner: Runner | None = None,
) -> FslmeantsOutputs:
    """
    Prints average timeseries (intensities) to the screen (or saves to a file).
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        input_image: Input 4D image.
        output: Output text matrix.
        mask: Input 3D mask.
        coordinates: Requested spatial coordinate (instead of mask). Must have\
            exactly three numerical entries in the list (3-vector).
        usemm_flag: Use mm instead of voxel coordinates (for -c option).
        showall_flag: Show all voxel time series (within mask) instead of\
            averaging.
        eigenv_flag: Calculate Eigenvariate(s) instead of mean (output will\
            have 0 mean).
        eigenvariates_order: Select number of Eigenvariates (default 1).
        no_bin_flag: Do not binarise the mask for calculation of Eigenvariates.
        label_image: Input 3D label image (generate separate mean for each\
            integer label value - cannot be used with showall).
        transpose_flag: Output results in transpose format (one row per\
            voxel/mean).
        weighted_mean_flag: Output weighted mean, using mask values as weights,\
            and exit.
        verbose_flag: Switch on diagnostic messages.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FslmeantsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSLMEANTS_METADATA)
    cargs = []
    cargs.append("fslmeants")
    cargs.extend([
        "-i",
        execution.input_file(input_image)
    ])
    if output is not None:
        cargs.extend([
            "-o",
            output
        ])
    if mask is not None:
        cargs.extend([
            "-m",
            execution.input_file(mask)
        ])
    if coordinates is not None:
        cargs.extend([
            "-c",
            *map(str, coordinates)
        ])
    if usemm_flag:
        cargs.append("--usemm")
    if showall_flag:
        cargs.append("--showall")
    if eigenv_flag:
        cargs.append("--eig")
    if eigenvariates_order is not None:
        cargs.extend([
            "--order",
            str(eigenvariates_order)
        ])
    if no_bin_flag:
        cargs.append("--no_bin")
    if label_image is not None:
        cargs.extend([
            "--label",
            execution.input_file(label_image)
        ])
    if transpose_flag:
        cargs.append("--transpose")
    if weighted_mean_flag:
        cargs.append("-w")
    if verbose_flag:
        cargs.append("-v")
    ret = FslmeantsOutputs(
        root=execution.output_file("."),
        output_text_matrix=execution.output_file(output) if (output is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSLMEANTS_METADATA",
    "FslmeantsOutputs",
    "fslmeants",
]
