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

import typing
import pathlib
from styxdefs import *
import dataclasses

LPCREGISTER_METADATA = Metadata(
    id="e5a5971735d364dfe8f37cf7d53f26828a5b15b4.boutiques",
    name="lpcregister",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class LpcregisterOutputs(typing.NamedTuple):
    """
    Output object returned when calling `lpcregister(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_reg_file: OutputPathType
    """Output registration file in FreeSurfer format."""
    resampled_volume: OutputPathType | None
    """The resampled movable volume if --o is specified."""


def lpcregister(
    subject_id: str,
    mov_volume: str,
    reg_file: str,
    dof_9: bool = False,
    dof_12: bool = False,
    frame_number: float | None = None,
    mid_frame: bool = False,
    fsvol: str | None = None,
    output_volume: str | None = None,
    tmp_dir: str | None = None,
    no_cleanup: bool = False,
    version: bool = False,
    help_: bool = False,
    runner: Runner | None = None,
) -> LpcregisterOutputs:
    """
    Registers a volume to its FreeSurfer anatomical using Local Pearson Correlation
    (LPC) (the AFNI lpc_align.py program). Creates a FreeSurfer register.dat file.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject_id: Subject ID found in SUBJECTS_DIR. The reference volume is\
            the mri/brain volume (modifiable with --fsvol). Converted to analyze\
            using mri_convert.
        mov_volume: Volume identifier of the movable volume. Must be specified\
            suitably for mri_convert. Uses first frame unless --frame is specified.
        reg_file: Output registration file mapping RAS in the reference to RAS\
            in the movable. The file/matrix format is understood by freesurfer.
        dof_9: Use 9 degrees of freedom; default is 6.
        dof_12: Use 12 degrees of freedom; default is 6.
        frame_number: Specify the frame number other than the first. For SPM\
            analyze, specify the file corresponding to the desired frame as each\
            file only has one frame.
        mid_frame: Register to the middle frame of the mov volume as the\
            template. Cannot be used with --frame.
        fsvol: Use FreeSurfer volume id; default is brainmask.
        output_volume: Output volume file for resampled mov.
        tmp_dir: Specify temporary directory (implies --nocleanup).
        no_cleanup: Do not delete temporary files.
        version: Print the version and exit.
        help_: Print help information and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `LpcregisterOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(LPCREGISTER_METADATA)
    cargs = []
    cargs.append("lpcregister")
    cargs.extend([
        "--s",
        subject_id
    ])
    cargs.extend([
        "--mov",
        mov_volume
    ])
    cargs.extend([
        "--reg",
        reg_file
    ])
    if dof_9:
        cargs.append("--9")
    if dof_12:
        cargs.append("--12")
    if frame_number is not None:
        cargs.extend([
            "--frame",
            str(frame_number)
        ])
    if mid_frame:
        cargs.append("--mid-frame")
    if fsvol is not None:
        cargs.extend([
            "--fsvol",
            fsvol
        ])
    if output_volume is not None:
        cargs.extend([
            "--o",
            output_volume
        ])
    if tmp_dir is not None:
        cargs.extend([
            "--tmp",
            tmp_dir
        ])
    if no_cleanup:
        cargs.append("--nocleanup")
    if version:
        cargs.append("--version")
    if help_:
        cargs.append("--help")
    ret = LpcregisterOutputs(
        root=execution.output_file("."),
        output_reg_file=execution.output_file("register.dat"),
        resampled_volume=execution.output_file(output_volume) if (output_volume is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "LPCREGISTER_METADATA",
    "LpcregisterOutputs",
    "lpcregister",
]
