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

import typing
import pathlib
from styxdefs import *
import dataclasses

MM_METADATA = Metadata(
    id="a5f0fd0df34d3464fbfc708013a6765ded373c4d.boutiques",
    name="mm",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


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


def mm(
    spatial_data_file: InputPathType,
    mask_file: InputPathType,
    verbose_flag: bool = False,
    debug_level: str | None = None,
    timing_flag: bool = False,
    example_epi_file: InputPathType | None = None,
    log_directory: str | None = None,
    nonspatial_flag: bool = False,
    fix_mrf_precision_flag: bool = False,
    mrf_prec_start: float | None = None,
    mrf_prec_multiplier: float | None = None,
    init_multiplier: float | None = None,
    no_update_theta_flag: bool = False,
    zfstat_flag: bool = False,
    phi: float | None = None,
    niters: float | None = None,
    threshold: float | None = None,
    runner: Runner | None = None,
) -> MmOutputs:
    """
    FSL's MM: mixture modelling.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        spatial_data_file: Spatial map data file.
        mask_file: Mask file.
        verbose_flag: Switch on diagnostic messages.
        debug_level: Set debug level.
        timing_flag: Turn timing on.
        example_epi_file: Example EPI data file.
        log_directory: Log directory.
        nonspatial_flag: Nonspatial mixture model.
        fix_mrf_precision_flag: Fix MRF precision to mrfprecstart throughout.
        mrf_prec_start: MRF precision initial value (default is 10).
        mrf_prec_multiplier: Update multiplier for MRF precision (default is\
            -1, do not multiply).
        init_multiplier: Init multiplier (default is 0.3).
        no_update_theta_flag: Turn off updating of distribution parameters\
            after non-spatial fit.
        zfstat_flag: Turn on zfstat mode - this enforces no deactivation class.
        phi: Phi (default is 0.05).
        niters: Number of iterations (default is -1: auto stop).
        threshold: Threshold for use when displaying classification maps in\
            MM.html report (default is 0.5, -1 indicates no thresholding).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MmOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MM_METADATA)
    cargs = []
    cargs.append("mm")
    cargs.extend([
        "--sdf",
        execution.input_file(spatial_data_file)
    ])
    cargs.extend([
        "-m",
        execution.input_file(mask_file)
    ])
    if verbose_flag:
        cargs.append("--verbose")
    if debug_level is not None:
        cargs.extend([
            "--debug",
            debug_level
        ])
    if timing_flag:
        cargs.append("--timingon")
    if example_epi_file is not None:
        cargs.extend([
            "--edf",
            execution.input_file(example_epi_file)
        ])
    if log_directory is not None:
        cargs.extend([
            "--logdir",
            log_directory
        ])
    if nonspatial_flag:
        cargs.append("--ns")
    if fix_mrf_precision_flag:
        cargs.append("--fmp")
    if mrf_prec_start is not None:
        cargs.extend([
            "--mps",
            str(mrf_prec_start)
        ])
    if mrf_prec_multiplier is not None:
        cargs.extend([
            "--mpm",
            str(mrf_prec_multiplier)
        ])
    if init_multiplier is not None:
        cargs.extend([
            "--im",
            str(init_multiplier)
        ])
    if no_update_theta_flag:
        cargs.append("--nut")
    if zfstat_flag:
        cargs.append("--zfstatmode")
    if phi is not None:
        cargs.extend([
            "--phi",
            str(phi)
        ])
    if niters is not None:
        cargs.extend([
            "--ni",
            str(niters)
        ])
    if threshold is not None:
        cargs.extend([
            "--th",
            str(threshold)
        ])
    ret = MmOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MM_METADATA",
    "MmOutputs",
    "mm",
]
