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

import typing
import pathlib
from styxdefs import *
import dataclasses

CUTOFFCALC_METADATA = Metadata(
    id="9714ed35004136e0a3b4c57d222df3ed14bb182c.boutiques",
    name="cutoffcalc",
    package="fsl",
    container_image_tag="mcin/fsl:6.0.5",
)


class CutoffcalcOutputs(typing.NamedTuple):
    """
    Output object returned when calling `cutoffcalc(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    example_output: OutputPathType
    """Filtered output file if example sigma is provided"""


def cutoffcalc(
    input_design: InputPathType,
    threshold: float | None = 0.9,
    tr: float | None = 3.0,
    lower_limit: float | None = 90.0,
    example_sigma: float | None = None,
    verbose_flag: bool = False,
    debug_flag: bool = False,
    runner: Runner | None = None,
) -> CutoffcalcOutputs:
    """
    Calculates the minimal period for the highpass filter that still preserves a
    specified amount of variance in all the design matrix regressors.
    
    Author: University of Oxford (Mark Jenkinson and Matthew Webster)
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        input_design: Input design matrix (e.g. design.mat).
        threshold: Threshold for retained variance (default=0.9).
        tr: Time between successive data points (default=3.0s).
        lower_limit: Lower limit on period due to autocorr estimation\
            (default=90s).
        example_sigma: Example sigma (in sec) to produce output called\
            example_filt.mtx.
        verbose_flag: Switch on diagnostic messages.
        debug_flag: Switch on debugging messages.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CutoffcalcOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CUTOFFCALC_METADATA)
    cargs = []
    cargs.append("cutoffcalc")
    cargs.append("-i " + execution.input_file(input_design))
    if threshold is not None:
        cargs.append("-t " + str(threshold))
    if tr is not None:
        cargs.append("--tr " + str(tr))
    if lower_limit is not None:
        cargs.append("--limit " + str(lower_limit))
    if example_sigma is not None:
        cargs.append("--example_sig " + str(example_sigma))
    if verbose_flag:
        cargs.append("-v")
    if debug_flag:
        cargs.append("--debug")
    ret = CutoffcalcOutputs(
        root=execution.output_file("."),
        example_output=execution.output_file("example_filt.mtx"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "CUTOFFCALC_METADATA",
    "CutoffcalcOutputs",
    "cutoffcalc",
]
