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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_REGISTER_TO_LABEL_METADATA = Metadata(
    id="36d8ca89ec62d6d129c91373f3bc303868500379.boutiques",
    name="mris_register_to_label",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisRegisterToLabelOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_register_to_label(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def mris_register_to_label(
    surface: InputPathType,
    regfile: InputPathType,
    mri_reg: InputPathType,
    mov_volume: InputPathType,
    resolution: float,
    max_rot: float | None = None,
    max_trans: float | None = None,
    subject: str | None = None,
    label: str | None = None,
    out_reg: str | None = None,
    downsample: float | None = None,
    cost_file: InputPathType | None = None,
    runner: Runner | None = None,
) -> MrisRegisterToLabelOutputs:
    """
    Register a surface to a volume using a label.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        surface: Surface file for registration.
        regfile: Registration file.
        mri_reg: Volume for MRI registration.
        mov_volume: Volume on which label points are specified.
        resolution: Resolution for calculations.
        max_rot: Maximum angle (degrees) to search over for rotation.
        max_trans: Maximum translation (mm) to search over.
        subject: Specify name of subject for register.dat file.
        label: Load label and limit calculations to it.
        out_reg: Output registration at lowest cost.
        downsample: Downsample input volume by a factor.
        cost_file: Cost file for registration.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisRegisterToLabelOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_REGISTER_TO_LABEL_METADATA)
    cargs = []
    cargs.append("mris_register_to_label")
    cargs.extend([
        "--surf",
        execution.input_file(surface)
    ])
    cargs.extend([
        "--reg",
        execution.input_file(regfile)
    ])
    cargs.extend([
        "--mri_reg",
        execution.input_file(mri_reg)
    ])
    cargs.extend([
        "--mov",
        execution.input_file(mov_volume)
    ])
    cargs.extend([
        "--res",
        str(resolution)
    ])
    if max_rot is not None:
        cargs.extend([
            "--max_rot",
            str(max_rot)
        ])
    if max_trans is not None:
        cargs.extend([
            "--max_trans",
            str(max_trans)
        ])
    if subject is not None:
        cargs.extend([
            "--s",
            subject
        ])
    if label is not None:
        cargs.extend([
            "--label",
            label
        ])
    if out_reg is not None:
        cargs.extend([
            "--out-reg",
            out_reg
        ])
    if downsample is not None:
        cargs.extend([
            "--downsample",
            str(downsample)
        ])
    if cost_file is not None:
        cargs.extend([
            "--cost",
            execution.input_file(cost_file)
        ])
    ret = MrisRegisterToLabelOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_REGISTER_TO_LABEL_METADATA",
    "MrisRegisterToLabelOutputs",
    "mris_register_to_label",
]
