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

import typing
import pathlib
from styxdefs import *
import dataclasses

ROBUSTFOV_METADATA = Metadata(
    id="fe07b11b244bac46a02d5373b67ae5b1735d6731.boutiques",
    name="robustfov",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class RobustfovOutputs(typing.NamedTuple):
    """
    Output object returned when calling `robustfov(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_roi_volume: OutputPathType | None
    """ROI volume output"""
    output_matrix_file: OutputPathType | None
    """Matrix output (ROI to full FOV)"""


def robustfov(
    input_file: InputPathType,
    output_image: str | None = "output",
    brain_size: float | None = None,
    matrix_output: str | None = None,
    debug_flag: bool = False,
    verbose_flag: bool = False,
    runner: Runner | None = None,
) -> RobustfovOutputs:
    """
    Reduce FOV of image to remove lower head and neck.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        input_file: Input image file.
        output_image: ROI volume output name.
        brain_size: Size of the brain in z-dimension (default 170mm).
        matrix_output: Matrix output name (ROI to full FOV).
        debug_flag: Turn on debugging output.
        verbose_flag: Switch on diagnostic messages.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `RobustfovOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ROBUSTFOV_METADATA)
    cargs = []
    cargs.append("robustfov")
    cargs.extend([
        "-i",
        execution.input_file(input_file)
    ])
    if output_image is not None:
        cargs.extend([
            "-r",
            output_image
        ])
    if brain_size is not None:
        cargs.extend([
            "-b",
            str(brain_size)
        ])
    if matrix_output is not None:
        cargs.extend([
            "-m",
            matrix_output
        ])
    if debug_flag:
        cargs.append("--debug")
    if verbose_flag:
        cargs.append("--verbose")
    ret = RobustfovOutputs(
        root=execution.output_file("."),
        output_roi_volume=execution.output_file(output_image.removesuffix(".nii.gz") + ".nii.gz") if (output_image is not None) else None,
        output_matrix_file=execution.output_file(matrix_output + ".txt") if (matrix_output is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ROBUSTFOV_METADATA",
    "RobustfovOutputs",
    "robustfov",
]
