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

import typing
import pathlib
from styxdefs import *
import dataclasses

MIDTRANS_METADATA = Metadata(
    id="199624ee421c21ddcb5318e1c0213bf85f4d3c9a.boutiques",
    name="midtrans",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class MidtransOutputs(typing.NamedTuple):
    """
    Output object returned when calling `midtrans(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def midtrans(
    transforms: list[InputPathType],
    output_matrix: str | None = None,
    template_image: InputPathType | None = None,
    separate_basename: str | None = None,
    debug_flag: bool = False,
    verbose_flag: bool = False,
    runner: Runner | None = None,
) -> MidtransOutputs:
    """
    Calculate the midpoint transform from a series of input transforms.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        transforms: List of input transform files (e.g. transform1.mat\
            transform2.mat ... transformN.mat).
        output_matrix: Output filename for the resulting matrix.
        template_image: Input filename for template image (needed for fix\
            origin).
        separate_basename: Basename for the output of separate matrices (final\
            name includes a number; e.g. img2mid0001.mat).
        debug_flag: Switch on debugging output.
        verbose_flag: Switch on diagnostic messages.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MidtransOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MIDTRANS_METADATA)
    cargs = []
    cargs.append("midtrans")
    cargs.extend([execution.input_file(f) for f in transforms])
    if output_matrix is not None:
        cargs.extend([
            "-o",
            output_matrix
        ])
    if template_image is not None:
        cargs.extend([
            "--template",
            execution.input_file(template_image)
        ])
    if separate_basename is not None:
        cargs.extend([
            "--separate",
            separate_basename
        ])
    if debug_flag:
        cargs.append("--debug")
    if verbose_flag:
        cargs.append("-v, --verbose")
    ret = MidtransOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MIDTRANS_METADATA",
    "MidtransOutputs",
    "midtrans",
]
