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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_NWARP_ADJUST_METADATA = Metadata(
    id="0c3ecbaf201c4034c9ca75f6bc8b7c5f5190cfaf.boutiques",
    name="3dNwarpAdjust",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dNwarpAdjustOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_nwarp_adjust(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_brik: OutputPathType | None
    """Output mean dataset BRIK file"""
    output_head: OutputPathType | None
    """Output mean dataset HEAD file"""


def v_3d_nwarp_adjust(
    input_warps: list[InputPathType],
    source_datasets: list[InputPathType] | None = None,
    output_prefix: str | None = None,
    runner: Runner | None = None,
) -> V3dNwarpAdjustOutputs:
    """
    Program to adjust 3D warp datasets by composing them with the inverse of their
    average, optionally warping input datasets and generating an output mean
    dataset.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_warps: List of input 3D warp datasets (at least 5).
        source_datasets: List of input 3D datasets to be warped by the adjusted\
            warp datasets. There must be exactly as many of these datasets as there\
            are input warps.
        output_prefix: Prefix for the output mean dataset (only needed if the\
            '-source' option is also given).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dNwarpAdjustOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_NWARP_ADJUST_METADATA)
    cargs = []
    cargs.append("3dNwarpAdjust")
    cargs.extend([
        "-nwarp",
        *[execution.input_file(f) for f in input_warps]
    ])
    if source_datasets is not None:
        cargs.extend([
            "-source",
            *[execution.input_file(f) for f in source_datasets]
        ])
    if output_prefix is not None:
        cargs.extend([
            "-prefix",
            output_prefix
        ])
    ret = V3dNwarpAdjustOutputs(
        root=execution.output_file("."),
        output_brik=execution.output_file(output_prefix + "+tlrc.BRIK") if (output_prefix is not None) else None,
        output_head=execution.output_file(output_prefix + "+tlrc.HEAD") if (output_prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dNwarpAdjustOutputs",
    "V_3D_NWARP_ADJUST_METADATA",
    "v_3d_nwarp_adjust",
]
