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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_MATCH_METADATA = Metadata(
    id="776b6479db1702d65ad4f7fa5e0459ec4fc1c302.boutiques",
    name="3dMatch",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dMatchOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_match(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    ref_brik: OutputPathType
    """AFNI BRIK file with the same number of subbricks as the refset file, with
    highest weighted correlation."""
    ref_coeff_vals: OutputPathType
    """Text file recording original indices and coefficients."""
    in_brik: OutputPathType
    """AFNI BRIK file with the same number of subbricks as the inset file, with
    highest weighted correlation."""
    in_coeff_vals: OutputPathType
    """Text file recording original indices and coefficients."""


def v_3d_match(
    inset: InputPathType,
    refset: InputPathType,
    prefix: str,
    mask: InputPathType | None = None,
    in_min: float | None = None,
    in_max: float | None = None,
    ref_min: float | None = None,
    ref_max: float | None = None,
    only_dice_thr: bool = False,
    runner: Runner | None = None,
) -> V3dMatchOutputs:
    """
    Find similar subbricks and rearrange order to ease comparison. Part of FATCAT in
    AFNI.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dMatch.html
    
    Args:
        inset: File with M subbricks of data to match against another file.
        refset: File with N subbricks, serving as a reference for INPUT_FILE.
        prefix: Prefix for output name for BRIK/HEAD files and *_coeff.vals\
            text files.
        mask: A mask of regions to include in the correlation of datasets.
        in_min: Threshold below which values in INPUT_FILE will be zeroed\
            during analysis.
        in_max: Threshold above which values in INPUT_FILE will be zeroed\
            during analysis.
        ref_min: Threshold below which values in REF_FILE will be zeroed during\
            analysis.
        ref_max: Threshold above which values in REF_FILE will be zeroed during\
            analysis.
        only_dice_thr: Apply thresholding only during Dice evaluation, not\
            during spatial correlation.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dMatchOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_MATCH_METADATA)
    cargs = []
    cargs.append("3dMatch")
    cargs.extend([
        "-inset",
        execution.input_file(inset)
    ])
    cargs.extend([
        "-refset",
        execution.input_file(refset)
    ])
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    if in_min is not None:
        cargs.extend([
            "-in_min",
            str(in_min)
        ])
    if in_max is not None:
        cargs.extend([
            "-in_max",
            str(in_max)
        ])
    if ref_min is not None:
        cargs.extend([
            "-ref_min",
            str(ref_min)
        ])
    if ref_max is not None:
        cargs.extend([
            "-ref_max",
            str(ref_max)
        ])
    cargs.extend([
        "-prefix",
        prefix
    ])
    if only_dice_thr:
        cargs.append("-only_dice_thr")
    ret = V3dMatchOutputs(
        root=execution.output_file("."),
        ref_brik=execution.output_file(prefix + "_REF+orig.BRIK"),
        ref_coeff_vals=execution.output_file(prefix + "_REF_coeff.vals"),
        in_brik=execution.output_file(prefix + "_IN+orig.BRIK"),
        in_coeff_vals=execution.output_file(prefix + "_IN_coeff.vals"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dMatchOutputs",
    "V_3D_MATCH_METADATA",
    "v_3d_match",
]
