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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSL_RIGID_REGISTER_METADATA = Metadata(
    id="86ae5f77c79298b854bf775bed382049d793e4ae.boutiques",
    name="fsl_rigid_register",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class FslRigidRegisterOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fsl_rigid_register(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    fslmat_output: OutputPathType
    """The registration matrix in FSL format."""


def fsl_rigid_register(
    refvol: InputPathType,
    inputvol: InputPathType,
    outputvol: str,
    fslmat: str | None = None,
    regmat: str | None = None,
    xfmmat: str | None = None,
    ltamat: str | None = None,
    noinitgeom: bool = False,
    applyxfm: InputPathType | None = None,
    applyinitxfm: bool = False,
    initxfm: InputPathType | None = None,
    maxangle: float | None = None,
    interp: str | None = None,
    dof: float | None = None,
    bins: float | None = None,
    cost: str | None = None,
    tmpdir: str | None = None,
    nocleanup: bool = False,
    cleanup: bool = False,
    subject: str | None = None,
    version: bool = False,
    help_: bool = False,
    runner: Runner | None = None,
) -> FslRigidRegisterOutputs:
    """
    A front-end tool for FSL's FLIRT that computes a rigid registration matrix and
    resamples the input volume to the reference volume.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        refvol: Reference/Target volume.
        inputvol: Input/Moveable volume.
        outputvol: Input resampled to reference.
        fslmat: Specifies explicitly where to store the FSL registration\
            matrix.
        regmat: Get registration matrix in register.dat file format.
        xfmmat: Get registration matrix as MNI xfm file.
        ltamat: Get registration matrix as MGH lta file.
        noinitgeom: Do not initialize matrix based on geometry.
        applyxfm: Apply a transformation file to the input without\
            registration.
        applyinitxfm: Apply initial transformation to the input without\
            registration.
        initxfm: Use this as an initial matrix for registration.
        maxangle: Only search over +/- max angle degrees.
        interp: Interpolation method: trilinear, nearestneighbour, sinc.
        dof: Use degrees of freedom instead of 6.
        bins: Number of bins to use (default 256).
        cost: Objective function: mutualinfo, corratio (default), normcorr,\
            normmi, leastsq.
        tmpdir: Specify temporary directory.
        nocleanup: Do not delete temporary files.
        cleanup: Delete temporary files (default).
        subject: Only puts it in the register.dat file.
        version: Print version and exit.
        help_: Print help and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FslRigidRegisterOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSL_RIGID_REGISTER_METADATA)
    cargs = []
    cargs.append("fsl_rigid_register")
    cargs.extend([
        "-r",
        execution.input_file(refvol)
    ])
    cargs.extend([
        "-i",
        execution.input_file(inputvol)
    ])
    cargs.extend([
        "-o",
        outputvol
    ])
    if fslmat is not None:
        cargs.extend([
            "-fslmat",
            fslmat
        ])
    if regmat is not None:
        cargs.extend([
            "-regmat",
            regmat
        ])
    if xfmmat is not None:
        cargs.extend([
            "-xfmmat",
            xfmmat
        ])
    if ltamat is not None:
        cargs.extend([
            "-ltamat",
            ltamat
        ])
    if noinitgeom:
        cargs.append("-noinitgeom")
    if applyxfm is not None:
        cargs.extend([
            "-applyxfm",
            execution.input_file(applyxfm)
        ])
    if applyinitxfm:
        cargs.append("-applyinitxfm")
    if initxfm is not None:
        cargs.extend([
            "-initxfm",
            execution.input_file(initxfm)
        ])
    if maxangle is not None:
        cargs.extend([
            "-maxangle",
            str(maxangle)
        ])
    if interp is not None:
        cargs.extend([
            "-interp",
            interp
        ])
    if dof is not None:
        cargs.extend([
            "-dof",
            str(dof)
        ])
    if bins is not None:
        cargs.extend([
            "-bins",
            str(bins)
        ])
    if cost is not None:
        cargs.extend([
            "-cost",
            cost
        ])
    if tmpdir is not None:
        cargs.extend([
            "-tmpdir",
            tmpdir
        ])
    if nocleanup:
        cargs.append("-nocleanup")
    if cleanup:
        cargs.append("-cleanup")
    if subject is not None:
        cargs.extend([
            "-subject",
            subject
        ])
    if version:
        cargs.append("-version")
    if help_:
        cargs.append("-help")
    ret = FslRigidRegisterOutputs(
        root=execution.output_file("."),
        fslmat_output=execution.output_file(outputvol + ".fslmat"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSL_RIGID_REGISTER_METADATA",
    "FslRigidRegisterOutputs",
    "fsl_rigid_register",
]
