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

import typing
import pathlib
from styxdefs import *
import dataclasses

BBREGISTER_METADATA = Metadata(
    id="06a9a3d42999005484cd3e30d110e491b2d7dca8.boutiques",
    name="bbregister",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class BbregisterOutputs(typing.NamedTuple):
    """
    Output object returned when calling `bbregister(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    reg_output: OutputPathType
    """Output registration file in dat or lta format."""
    out_volume: OutputPathType
    """Resampled moveable volume."""


def bbregister(
    subject: str,
    moveable_volume: InputPathType,
    reg_file: str,
    contrast_type_t2: bool = False,
    runner: Runner | None = None,
) -> BbregisterOutputs:
    """
    Performs within-subject, cross-modal registration using a boundary-based cost
    function.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: FreeSurfer subject name as found in $SUBJECTS_DIR.
        moveable_volume: "Moveable" volume template for cross-modal volume.\
            E.g., fMRI volume used for motion correction.
        reg_file: Output FreeSurfer registration file (tkregister-style or LTA\
            format).
        contrast_type_t2: Assume T2 contrast, Grey Matter brighter than White\
            Matter. Same as --bold and --dti.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BbregisterOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(BBREGISTER_METADATA)
    cargs = []
    cargs.append("bbregister")
    cargs.extend([
        "--s",
        subject
    ])
    cargs.extend([
        "--mov",
        execution.input_file(moveable_volume)
    ])
    cargs.extend([
        "--reg",
        reg_file
    ])
    if contrast_type_t2:
        cargs.append("--t2")
    cargs.append("[OPTIONS]")
    ret = BbregisterOutputs(
        root=execution.output_file("."),
        reg_output=execution.output_file(reg_file),
        out_volume=execution.output_file("[O_OUTVOL]"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "BBREGISTER_METADATA",
    "BbregisterOutputs",
    "bbregister",
]
