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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSLREORIENT2STD_METADATA = Metadata(
    id="98ad860c6642382747cdb3cc314cb5e47d03ab96.boutiques",
    name="fslreorient2std",
    package="fsl",
    container_image_tag="mcin/fsl:6.0.5",
)


class Fslreorient2stdOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fslreorient2std(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_image: OutputPathType | None
    """Reoriented output image (NIfTI format)"""
    matrix_output: OutputPathType
    """File to save the transformation matrix"""


def fslreorient2std(
    input_image: InputPathType,
    output_image: InputPathType | None = None,
    runner: Runner | None = None,
) -> Fslreorient2stdOutputs:
    """
    A tool for reorienting an image to match the approximate orientation of standard
    template images (MNI152).
    
    Author: Oxford Centre for Functional MRI of the Brain (FMRIB)
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Fslutils#fslreorient2std
    
    Args:
        input_image: Input image to be reoriented (NIfTI format, e.g.\
            img.nii.gz).
        output_image: Output image with the reoriented result (NIfTI format,\
            e.g. reoriented_img.nii.gz). If not provided, transformation matrix is\
            output to standard output.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Fslreorient2stdOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSLREORIENT2STD_METADATA)
    cargs = []
    cargs.append("fslreorient2std")
    cargs.append(execution.input_file(input_image))
    if output_image is not None:
        cargs.append(execution.input_file(output_image))
    cargs.append("[-m")
    cargs.append("MATRIX_FILE]")
    ret = Fslreorient2stdOutputs(
        root=execution.output_file("."),
        output_image=execution.output_file(pathlib.Path(output_image).name) if (output_image is not None) else None,
        matrix_output=execution.output_file("[MATRIX_FILE]"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSLREORIENT2STD_METADATA",
    "Fslreorient2stdOutputs",
    "fslreorient2std",
]
