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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSL_REG_METADATA = Metadata(
    id="fa899f6f488c1db24bf97c2552e452f45a1a6d51.boutiques",
    name="fsl_reg",
    package="fsl",
    container_image_tag="mcin/fsl:6.0.5",
)


class FslRegOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fsl_reg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_transform_file: OutputPathType
    """Output transformation file"""


def fsl_reg(
    input_file: InputPathType,
    reference_file: InputPathType,
    output_file: str,
    estimate_only_flag: bool = False,
    affine_only_flag: bool = False,
    fnirt_fa_config_flag: bool = False,
    flirt_options: str | None = None,
    fnirt_options: str | None = None,
    runner: Runner | None = None,
) -> FslRegOutputs:
    """
    Image registration using FSL tools.
    
    Author: Oxford Centre for Functional MRI of the Brain (FMRIB)
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FNIRT
    
    Args:
        input_file: Input image file.
        reference_file: Reference image file.
        output_file: Output transformation file.
        estimate_only_flag: Estimate transformation but don't apply it.
        affine_only_flag: Affine-only registration.
        fnirt_fa_config_flag: Use FNIRT config file optimised for FA data.
        flirt_options: Options to be passed onto flirt (inside double-quotes).
        fnirt_options: Options to be passed onto fnirt (inside double-quotes).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FslRegOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSL_REG_METADATA)
    cargs = []
    cargs.append("fsl_reg")
    cargs.append(execution.input_file(input_file))
    cargs.append(execution.input_file(reference_file))
    cargs.append(output_file)
    if estimate_only_flag:
        cargs.append("-e")
    if affine_only_flag:
        cargs.append("-a")
    if fnirt_fa_config_flag:
        cargs.append("-FA")
    if flirt_options is not None:
        cargs.extend([
            "-flirt",
            flirt_options
        ])
    if fnirt_options is not None:
        cargs.extend([
            "-fnirt",
            fnirt_options
        ])
    ret = FslRegOutputs(
        root=execution.output_file("."),
        output_transform_file=execution.output_file(output_file),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSL_REG_METADATA",
    "FslRegOutputs",
    "fsl_reg",
]
