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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSLREGISTER_METADATA = Metadata(
    id="81e352f9cdac0df3ddc26c66eafd2de97cd00277.boutiques",
    name="fslregister",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class FslregisterOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fslregister(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_reg_file: OutputPathType
    """Output registration file."""
    output_resliced_volume: OutputPathType | None
    """Resliced output volume."""
    output_fsl_matrix: OutputPathType | None
    """FSL format output registration matrix."""
    lta_output: OutputPathType | None
    """Registration output in LTA format."""
    output_template: OutputPathType | None
    """Output template."""


def fslregister(
    subjid: str,
    mov_vol: str,
    reg_file: str,
    fsl_matrix: str | None = None,
    init_fsl_matrix: str | None = None,
    no_init_xfm: bool = False,
    niters: float | None = None,
    dof: float | None = None,
    bins: float | None = None,
    cost: str | None = None,
    max_angle: float | None = None,
    no_new_schedule: bool = False,
    no_allow_swap: bool = False,
    no_trans: bool = False,
    bet_mov: bool = False,
    bet_fvalue: float | None = None,
    bet_func: bool = False,
    bet_ref: bool = False,
    frame: float | None = None,
    mid_frame: bool = False,
    freesurfer_volume: str | None = None,
    template_output: str | None = None,
    output_volume: str | None = None,
    verbose: float | None = None,
    tmp_dir: str | None = None,
    no_cleanup: bool = False,
    no_log: bool = False,
    version: bool = False,
    help_: bool = False,
    lta_format: str | None = None,
    runner: Runner | None = None,
) -> FslregisterOutputs:
    """
    Registers a volume to its FreeSurfer anatomical using FSL's FLIRT and creates a
    FreeSurfer register.dat file.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subjid: Id of the subject as found in SUBJECTS_DIR.
        mov_vol: Volume identifier of the movable volume.
        reg_file: Output registration file.
        fsl_matrix: Output registration matrix in FSL format.
        init_fsl_matrix: Supply initial FSL matrix file.
        no_init_xfm: Do not initialize based on header geometry.
        niters: Number of iterations for FLIRT.
        dof: Degrees of freedom in the FLIRT registration.
        bins: Number of bins for FLIRT.
        cost: Cost function for FLIRT.
        max_angle: Maximum search angle for FLIRT.
        no_new_schedule: Disable new schedule in FLIRT.
        no_allow_swap: Do not allow swap dimension of positive determinant\
            input volumes.
        no_trans: Do not perform translation-only registration prior to full.
        bet_mov: Perform brain extraction on movable volume.
        bet_fvalue: f value for BET.
        bet_func: Run betfunc instead of bet.
        bet_ref: Perform brain extraction on reference volume.
        frame: Frame number for registration.
        mid_frame: Use the middle frame of the volume.
        freesurfer_volume: Use FreeSurfer volid as reference volume.
        template_output: Save template.
        output_volume: Have FLIRT reslice movable volume to target.
        verbose: FLIRT verbosity level.
        tmp_dir: Temporary directory to use.
        no_cleanup: Do not delete temporary files.
        no_log: Do not produce a log file.
        version: Print version and exit.
        help_: Print help and exit.
        lta_format: Output registration in LTA format.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FslregisterOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSLREGISTER_METADATA)
    cargs = []
    cargs.append("fslregister")
    cargs.extend([
        "--s",
        subjid
    ])
    cargs.extend([
        "--mov",
        mov_vol
    ])
    cargs.extend([
        "--reg",
        reg_file
    ])
    if fsl_matrix is not None:
        cargs.extend([
            "--fslmat",
            fsl_matrix
        ])
    if init_fsl_matrix is not None:
        cargs.extend([
            "--initfslmat",
            init_fsl_matrix
        ])
    if no_init_xfm:
        cargs.append("--noinitxfm")
    if niters is not None:
        cargs.extend([
            "--niters",
            str(niters)
        ])
    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 max_angle is not None:
        cargs.extend([
            "--maxangle",
            str(max_angle)
        ])
    if no_new_schedule:
        cargs.append("--no-new-schedule")
    if no_allow_swap:
        cargs.append("--no-allow-swap")
    if no_trans:
        cargs.append("--no-trans")
    if bet_mov:
        cargs.append("--betmov")
    if bet_fvalue is not None:
        cargs.extend([
            "--betfvalue",
            str(bet_fvalue)
        ])
    if bet_func:
        cargs.append("--betfunc")
    if bet_ref:
        cargs.append("--betref")
    if frame is not None:
        cargs.extend([
            "--frame",
            str(frame)
        ])
    if mid_frame:
        cargs.append("--mid-frame")
    if freesurfer_volume is not None:
        cargs.extend([
            "--fsvol",
            freesurfer_volume
        ])
    if template_output is not None:
        cargs.extend([
            "--template-out",
            template_output
        ])
    if output_volume is not None:
        cargs.extend([
            "--out",
            output_volume
        ])
    if verbose is not None:
        cargs.extend([
            "--verbose",
            str(verbose)
        ])
    if tmp_dir is not None:
        cargs.extend([
            "--tmp",
            tmp_dir
        ])
    if no_cleanup:
        cargs.append("--nocleanup")
    if no_log:
        cargs.append("--nolog")
    if version:
        cargs.append("--version")
    if help_:
        cargs.append("--help")
    if lta_format is not None:
        cargs.extend([
            "--lta",
            lta_format
        ])
    ret = FslregisterOutputs(
        root=execution.output_file("."),
        output_reg_file=execution.output_file(reg_file),
        output_resliced_volume=execution.output_file(output_volume) if (output_volume is not None) else None,
        output_fsl_matrix=execution.output_file(fsl_matrix) if (fsl_matrix is not None) else None,
        lta_output=execution.output_file(lta_format) if (lta_format is not None) else None,
        output_template=execution.output_file(template_output) if (template_output is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSLREGISTER_METADATA",
    "FslregisterOutputs",
    "fslregister",
]
