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

import typing
import pathlib
from styxdefs import *
import dataclasses

PREPARE_FIELDMAP_METADATA = Metadata(
    id="dad6607f2a51e3a9698a27e3d3875a0624021638.boutiques",
    name="prepare_fieldmap",
    package="fsl",
    container_image_tag="mcin/fsl:6.0.5",
)


class PrepareFieldmapOutputs(typing.NamedTuple):
    """
    Output object returned when calling `prepare_fieldmap(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    out_fieldmap_outfile: OutputPathType | None
    """Output name for prepared fieldmap."""


def prepare_fieldmap(
    in_phase: InputPathType,
    in_magnitude: InputPathType,
    delta_te: float = 2.46,
    scanner: str | None = "SIEMENS",
    out_fieldmap: InputPathType | None = None,
    nocheck: bool = False,
    output_type: typing.Literal["NIFTI", "NIFTI_PAIR", "NIFTI_GZ", "NIFTI_PAIR_GZ"] | None = None,
    runner: Runner | None = None,
) -> PrepareFieldmapOutputs:
    """
    
    Interface for the fsl_prepare_fieldmap script (FSL 5.0)
    Prepares a fieldmap suitable for FEAT from SIEMENS data - saves output in
    rad/s format (e.g. ```fsl_prepare_fieldmap SIEMENS
    images_3_gre_field_mapping images_4_gre_field_mapping fmap_rads 2.65```).
    
    Author: Nipype (interface)
    
    Args:
        in_phase: Phase difference map, in siemens format range from 0-4096 or\
            0-8192).
        in_magnitude: Magnitude difference map, brain extracted.
        delta_te: Echo time difference of the fieldmap sequence in ms. (usually\
            2.46ms in siemens).
        scanner: Must be siemens.
        out_fieldmap: Output name for prepared fieldmap.
        nocheck: Do not perform sanity checks for image size/range/dimensions.
        output_type: 'nifti' or 'nifti_pair' or 'nifti_gz' or 'nifti_pair_gz'.\
            Fsl output type.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `PrepareFieldmapOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(PREPARE_FIELDMAP_METADATA)
    cargs = []
    cargs.append("PrepareFieldmap")
    cargs.append(str(delta_te))
    if scanner is not None:
        cargs.append(scanner)
    cargs.append(execution.input_file(in_phase))
    cargs.append(execution.input_file(in_magnitude))
    if out_fieldmap is not None:
        cargs.append(execution.input_file(out_fieldmap))
    if nocheck:
        cargs.append("--nocheck")
    if output_type is not None:
        cargs.append(output_type)
    ret = PrepareFieldmapOutputs(
        root=execution.output_file("."),
        out_fieldmap_outfile=execution.output_file(pathlib.Path(out_fieldmap).name) if (out_fieldmap is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "PREPARE_FIELDMAP_METADATA",
    "PrepareFieldmapOutputs",
    "prepare_fieldmap",
]
