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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_NORMALIZE_TP2_METADATA = Metadata(
    id="aee73f5df022fe02e7fc4d5e4771e952936204f3.boutiques",
    name="mri_normalize_tp2",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriNormalizeTp2Outputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_normalize_tp2(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_normalized_vol: OutputPathType
    """The resulting normalized volume"""


def mri_normalize_tp2(
    input_vol: InputPathType,
    normalized_vol: str,
    t1_volume: InputPathType | None = None,
    mask1: InputPathType | None = None,
    mask2: InputPathType | None = None,
    threshold: float | None = None,
    ctrl: InputPathType | None = None,
    xform: InputPathType | None = None,
    invert_flag: bool = False,
    lta_src: InputPathType | None = None,
    lta_dst: InputPathType | None = None,
    runner: Runner | None = None,
) -> MriNormalizeTp2Outputs:
    """
    Normalize the input volume using control points of tp1 to help normalize tp2.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_vol: Input volume to be normalized.
        normalized_vol: Output normalized volume.
        t1_volume: T1 volume for tp1 where normalization is applied.
        mask1: Brain mask for tp1, mapped to tp2 via the xform.
        mask2: Brain mask for tp2, mapped to tp1 via the inverse xform.
        threshold: Threshold for background (default = 1.0).
        ctrl: Control point volume for tp1.
        xform: LTA transform that aligns tp1 to tp2.
        invert_flag: Reversely apply -xform.
        lta_src: Source volume for -xform if not available from the xform file.
        lta_dst: Target volume for -xform if not available from the xform file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriNormalizeTp2Outputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_NORMALIZE_TP2_METADATA)
    cargs = []
    cargs.append("mri_normalize_tp2")
    cargs.append(execution.input_file(input_vol))
    cargs.append(normalized_vol)
    if t1_volume is not None:
        cargs.extend([
            "-T1",
            execution.input_file(t1_volume)
        ])
    if mask1 is not None:
        cargs.extend([
            "-mask1",
            execution.input_file(mask1)
        ])
    if mask2 is not None:
        cargs.extend([
            "-mask2",
            execution.input_file(mask2)
        ])
    if threshold is not None:
        cargs.extend([
            "-threshold",
            str(threshold)
        ])
    if ctrl is not None:
        cargs.extend([
            "-ctrl",
            execution.input_file(ctrl)
        ])
    if xform is not None:
        cargs.extend([
            "-xform",
            execution.input_file(xform)
        ])
    if invert_flag:
        cargs.append("-invert")
    if lta_src is not None:
        cargs.extend([
            "-lta_src",
            execution.input_file(lta_src)
        ])
    if lta_dst is not None:
        cargs.extend([
            "-lta_dst",
            execution.input_file(lta_dst)
        ])
    ret = MriNormalizeTp2Outputs(
        root=execution.output_file("."),
        output_normalized_vol=execution.output_file(normalized_vol),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_NORMALIZE_TP2_METADATA",
    "MriNormalizeTp2Outputs",
    "mri_normalize_tp2",
]
