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

import typing
import pathlib
from styxdefs import *
import dataclasses

C3D_AFFINE_TOOL_METADATA = Metadata(
    id="4d680bc675d44917986d0a7dc537117e07489d00.boutiques",
    name="c3d_affine_tool",
    package="c3d",
    container_image_tag="pyushkevich/itksnap:v3.8.2",
)


class C3dAffineToolOutputs(typing.NamedTuple):
    """
    Output object returned when calling `c3d_affine_tool(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    itk_transform_outfile: OutputPathType | None
    """Output ITK transform file."""
    irtk_transform_outfile: OutputPathType | None
    """Output IRTK transform file."""
    matrix_transform_outfile: OutputPathType | None
    """Write output matrix."""


def c3d_affine_tool(
    transform_file: InputPathType | None = None,
    reference_file: InputPathType | None = None,
    source_file: InputPathType | None = None,
    sform_file: InputPathType | None = None,
    invert: bool = False,
    determinant: bool = False,
    multiply: bool = False,
    sqrt: bool = False,
    itk_transform: InputPathType | None = None,
    irtk_transform: InputPathType | None = None,
    fsl2ras: bool = False,
    ras2fsl: bool = False,
    out_itk_transform: str | None = None,
    out_irtk_transform: str | None = None,
    out_matfile: str | None = None,
    info: bool = False,
    info_full: bool = False,
    runner: Runner | None = None,
) -> C3dAffineToolOutputs:
    """
    RAS affine transform tool.
    
    Author: Convert3D Developers
    
    URL: http://www.itksnap.org/pmwiki/pmwiki.php?n=Convert3D.Convert3D
    
    Args:
        transform_file: file or string representing the transform.
        reference_file: Set reference (fixed) image - only for -fsl2ras and\
            -ras2fsl.
        source_file: Set source (moving) image - only for -fsl2ras and\
            -ras2fsl.
        sform_file: Read matrix from NifTI sform.
        invert: Invert matrix.
        determinant: Print the determinant.
        multiply: Multiply matrices.
        sqrt: Matrix square root (i.e., Q s.t. A = Q * Q).
        itk_transform: Import ITK transform.
        irtk_transform: Import IRTK .dof format transform.
        fsl2ras: Convert FSL to RAS.
        ras2fsl: Convert RAS to FSL.
        out_itk_transform: Export ITK transform.
        out_irtk_transform: Export IRTK .dof format transform.
        out_matfile: Write output matrix.
        info: Print matrix.
        info_full: Print matrix and more detail about the transform.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `C3dAffineToolOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(C3D_AFFINE_TOOL_METADATA)
    cargs = []
    cargs.append("c3d_affine_tool")
    if transform_file is not None:
        cargs.append(execution.input_file(transform_file))
    if reference_file is not None:
        cargs.extend([
            "-ref",
            execution.input_file(reference_file)
        ])
    if source_file is not None:
        cargs.extend([
            "-src",
            execution.input_file(source_file)
        ])
    if sform_file is not None:
        cargs.extend([
            "-sform",
            execution.input_file(sform_file)
        ])
    if invert:
        cargs.append("-inv")
    if determinant:
        cargs.append("-det")
    if multiply:
        cargs.append("-mult")
    if sqrt:
        cargs.append("-sqrt")
    if itk_transform is not None:
        cargs.extend([
            "-itk",
            execution.input_file(itk_transform)
        ])
    if irtk_transform is not None:
        cargs.extend([
            "-irtk",
            execution.input_file(irtk_transform)
        ])
    if fsl2ras:
        cargs.append("-fsl2ras")
    if ras2fsl:
        cargs.append("-ras2fsl")
    if out_itk_transform is not None:
        cargs.extend([
            "-oitk",
            out_itk_transform
        ])
    if out_irtk_transform is not None:
        cargs.extend([
            "-oirtk",
            out_irtk_transform
        ])
    if out_matfile is not None:
        cargs.extend([
            "-o",
            out_matfile
        ])
    if info:
        cargs.append("-info")
    if info_full:
        cargs.append("-info-full")
    ret = C3dAffineToolOutputs(
        root=execution.output_file("."),
        itk_transform_outfile=execution.output_file(out_itk_transform) if (out_itk_transform is not None) else None,
        irtk_transform_outfile=execution.output_file(out_irtk_transform) if (out_irtk_transform is not None) else None,
        matrix_transform_outfile=execution.output_file(out_matfile) if (out_matfile is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "C3D_AFFINE_TOOL_METADATA",
    "C3dAffineToolOutputs",
    "c3d_affine_tool",
]
