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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_SYNTHMORPH_METADATA = Metadata(
    id="cca34624b81822a73cc5fffde808c9e91f121f25.boutiques",
    name="mri_synthmorph",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriSynthmorphOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_synthmorph(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    moved_output_file: OutputPathType | None
    """The registered output image file, resulting from the operation."""
    transform_output_file: OutputPathType
    """Transform file resulting from registration."""


def mri_synthmorph(
    moving_image: InputPathType,
    fixed_image: InputPathType,
    moved_output: InputPathType | None = None,
    transform_output: InputPathType | None = None,
    header_only: bool = False,
    transformation_model: typing.Literal["deform", "affine", "rigid"] | None = "deform",
    init_transform: InputPathType | None = None,
    threads: float | None = None,
    gpu_flag: bool = False,
    smooth: float | None = 1,
    extent: float | None = 256,
    model_weights: InputPathType | None = None,
    inspect_directory: str | None = None,
    runner: Runner | None = None,
) -> MriSynthmorphOutputs:
    """
    SynthMorph is a deep-learning tool for brain-specific MRI image registration
    without preprocessing.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        moving_image: The moving input image, which will be registered to the\
            fixed image.
        fixed_image: The fixed input image, which is used as the reference for\
            registration.
        moved_output: The resulting image after registration.
        transform_output: Output transform file for registration. Can be a text\
            file for linear or an image file for deformable registration.
        header_only: Adjust the voxel-to-world matrix instead of resampling.\
            Linear registration only.
        transformation_model: Specifies the registration transformation model.\
            Options include 'deform', 'affine', and 'rigid'.
        init_transform: Initial linear transform for registration.
        threads: Number of TensorFlow threads to utilize. Defaults to the\
            number of cores.
        gpu_flag: Utilize the GPU specified by CUDA_VISIBLE_DEVICES or GPU 0 if\
            unset or empty.
        smooth: Regularization parameter for deformable registration. Higher\
            values indicate smoother displacement fields.
        extent: Isotropic extent of the registration space in unit voxels.
        model_weights: Alternative model weights as an H5 file.
        inspect_directory: Save model inputs resampled into network space for\
            inspection.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriSynthmorphOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_SYNTHMORPH_METADATA)
    cargs = []
    cargs.append("mri_synthmorph")
    cargs.append(execution.input_file(moving_image))
    cargs.append(execution.input_file(fixed_image))
    if moved_output is not None:
        cargs.extend([
            "-o",
            execution.input_file(moved_output)
        ])
    if transform_output is not None:
        cargs.extend([
            "-t",
            execution.input_file(transform_output)
        ])
    if header_only:
        cargs.append("-H")
    if transformation_model is not None:
        cargs.extend([
            "-m",
            transformation_model
        ])
    if init_transform is not None:
        cargs.extend([
            "-i",
            execution.input_file(init_transform)
        ])
    if threads is not None:
        cargs.extend([
            "-j",
            str(threads)
        ])
    if gpu_flag:
        cargs.append("-g")
    if smooth is not None:
        cargs.extend([
            "-s",
            str(smooth)
        ])
    if extent is not None:
        cargs.extend([
            "-e",
            str(extent)
        ])
    if model_weights is not None:
        cargs.extend([
            "-w",
            execution.input_file(model_weights)
        ])
    if inspect_directory is not None:
        cargs.extend([
            "--inspect",
            inspect_directory
        ])
    ret = MriSynthmorphOutputs(
        root=execution.output_file("."),
        moved_output_file=execution.output_file(pathlib.Path(moved_output).name) if (moved_output is not None) else None,
        transform_output_file=execution.output_file("[TRANS_OUTPUT]"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_SYNTHMORPH_METADATA",
    "MriSynthmorphOutputs",
    "mri_synthmorph",
]
