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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_NORMALIZE_METADATA = Metadata(
    id="600d2e82bac484d0fa09b08fc06b759b58c55a5b.boutiques",
    name="mri_normalize",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriNormalizeOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_normalize(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_volume: OutputPathType
    """Normalized output volume"""
    controlpoints_output: OutputPathType
    """Output final control points as a volume, applicable only with -aseg"""


def mri_normalize(
    input_vol: InputPathType,
    output_vol: str,
    norm_iters: float | None = None,
    disable_1d: bool = False,
    nonmax_suppress: float | None = None,
    conform: bool = False,
    nonconform: bool = False,
    gentle: bool = False,
    control_points: InputPathType | None = None,
    fonly_control_points: InputPathType | None = None,
    lonly_labels: InputPathType | None = None,
    labels: InputPathType | None = None,
    write_volumes: str | None = None,
    intensity_above: float | None = None,
    intensity_below: float | None = None,
    intensity_gradient: float | None = None,
    prune: bool = False,
    no_gentle_cp: bool = False,
    mask_file: InputPathType | None = None,
    atlas_transform: str | None = None,
    noskull: bool = False,
    monkey: bool = False,
    nosnr: bool = False,
    sigma_smooth: float | None = None,
    aseg_file: InputPathType | None = None,
    debug_v: str | None = None,
    debug_d: str | None = None,
    renorm_vol: InputPathType | None = None,
    checknorm_vol: str | None = None,
    load_read_cp: str | None = None,
    cp_output_vol: InputPathType | None = None,
    surface_transform: str | None = None,
    seed_value: float | None = None,
    print_help: bool = False,
    runner: Runner | None = None,
) -> MriNormalizeOutputs:
    """
    Normalize the white-matter, optionally based on control points. The input volume
    is converted into a new volume where white matter image values all range around
    110.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_vol: Input MRI volume file.
        output_vol: Output MRI volume file.
        norm_iters: Use n 3D normalization iterations (default=2).
        disable_1d: Disable 1D normalization.
        nonmax_suppress: Turn non-maximum suppression on (1) or off (0) when\
            using interior of surfaces.
        conform: Interpolate and embed volume to be 256^3.
        nonconform: Do not conform the volume.
        gentle: Perform kinder gentler normalization.
        control_points: Use control points file (usually control.dat).
        fonly_control_points: Use only control points file.
        lonly_labels: Use only control points in label file.
        labels: Use control points in label file.
        write_volumes: Write control point (c) and bias field (b) volumes.
        intensity_above: Use control point with intensity above target\
            (default=25.0).
        intensity_below: Use control point with intensity below target\
            (default=10.0).
        intensity_gradient: Use max intensity/mm gradient (default=1.000).
        prune: Turn pruning of control points on/off (default=off).
        no_gentle_cp: Do not use gentle normalization with control points file.
        mask_file: Mask file to use.
        atlas_transform: Use atlas to exclude control points from being in\
            non-brain regions.
        noskull: Do not consider skull regions.
        monkey: Turns off 1D, sets num_3d_iter=1.
        nosnr: Disable SNR normalization.
        sigma_smooth: Smooth bias field with given sigma.
        aseg_file: Aseg file for processing.
        debug_v: For debugging.
        debug_d: For debugging.
        renorm_vol: Load volume and use all points in it that are exactly 110\
            as control points.
        checknorm_vol: Load volume and remove all control points that aren't in\
            [min max].
        load_read_cp: For reading control points and bias field.
        cp_output_vol: Output final control points as a volume (only with\
            -aseg).
        surface_transform: Normalize based on the skeleton of the interior of\
            the transformed surface.
        seed_value: Set random number generator to seed N.
        print_help: Print usage.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriNormalizeOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_NORMALIZE_METADATA)
    cargs = []
    cargs.append("mri_normalize")
    cargs.append(execution.input_file(input_vol))
    cargs.append(output_vol)
    if norm_iters is not None:
        cargs.extend([
            "-n",
            str(norm_iters)
        ])
    if disable_1d:
        cargs.append("-no1d")
    if nonmax_suppress is not None:
        cargs.extend([
            "-nonmax_suppress",
            str(nonmax_suppress)
        ])
    if conform:
        cargs.append("-conform")
    if nonconform:
        cargs.append("-noconform")
    if gentle:
        cargs.append("-gentle")
    if control_points is not None:
        cargs.extend([
            "-f",
            execution.input_file(control_points)
        ])
    if fonly_control_points is not None:
        cargs.extend([
            "-fonly",
            execution.input_file(fonly_control_points)
        ])
    if lonly_labels is not None:
        cargs.extend([
            "-lonly",
            execution.input_file(lonly_labels)
        ])
    if labels is not None:
        cargs.extend([
            "-label",
            execution.input_file(labels)
        ])
    if write_volumes is not None:
        cargs.extend([
            "-w",
            write_volumes
        ])
    if intensity_above is not None:
        cargs.extend([
            "-a",
            str(intensity_above)
        ])
    if intensity_below is not None:
        cargs.extend([
            "-b",
            str(intensity_below)
        ])
    if intensity_gradient is not None:
        cargs.extend([
            "-g",
            str(intensity_gradient)
        ])
    if prune:
        cargs.append("-prune")
    if no_gentle_cp:
        cargs.append("-no-gentle-cp")
    if mask_file is not None:
        cargs.extend([
            "-MASK",
            execution.input_file(mask_file)
        ])
    if atlas_transform is not None:
        cargs.extend([
            "-atlas",
            atlas_transform
        ])
    if noskull:
        cargs.append("-noskull")
    if monkey:
        cargs.append("-monkey")
    if nosnr:
        cargs.append("-nosnr")
    if sigma_smooth is not None:
        cargs.extend([
            "-sigma",
            str(sigma_smooth)
        ])
    if aseg_file is not None:
        cargs.extend([
            "-aseg",
            execution.input_file(aseg_file)
        ])
    if debug_v is not None:
        cargs.extend([
            "-v",
            debug_v
        ])
    if debug_d is not None:
        cargs.extend([
            "-d",
            debug_d
        ])
    if renorm_vol is not None:
        cargs.extend([
            "-renorm",
            execution.input_file(renorm_vol)
        ])
    if checknorm_vol is not None:
        cargs.extend([
            "-checknorm",
            checknorm_vol
        ])
    if load_read_cp is not None:
        cargs.extend([
            "-r",
            load_read_cp
        ])
    if cp_output_vol is not None:
        cargs.extend([
            "-c",
            execution.input_file(cp_output_vol)
        ])
    if surface_transform is not None:
        cargs.extend([
            "-surface",
            surface_transform
        ])
    if seed_value is not None:
        cargs.extend([
            "-seed",
            str(seed_value)
        ])
    if print_help:
        cargs.append("-u")
    ret = MriNormalizeOutputs(
        root=execution.output_file("."),
        output_volume=execution.output_file(output_vol),
        controlpoints_output=execution.output_file("controlpoints_volume.nii.gz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_NORMALIZE_METADATA",
    "MriNormalizeOutputs",
    "mri_normalize",
]
