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

import typing
import pathlib
from styxdefs import *
import dataclasses

ANTS_N4_BIAS_FIELD_CORRECTION_FS_METADATA = Metadata(
    id="8e3aa79a90f40d521916471804f2c3ad2b5aa209.boutiques",
    name="AntsN4BiasFieldCorrectionFs",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class AntsN4BiasFieldCorrectionFsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `ants_n4_bias_field_correction_fs(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    corrected_output_file: OutputPathType
    """Corrected volume output file."""


def ants_n4_bias_field_correction_fs(
    input_file: InputPathType,
    output_file: InputPathType,
    mask_file: InputPathType | None = None,
    shrink_factor: int | None = 4,
    iterations: list[float] | None = None,
    output_dtype: str | None = "float",
    replace_zeros: str | None = None,
    runner: Runner | None = None,
) -> AntsN4BiasFieldCorrectionFsOutputs:
    """
    Runs N4 (nonparameteric, nonuniform normalization) retrospective bias correction
    on an image. This program wraps the AntsN4BiasFieldCorrection utility available
    in the ANTs package.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_file: Input volume file.
        output_file: Corrected output volume file.
        mask_file: Use image mask during correction.
        shrink_factor: Resample factor to decrease computation time. Default is\
            4.
        iterations: Number of resolutions and max iterations per resolution.\
            Default is `50 50 50 50`, which indicates 4 fitting levels with 50\
            iterations each.
        output_dtype: Corrected output data type. Can be float, uchar, or int.\
            Default is float.
        replace_zeros: Replace 0s with offset + scale*rand(). Values will be\
            remasked in the output if remask=1.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AntsN4BiasFieldCorrectionFsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ANTS_N4_BIAS_FIELD_CORRECTION_FS_METADATA)
    cargs = []
    cargs.append("AntsN4BiasFieldCorrectionFs")
    cargs.extend([
        "-i",
        execution.input_file(input_file)
    ])
    cargs.extend([
        "-o",
        execution.input_file(output_file)
    ])
    if mask_file is not None:
        cargs.extend([
            "-m",
            execution.input_file(mask_file)
        ])
    if shrink_factor is not None:
        cargs.extend([
            "-s",
            str(shrink_factor)
        ])
    if iterations is not None:
        cargs.extend([
            "-t",
            *map(str, iterations)
        ])
    if output_dtype is not None:
        cargs.extend([
            "-d",
            output_dtype
        ])
    if replace_zeros is not None:
        cargs.extend([
            "-r",
            replace_zeros
        ])
    ret = AntsN4BiasFieldCorrectionFsOutputs(
        root=execution.output_file("."),
        corrected_output_file=execution.output_file(pathlib.Path(output_file).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ANTS_N4_BIAS_FIELD_CORRECTION_FS_METADATA",
    "AntsN4BiasFieldCorrectionFsOutputs",
    "ants_n4_bias_field_correction_fs",
]
