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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_EASYREG_METADATA = Metadata(
    id="a8597c7c31eb3d0db090b8c58b2eb2709f8b9b2d.boutiques",
    name="mri_easyreg",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriEasyregOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_easyreg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    registered_reference_output: OutputPathType
    """Output registered reference image"""
    registered_floating_output: OutputPathType
    """Output registered floating image"""
    forward_field_output: OutputPathType
    """Output forward field file"""
    inverse_field_output: OutputPathType
    """Output inverse field file"""


def mri_easyreg(
    reference_image: InputPathType,
    floating_image: InputPathType,
    reference_segmentation: InputPathType | None = None,
    floating_segmentation: InputPathType | None = None,
    registered_reference: InputPathType | None = None,
    registered_floating: InputPathType | None = None,
    forward_field: InputPathType | None = None,
    inverse_field: InputPathType | None = None,
    affine_only: bool = False,
    threads: float | None = None,
    runner: Runner | None = None,
) -> MriEasyregOutputs:
    """
    EasyReg: deep learning registration simple and easy.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        reference_image: Reference image.
        floating_image: Floating image.
        reference_segmentation: Reference SynthSeg segmentation (will be\
            created if it does not exist).
        floating_segmentation: Floating SynthSeg segmentation (will be created\
            if it does not exist).
        registered_reference: (optional) Registered reference.
        registered_floating: (optional) Registered floating images (in space of\
            reference).
        forward_field: (optional) Forward field.
        inverse_field: (optional) Inverse field.
        affine_only: (optional) Skips nonlinear part.
        threads: (optional) Number of cores to be used. Default is 1. You can\
            use -1 to use all available cores.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriEasyregOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_EASYREG_METADATA)
    cargs = []
    cargs.append("mri_easyreg")
    cargs.extend([
        "--ref",
        execution.input_file(reference_image)
    ])
    if reference_segmentation is not None:
        cargs.extend([
            "--ref_seg",
            execution.input_file(reference_segmentation)
        ])
    cargs.extend([
        "--flo",
        execution.input_file(floating_image)
    ])
    if floating_segmentation is not None:
        cargs.extend([
            "--flo_seg",
            execution.input_file(floating_segmentation)
        ])
    if registered_reference is not None:
        cargs.extend([
            "--ref_reg",
            execution.input_file(registered_reference)
        ])
    if registered_floating is not None:
        cargs.extend([
            "--flo_reg",
            execution.input_file(registered_floating)
        ])
    if forward_field is not None:
        cargs.extend([
            "--fwd_field",
            execution.input_file(forward_field)
        ])
    if inverse_field is not None:
        cargs.extend([
            "--bak_field",
            execution.input_file(inverse_field)
        ])
    if affine_only:
        cargs.append("--affine_only")
    if threads is not None:
        cargs.extend([
            "--threads",
            str(threads)
        ])
    ret = MriEasyregOutputs(
        root=execution.output_file("."),
        registered_reference_output=execution.output_file("registered_reference.nii.gz"),
        registered_floating_output=execution.output_file("registered_floating.nii.gz"),
        forward_field_output=execution.output_file("forward_field.nii.gz"),
        inverse_field_output=execution.output_file("inverse_field.nii.gz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_EASYREG_METADATA",
    "MriEasyregOutputs",
    "mri_easyreg",
]
