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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_FIELDSIGN_METADATA = Metadata(
    id="ab824af01a699004ad68775dafe2a065f72a9634.boutiques",
    name="mri_fieldsign",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriFieldsignOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_fieldsign(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def mri_fieldsign(
    fieldsign_file: str,
    eccen_values: list[float],
    polar_values: list[float],
    subject: str,
    hemisphere: str,
    patch_file: str | None = None,
    occip_flag: bool = False,
    sphere_flag: bool = False,
    fwhm: float | None = None,
    nsmooth: float | None = None,
    reverse_flag: bool = False,
    old_flag: bool = False,
    eccen_rotation: float | None = None,
    polar_rotation: float | None = None,
    eccen_output: float | None = None,
    polar_output: float | None = None,
    eccen_sfa_file: InputPathType | None = None,
    polar_sfa_file: InputPathType | None = None,
    sfa_dir: str | None = None,
    sfa_true_flag: bool = False,
    debug_flag: bool = False,
    checkopts_flag: bool = False,
    help_flag: bool = False,
    version_flag: bool = False,
    runner: Runner | None = None,
) -> MriFieldsignOutputs:
    """
    Field Sign Mapping Tool from FreeSurfer.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        fieldsign_file: Output field sign file.
        eccen_values: Eccentricity values (real and imaginary).
        polar_values: Polar values (real and imaginary).
        subject: Subject identifier.
        hemisphere: Hemisphere to process.
        patch_file: Patch file, without hemi.
        occip_flag: Use occipital patch (patchfile = occip.patch.flat).
        sphere_flag: Use spherical surface instead of patch.
        fwhm: Full-width at half-maximum (mm).
        nsmooth: Number of smoothing steps.
        reverse_flag: Reverse sign.
        old_flag: Use old FS estimation code.
        eccen_rotation: Rotate eccentricity by rotangle degrees.
        polar_rotation: Rotate polar by rotangle degrees.
        eccen_output: Output eccentricity angle.
        polar_output: Output polar angle.
        eccen_sfa_file: Eccentricity self-frequency average file.
        polar_sfa_file: Polar self-frequency average file.
        sfa_dir: SFA directory.
        sfa_true_flag: Use true real and imaginary (affects small smoothing).
        debug_flag: Turn on debugging.
        checkopts_flag: Check options and exit.
        help_flag: Display help information.
        version_flag: Print version and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriFieldsignOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_FIELDSIGN_METADATA)
    cargs = []
    cargs.append("mri_fieldsign")
    cargs.extend([
        "--fs",
        fieldsign_file
    ])
    cargs.extend([
        "--eccen",
        *map(str, eccen_values)
    ])
    cargs.extend([
        "--polar",
        *map(str, polar_values)
    ])
    cargs.extend([
        "--s",
        subject
    ])
    cargs.extend([
        "--hemi",
        hemisphere
    ])
    if patch_file is not None:
        cargs.extend([
            "--patch",
            patch_file
        ])
    if occip_flag:
        cargs.append("--occip")
    if sphere_flag:
        cargs.append("--sphere")
    if fwhm is not None:
        cargs.extend([
            "--fwhm",
            str(fwhm)
        ])
    if nsmooth is not None:
        cargs.extend([
            "--nsmooth",
            str(nsmooth)
        ])
    if reverse_flag:
        cargs.append("--rev")
    if old_flag:
        cargs.append("--old")
    if eccen_rotation is not None:
        cargs.extend([
            "--eccen-rot",
            str(eccen_rotation)
        ])
    if polar_rotation is not None:
        cargs.extend([
            "--polar-rot",
            str(polar_rotation)
        ])
    if eccen_output is not None:
        cargs.extend([
            "--eccen-out",
            str(eccen_output)
        ])
    if polar_output is not None:
        cargs.extend([
            "--polar-out",
            str(polar_output)
        ])
    if eccen_sfa_file is not None:
        cargs.extend([
            "--eccen-sfa",
            execution.input_file(eccen_sfa_file)
        ])
    if polar_sfa_file is not None:
        cargs.extend([
            "--polar-sfa",
            execution.input_file(polar_sfa_file)
        ])
    if sfa_dir is not None:
        cargs.extend([
            "--sfa",
            sfa_dir
        ])
    if sfa_true_flag:
        cargs.append("--sfa-true")
    if debug_flag:
        cargs.append("--debug")
    if checkopts_flag:
        cargs.append("--checkopts")
    if help_flag:
        cargs.append("--help")
    if version_flag:
        cargs.append("--version")
    ret = MriFieldsignOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_FIELDSIGN_METADATA",
    "MriFieldsignOutputs",
    "mri_fieldsign",
]
