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

import typing
import pathlib
from styxdefs import *
import dataclasses

FEATREGAPPLY_METADATA = Metadata(
    id="30c4e6513395f39bf385f62de8b909c189f6d029.boutiques",
    name="featregapply",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class FeatregapplyOutputs(typing.NamedTuple):
    """
    Output object returned when calling `featregapply(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_directory: OutputPathType
    """Directory where the output files will be stored"""


def featregapply(
    feat_directory: str,
    force_flag: bool = False,
    cleanup_flag: bool = False,
    upsample_trilinear: InputPathType | None = None,
    upsample_spline: InputPathType | None = None,
    standard_space_res: float | None = None,
    exclude_filtered_func_flag: bool = False,
    runner: Runner | None = None,
) -> FeatregapplyOutputs:
    """
    Apply registration from FEAT analysis to other images.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        feat_directory: FEAT directory from which registration will be taken.
        force_flag: Force featregapply to run even if it has already been run\
            on this FEAT directory.
        cleanup_flag: Cleanup, i.e. remove all featregapply output.
        upsample_trilinear: Upsample functional-space image to standard space\
            using trilinear interpolation.
        upsample_spline: Upsample functional-space image to standard space\
            using spline (like sinc) interpolation.
        standard_space_res: Specify the standard space resolution for melodic\
            (e.g. 3 for 3mm).
        exclude_filtered_func_flag: Exclude filtered func when processing\
            melodic directories (for FEAT directories filtered func is never\
            processed).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FeatregapplyOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FEATREGAPPLY_METADATA)
    cargs = []
    cargs.append("featregapply")
    cargs.append(feat_directory)
    if force_flag:
        cargs.append("-f")
    if cleanup_flag:
        cargs.append("-c")
    if upsample_trilinear is not None:
        cargs.extend([
            "-l",
            execution.input_file(upsample_trilinear)
        ])
    if upsample_spline is not None:
        cargs.extend([
            "-s",
            execution.input_file(upsample_spline)
        ])
    if standard_space_res is not None:
        cargs.extend([
            "-r",
            str(standard_space_res)
        ])
    if exclude_filtered_func_flag:
        cargs.append("-e")
    ret = FeatregapplyOutputs(
        root=execution.output_file("."),
        output_directory=execution.output_file(feat_directory + "/reg_standard"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FEATREGAPPLY_METADATA",
    "FeatregapplyOutputs",
    "featregapply",
]
