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

import typing
import pathlib
from styxdefs import *
import dataclasses

BIASFIELD_METADATA = Metadata(
    id="c8391deeed6d412683183d406717be9cba1af3b4.boutiques",
    name="biasfield",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class BiasfieldOutputs(typing.NamedTuple):
    """
    Output object returned when calling `biasfield(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    biasfield_output: OutputPathType
    """Generated bias field in the subject MRI directory"""
    rawavg_cor_norm: OutputPathType
    """The rawavg.mgz in 256^3, 1mm^3 space with the bias field removed"""


def biasfield(
    subject: str,
    tmpdir: str | None = None,
    no_cleanup: bool = False,
    help_: bool = False,
    debug: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> BiasfieldOutputs:
    """
    Computes the bias field by dividing the (unconformed) orig.mgz by the norm.mgz.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: Subject identifier.
        tmpdir: Temporary directory.
        no_cleanup: Prevent cleanup of temporary files.
        help_: Display help information.
        debug: Enable debugging mode.
        version: Display script version info.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BiasfieldOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(BIASFIELD_METADATA)
    cargs = []
    cargs.append("biasfield")
    cargs.extend([
        "--s",
        subject
    ])
    if tmpdir is not None:
        cargs.extend([
            "--tmp",
            tmpdir
        ])
    if no_cleanup:
        cargs.append("--nocleanup")
    if help_:
        cargs.append("--help")
    if debug:
        cargs.append("--debug")
    if version:
        cargs.append("--version")
    ret = BiasfieldOutputs(
        root=execution.output_file("."),
        biasfield_output=execution.output_file("biasfield.mgz"),
        rawavg_cor_norm=execution.output_file("rawavg.cor.norm.mgz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "BIASFIELD_METADATA",
    "BiasfieldOutputs",
    "biasfield",
]
