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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_EXVIVO_NORM_METADATA = Metadata(
    id="a88bc50afe4bde5d431a45ef570ba7c5a89a8c36.boutiques",
    name="mri_exvivo_norm",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriExvivoNormOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_exvivo_norm(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_volume: OutputPathType
    """Output MRI volume"""


def mri_exvivo_norm(
    input_volume: InputPathType,
    output_volume: str,
    hemi: str,
    prediction_volume: str | None = None,
    normalized_volume: str | None = None,
    freeview: bool = False,
    normalize_output_mean: bool = False,
    write_normalization_rounds: bool = False,
    upper_threshold: float | None = None,
    bias_field_sigma: float | None = None,
    normalization_rounds: float | None = None,
    multichannel: bool = False,
    model_file: InputPathType | None = None,
    weights_file: InputPathType | None = None,
    gpu_number: float | None = None,
    runner: Runner | None = None,
) -> MriExvivoNormOutputs:
    """
    MRI Ex Vivo Normalization Tool.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_volume: Input MRI volume.
        output_volume: Output MRI volume.
        hemi: Hemi to process.
        prediction_volume: Write prediction volume.
        normalized_volume: Write normalized volume.
        freeview: Bring up freeview to show results.
        normalize_output_mean: Normalize output mean to match input mean.
        write_normalization_rounds: Write normalization results after each\
            round.
        upper_threshold: Specify threshold to erase above.
        bias_field_sigma: Sigma to smooth bias field.
        normalization_rounds: Number of rounds of iterative normalization to\
            apply.
        multichannel: Specify that data has multiple channels.
        model_file: Use alternative model file.
        weights_file: Alternative weights filename.
        gpu_number: GPU number - if not supplied, CPU is used.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriExvivoNormOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_EXVIVO_NORM_METADATA)
    cargs = []
    cargs.append("mri_exvivo_norm")
    cargs.extend([
        "-i",
        execution.input_file(input_volume)
    ])
    cargs.extend([
        "-o",
        output_volume
    ])
    cargs.extend([
        "--hemi",
        hemi
    ])
    if prediction_volume is not None:
        cargs.extend([
            "--pred",
            prediction_volume
        ])
    if normalized_volume is not None:
        cargs.extend([
            "--norm",
            normalized_volume
        ])
    if freeview:
        cargs.append("--fv")
    if normalize_output_mean:
        cargs.append("--norm_mean")
    if write_normalization_rounds:
        cargs.append("--write_rounds")
    if upper_threshold is not None:
        cargs.extend([
            "--uthresh",
            str(upper_threshold)
        ])
    if bias_field_sigma is not None:
        cargs.extend([
            "--sigma",
            str(bias_field_sigma)
        ])
    if normalization_rounds is not None:
        cargs.extend([
            "--nrounds",
            str(normalization_rounds)
        ])
    if multichannel:
        cargs.append("--multichannel")
    if model_file is not None:
        cargs.extend([
            "--model",
            execution.input_file(model_file)
        ])
    if weights_file is not None:
        cargs.extend([
            "--wts",
            execution.input_file(weights_file)
        ])
    if gpu_number is not None:
        cargs.extend([
            "--gpu",
            str(gpu_number)
        ])
    ret = MriExvivoNormOutputs(
        root=execution.output_file("."),
        output_volume=execution.output_file(output_volume),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_EXVIVO_NORM_METADATA",
    "MriExvivoNormOutputs",
    "mri_exvivo_norm",
]
