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

import typing
import pathlib
from styxdefs import *
import dataclasses

MNI152REG_METADATA = Metadata(
    id="ce57b863d24379ba72442d213f0a02c5cba44366.boutiques",
    name="mni152reg",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class Mni152regOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mni152reg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    reg_matrix_2mm: OutputPathType
    """Output registration matrix for standard 2mm target"""
    reg_matrix_1mm: OutputPathType
    """Output registration matrix for 1mm target when --1 flag is used"""


def mni152reg(
    subject: str,
    register_1mm: bool = False,
    output: str | None = None,
    symmetric: bool = False,
    save_volume: bool = False,
    runner: Runner | None = None,
) -> Mni152regOutputs:
    """
    Registers the FreeSurfer subject to the FSL MNI 152 brain to create a
    tkregister-style registration matrix.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: FreeSurfer subject ID.
        register_1mm: Register to 1mm target (instead of 2mm).
        output: Explicitly set output registration file.
        symmetric: Register to FSL symmetric target.
        save_volume: Sample original to output space.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Mni152regOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MNI152REG_METADATA)
    cargs = []
    cargs.append("mni152reg")
    cargs.extend([
        "-s",
        "-" + subject
    ])
    if register_1mm:
        cargs.append("--1")
    if output is not None:
        cargs.extend([
            "--o",
            output
        ])
    if symmetric:
        cargs.append("--sym")
    if save_volume:
        cargs.append("--save-vol")
    ret = Mni152regOutputs(
        root=execution.output_file("."),
        reg_matrix_2mm=execution.output_file("$SUBJECTS_DIR/" + subject + "/mri/transforms/reg.mni152.2mm.dat"),
        reg_matrix_1mm=execution.output_file("$SUBJECTS_DIR/" + subject + "/mri/transforms/reg.mni152.1mm.dat"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MNI152REG_METADATA",
    "Mni152regOutputs",
    "mni152reg",
]
