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

import typing
import pathlib
from styxdefs import *
import dataclasses

ROI_METADATA = Metadata(
    id="0182836486efae1debe989da6ba98d23ed8c3872.boutiques",
    name="roi",
    package="fsl",
    container_image_tag="mcin/fsl:6.0.5",
)


class RoiOutputs(typing.NamedTuple):
    """
    Output object returned when calling `roi(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    roi_file_outfile: OutputPathType
    """Output ROI file."""


def roi(
    in_file: InputPathType,
    roi_file: str,
    x_min: int | None = None,
    x_size: int | None = None,
    y_min: int | None = None,
    y_size: int | None = None,
    z_min: int | None = None,
    z_size: int | None = None,
    t_min: int | None = None,
    t_size: int | None = None,
    runner: Runner | None = None,
) -> RoiOutputs:
    """
    Extract region of interest (ROI) from an image.
    
    Author: Oxford Centre for Functional MRI of the Brain (FMRIB)
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Fslutils
    
    Args:
        in_file: Input image to extract ROI from.
        roi_file: Output ROI file.
        x_min: Minimum index for x-dimension.
        x_size: Size of ROI for x-dimension.
        y_min: Minimum index for y-dimension.
        y_size: Size of ROI for y-dimension.
        z_min: Minimum index for z-dimension.
        z_size: Size of ROI for z-dimension.
        t_min: Minimum index for t-dimension.
        t_size: Size of ROI in t-dimension.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `RoiOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ROI_METADATA)
    cargs = []
    cargs.append("fslroi")
    cargs.append(execution.input_file(in_file))
    cargs.append(roi_file)
    if x_min is not None:
        cargs.append(str(x_min))
    if x_size is not None:
        cargs.append(str(x_size))
    if y_min is not None:
        cargs.append(str(y_min))
    if y_size is not None:
        cargs.append(str(y_size))
    if z_min is not None:
        cargs.append(str(z_min))
    if z_size is not None:
        cargs.append(str(z_size))
    if t_min is not None:
        cargs.append(str(t_min))
    if t_size is not None:
        cargs.append(str(t_size))
    ret = RoiOutputs(
        root=execution.output_file("."),
        roi_file_outfile=execution.output_file(roi_file + ".nii.gz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ROI_METADATA",
    "RoiOutputs",
    "roi",
]
