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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_SBBR_METADATA = Metadata(
    id="f4b950626104a4845f82588892a8047d0782b10a.boutiques",
    name="mri_sbbr",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def mri_sbbr(
    template_volume: InputPathType,
    surface_file: InputPathType,
    init_reg_file: InputPathType,
    t1: bool = False,
    t2: bool = False,
    optimization_type: float | None = None,
    distance_in: float | None = None,
    distance_out: float | None = None,
    slope: float | None = None,
    ftol: float | None = None,
    linmintol: float | None = None,
    niters_max: float | None = None,
    search: str | None = None,
    search1d: str | None = None,
    parameter_set: str | None = None,
    increment: float | None = None,
    slice_number: float | None = None,
    threads: float | None = None,
    output_registration: str | None = None,
    inverted_output_registration: str | None = None,
    output_surface: str | None = None,
    debug: bool = False,
    diagnostic: bool = False,
    check_options: bool = False,
    runner: Runner | None = None,
) -> MriSbbrOutputs:
    """
    Special implementation of boundary-based registration for a single slice.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        template_volume: Template volume file.
        surface_file: Surface file.
        init_reg_file: Initial registration file.
        t1: Use T1-weighted image.
        t2: Use T2-weighted image.
        optimization_type: Optimization type; choose 1, 2, or 3 (default is 1,\
            6 dof).
        distance_in: Distance in mm into surface (default 1.0).
        distance_out: Distance in mm out of surface (default 2.0).
        slope: BBR slope (default 0.5).
        ftol: Tolerance for fitting (default 1.000000e-08).
        linmintol: Linear minimization tolerance (default 0.0).
        niters_max: Maximum number of iterations (default 10).
        search: Brute force search through parameter space.
        search1d: 1D search through parameter space.
        parameter_set: Set initial parameter.
        increment: Face number increment (default 1).
        slice_number: Slice number (defaults to 0).
        threads: Number of threads.
        output_registration: Output registration file.
        inverted_output_registration: Inverted output registration file.
        output_surface: Output surface in slice coordinates.
        debug: Turn on debugging.
        diagnostic: Turn on diagnostics.
        check_options: Don't run anything, just check options and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriSbbrOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_SBBR_METADATA)
    cargs = []
    cargs.append("mri_sbbr")
    cargs.extend([
        "--mov",
        execution.input_file(template_volume)
    ])
    cargs.extend([
        "--surf",
        execution.input_file(surface_file)
    ])
    cargs.extend([
        "--init-reg",
        execution.input_file(init_reg_file)
    ])
    if t1:
        cargs.append("--t1")
    if t2:
        cargs.append("--t2")
    if optimization_type is not None:
        cargs.extend([
            "--opt",
            str(optimization_type)
        ])
    if distance_in is not None:
        cargs.extend([
            "--din",
            str(distance_in)
        ])
    if distance_out is not None:
        cargs.extend([
            "--dout",
            str(distance_out)
        ])
    if slope is not None:
        cargs.extend([
            "--slope",
            str(slope)
        ])
    if ftol is not None:
        cargs.extend([
            "--ftol",
            str(ftol)
        ])
    if linmintol is not None:
        cargs.extend([
            "--linmintol",
            str(linmintol)
        ])
    if niters_max is not None:
        cargs.extend([
            "--niters-max",
            str(niters_max)
        ])
    if search is not None:
        cargs.extend([
            "--search",
            search
        ])
    if search1d is not None:
        cargs.extend([
            "--search1d",
            search1d
        ])
    if parameter_set is not None:
        cargs.extend([
            "--p",
            parameter_set
        ])
    if increment is not None:
        cargs.extend([
            "--inc",
            str(increment)
        ])
    if slice_number is not None:
        cargs.extend([
            "--slice",
            str(slice_number)
        ])
    if threads is not None:
        cargs.extend([
            "--threads",
            str(threads)
        ])
    if output_registration is not None:
        cargs.extend([
            "--reg",
            output_registration
        ])
    if inverted_output_registration is not None:
        cargs.extend([
            "--reg-inv",
            inverted_output_registration
        ])
    if output_surface is not None:
        cargs.extend([
            "--out-surf",
            output_surface
        ])
    if debug:
        cargs.append("--debug")
    if diagnostic:
        cargs.append("--diag")
    if check_options:
        cargs.append("--checkopts")
    ret = MriSbbrOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_SBBR_METADATA",
    "MriSbbrOutputs",
    "mri_sbbr",
]
