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

import typing
import pathlib
from styxdefs import *
import dataclasses

SWI_PREPROCESS_METADATA = Metadata(
    id="9c092f99975ad21400c19882fe546f899bd6d1ce.boutiques",
    name="swi_preprocess",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class SwiPreprocessOutputs(typing.NamedTuple):
    """
    Output object returned when calling `swi_preprocess(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_magnitude_file: OutputPathType
    """Output magnitude file in NIfTI format."""
    output_phase_file: OutputPathType
    """Output phase file in NIfTI format."""


def swi_preprocess(
    scanner: typing.Literal["ge", "siemens", "philips"],
    out_magnitude: str,
    out_phase: str,
    ge_file: InputPathType | None = None,
    philips_file: InputPathType | None = None,
    siemens_magnitude: InputPathType | None = None,
    siemens_phase: InputPathType | None = None,
    runner: Runner | None = None,
) -> SwiPreprocessOutputs:
    """
    Pre-process the Susceptibility-weighted images and write out nifti files for
    feeding into PRELUDE (Phase Unwrapping Library of FSL).
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        scanner: Name of the scanner (one of ge, siemens or philips).
        out_magnitude: Name of the output magnitude file after preprocessing.\
            Ensure it has a .nii suffix.
        out_phase: Name of the output phase file after preprocessing. Ensure it\
            has a .nii suffix.
        ge_file: Name of the input GE file (only compatible with --scanner ge\
            option).
        philips_file: Name of the input Philips file (only compatible with\
            --scanner philips option).
        siemens_magnitude: Name of the input Siemens magnitude file (only\
            compatible with --scanner siemens option).
        siemens_phase: Name of the input Siemens phase file (only compatible\
            with --scanner siemens option).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SwiPreprocessOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SWI_PREPROCESS_METADATA)
    cargs = []
    cargs.append("swi_preprocess")
    cargs.extend([
        "--scanner",
        scanner
    ])
    if ge_file is not None:
        cargs.extend([
            "--ge_file",
            execution.input_file(ge_file)
        ])
    if philips_file is not None:
        cargs.extend([
            "--philips_file",
            execution.input_file(philips_file)
        ])
    if siemens_magnitude is not None:
        cargs.extend([
            "--siemens_mag",
            execution.input_file(siemens_magnitude)
        ])
    if siemens_phase is not None:
        cargs.extend([
            "--siemens_phase",
            execution.input_file(siemens_phase)
        ])
    cargs.extend([
        "--out_magnitude",
        out_magnitude
    ])
    cargs.extend([
        "--out_phase",
        out_phase
    ])
    ret = SwiPreprocessOutputs(
        root=execution.output_file("."),
        output_magnitude_file=execution.output_file(out_magnitude),
        output_phase_file=execution.output_file(out_phase),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SWI_PREPROCESS_METADATA",
    "SwiPreprocessOutputs",
    "swi_preprocess",
]
