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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_REGISTER_METADATA = Metadata(
    id="01ac3575a4acd8aa600baa6d27fee615f0a862c6.boutiques",
    name="mris_register",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisRegisterOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_register(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_surface_file: OutputPathType
    """Output surface file after registration."""
    jacobian_output: OutputPathType | None
    """Jacobian output file if specified."""


def mris_register(
    surf_fname: InputPathType,
    target: InputPathType,
    out_fname: str,
    one_flag: bool = False,
    addframe: str | None = None,
    annot_name: str | None = None,
    curvature_fname: InputPathType | None = None,
    canonical_name: str | None = None,
    inflated: bool = False,
    inflated_name: str | None = None,
    label_file: str | None = None,
    orig_name: str | None = None,
    overlay_values: str | None = None,
    overlay_dir: str | None = None,
    starting_reg_fname: InputPathType | None = None,
    jacobian_fname: str | None = None,
    n_averages: float | None = None,
    adaptive: bool = False,
    l_area: float | None = None,
    l_corr: float | None = None,
    curvature_flag: bool = False,
    l_dist: float | None = None,
    dt_value: float | None = None,
    dt_decrease: float | None = None,
    dt_increase: float | None = None,
    l_external: float | None = None,
    error_ratio: float | None = None,
    initial_flag: bool = False,
    l_laplacian: float | None = None,
    line_min: bool = False,
    momentum: float | None = None,
    max_degrees: float | None = None,
    median: bool = False,
    min_degrees: float | None = None,
    multi_scale: float | None = None,
    n_iterations: float | None = None,
    n_angles: float | None = None,
    neighborhood_size: float | None = None,
    l_nlarea: float | None = None,
    no_curv: bool = False,
    no_normalization: bool = False,
    no_rotation: bool = False,
    no_sulc: bool = False,
    num_surfaces: float | None = None,
    overlay_corr: float | None = None,
    max_passes: float | None = None,
    l_parea: float | None = None,
    remove_negative: float | None = None,
    reverse: bool = False,
    rotate_values: str | None = None,
    registration_file: InputPathType | None = None,
    scale: float | None = None,
    search_flag: bool = False,
    spring_value: float | None = None,
    tolerance: float | None = None,
    topology_flag: bool = False,
    vnum: str | None = None,
    vsmooth: bool = False,
    write_iterations: float | None = None,
    gdiag_no: float | None = None,
    vector_flag: bool = False,
    threads: float | None = None,
    version_flag: bool = False,
    runner: Runner | None = None,
) -> MrisRegisterOutputs:
    """
    This program registers a surface to an average surface template.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        surf_fname: Surface to register, often {hemi}.sphere.
        target: The data to register to. A template file for average surface or\
            a single-subject's surface.
        out_fname: Output surface file to capture registration. Example:\
            {hemi}.sphere.reg.
        one_flag: Treats target argument as a single subject's surface not a\
            template file.
        addframe: Add field with location in the atlas.
        annot_name: Zeroes medial wall using annotation.
        curvature_fname: Curvature file name.
        canonical_name: Use surface for canonical properties.
        inflated: Use inflated surface for initial alignment.
        inflated_name: Uses this name for inflated surface for initial\
            alignment.
        label_file: Specify a manual label to align with atlas label.
        orig_name: Use this for original properties.
        overlay_values: Adds a variable to the atlas from overlay file,\
            smoothing it specified number of times.
        overlay_dir: Changes overlay path.
        starting_reg_fname: Start registration with coordinates from file.
        jacobian_fname: Write out jacobian of mapping to the specified file.
        n_averages: Set the number of averages.
        adaptive: Use adaptive time step integration.
        l_area: Sets l_area parameter.
        l_corr: Sets the l_corr parameter.
        curvature_flag: Use smoothwm curvature for final alignment.
        l_dist: Specify distance term.
        dt_value: Sets momentum with specified dt.
        dt_decrease: Set decrease for dt.
        dt_increase: Set increase for dt.
        l_external: Sets l_external parameter.
        error_ratio: Sets error ratio.
        initial_flag: Use initial registration.
        l_laplacian: Sets l_laplacian.
        line_min: Integrate using line minimization.
        momentum: Chooses integration_type = INTEGRATE_MOMENTUM and sets\
            momentum value.
        max_degrees: Set max angle for search.
        median: Uses median normalization (instead of mean).
        min_degrees: Set min angle for search.
        multi_scale: Use multi_scale scales for morphing.
        n_iterations: Sets number of iterations.
        n_angles: Set number of angles/search per scale.
        neighborhood_size: Use neighborhood size specified.
        l_nlarea: Sets l_nlarea parameter.
        no_curv: Do not use smoothwm curvature for final alignment.
        no_normalization: Disables normalization.
        no_rotation: Disables initial rigid alignment.
        no_sulc: Disables initial sulc alignment.
        num_surfaces: Use specified number of surfaces/curvatures for\
            alignment.
        overlay_corr: Sets overlay correlation coefficient.
        max_passes: Limit unfolding to specified passes.
        l_parea: Sets l_parea parameter.
        remove_negative: Remove negative triangles with iterative smoothing if\
            non-zero.
        reverse: Mirror image reverse brain before morphing.
        rotate_values: Rotates brain by specified angles.
        registration_file: Extract rotational components from registration\
            file.
        scale: Scales distances by the specified value.
        search_flag: Integrate with binary search line minimization.
        spring_value: Sets the spring parameter.
        tolerance: Specifies tolerance.
        topology_flag: Preserves the topology of positive area triangles.
        vnum: Set neighborhood parameters.
        vsmooth: Use space/time varying smoothness weighting.
        write_iterations: Set number of write iterations.
        gdiag_no: Supplies a vertex number for diagnostics.
        vector_flag: Prints help for Multiframe mode, listing field names and\
            numbers.
        threads: Set number of OMP threads.
        version_flag: Print the version number.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisRegisterOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_REGISTER_METADATA)
    cargs = []
    cargs.append("mris_register")
    cargs.append(execution.input_file(surf_fname))
    cargs.append(execution.input_file(target))
    cargs.append(out_fname)
    if one_flag:
        cargs.append("-1")
    if addframe is not None:
        cargs.extend([
            "-addframe",
            addframe
        ])
    if annot_name is not None:
        cargs.extend([
            "-annot",
            annot_name
        ])
    if curvature_fname is not None:
        cargs.extend([
            "-C",
            execution.input_file(curvature_fname)
        ])
    if canonical_name is not None:
        cargs.extend([
            "-canon",
            canonical_name
        ])
    if inflated:
        cargs.append("-inflated")
    if inflated_name is not None:
        cargs.extend([
            "-infname",
            inflated_name
        ])
    if label_file is not None:
        cargs.extend([
            "-L",
            label_file
        ])
    if orig_name is not None:
        cargs.extend([
            "-O",
            orig_name
        ])
    if overlay_values is not None:
        cargs.extend([
            "-overlay",
            overlay_values
        ])
    if overlay_dir is not None:
        cargs.extend([
            "-overlay-dir",
            overlay_dir
        ])
    if starting_reg_fname is not None:
        cargs.extend([
            "-sreg",
            execution.input_file(starting_reg_fname)
        ])
    if jacobian_fname is not None:
        cargs.extend([
            "-jacobian",
            jacobian_fname
        ])
    if n_averages is not None:
        cargs.extend([
            "-A",
            str(n_averages)
        ])
    if adaptive:
        cargs.append("-adaptive")
    if l_area is not None:
        cargs.extend([
            "-area",
            str(l_area)
        ])
    if l_corr is not None:
        cargs.extend([
            "-corr",
            str(l_corr)
        ])
    if curvature_flag:
        cargs.append("-curv")
    if l_dist is not None:
        cargs.extend([
            "-dist",
            str(l_dist)
        ])
    if dt_value is not None:
        cargs.extend([
            "-dt",
            str(dt_value)
        ])
    if dt_decrease is not None:
        cargs.extend([
            "-dt_dec",
            str(dt_decrease)
        ])
    if dt_increase is not None:
        cargs.extend([
            "-dt_inc",
            str(dt_increase)
        ])
    if l_external is not None:
        cargs.extend([
            "-E",
            str(l_external)
        ])
    if error_ratio is not None:
        cargs.extend([
            "-error_ratio",
            str(error_ratio)
        ])
    if initial_flag:
        cargs.append("-init")
    if l_laplacian is not None:
        cargs.extend([
            "-lap",
            str(l_laplacian)
        ])
    if line_min:
        cargs.append("-lm")
    if momentum is not None:
        cargs.extend([
            "-M",
            str(momentum)
        ])
    if max_degrees is not None:
        cargs.extend([
            "-max_degrees",
            str(max_degrees)
        ])
    if median:
        cargs.append("-median")
    if min_degrees is not None:
        cargs.extend([
            "-min_degrees",
            str(min_degrees)
        ])
    if multi_scale is not None:
        cargs.extend([
            "-multi_scale",
            str(multi_scale)
        ])
    if n_iterations is not None:
        cargs.extend([
            "-N",
            str(n_iterations)
        ])
    if n_angles is not None:
        cargs.extend([
            "-nangles",
            str(n_angles)
        ])
    if neighborhood_size is not None:
        cargs.extend([
            "-nbrs",
            str(neighborhood_size)
        ])
    if l_nlarea is not None:
        cargs.extend([
            "-nlarea",
            str(l_nlarea)
        ])
    if no_curv:
        cargs.append("-nocurv")
    if no_normalization:
        cargs.append("-nonorm")
    if no_rotation:
        cargs.append("-norot")
    if no_sulc:
        cargs.append("-nosulc")
    if num_surfaces is not None:
        cargs.extend([
            "-nsurfaces",
            str(num_surfaces)
        ])
    if overlay_corr is not None:
        cargs.extend([
            "-ocorr",
            str(overlay_corr)
        ])
    if max_passes is not None:
        cargs.extend([
            "-P",
            str(max_passes)
        ])
    if l_parea is not None:
        cargs.extend([
            "-parea",
            str(l_parea)
        ])
    if remove_negative is not None:
        cargs.extend([
            "-remove_negative",
            str(remove_negative)
        ])
    if reverse:
        cargs.append("-reverse")
    if rotate_values is not None:
        cargs.extend([
            "-rotate",
            rotate_values
        ])
    if registration_file is not None:
        cargs.extend([
            "-reg",
            execution.input_file(registration_file)
        ])
    if scale is not None:
        cargs.extend([
            "-S",
            str(scale)
        ])
    if search_flag:
        cargs.append("-search")
    if spring_value is not None:
        cargs.extend([
            "-spring",
            str(spring_value)
        ])
    if tolerance is not None:
        cargs.extend([
            "-tol",
            str(tolerance)
        ])
    if topology_flag:
        cargs.append("-topology")
    if vnum is not None:
        cargs.extend([
            "-vnum",
            vnum
        ])
    if vsmooth:
        cargs.append("-vsmooth")
    if write_iterations is not None:
        cargs.extend([
            "-W",
            str(write_iterations)
        ])
    if gdiag_no is not None:
        cargs.extend([
            "-V",
            str(gdiag_no)
        ])
    if vector_flag:
        cargs.append("-vector")
    if threads is not None:
        cargs.extend([
            "-threads",
            str(threads)
        ])
    if version_flag:
        cargs.append("--version")
    ret = MrisRegisterOutputs(
        root=execution.output_file("."),
        output_surface_file=execution.output_file(out_fname),
        jacobian_output=execution.output_file(jacobian_fname) if (jacobian_fname is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_REGISTER_METADATA",
    "MrisRegisterOutputs",
    "mris_register",
]
