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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_BRAIN_SYNC_METADATA = Metadata(
    id="5b4873a7460d63bb6ab8b2f718571646d6b0ba3b.boutiques",
    name="3dBrainSync",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dBrainSyncOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_brain_sync(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    qprefix_output: OutputPathType | None
    """Output dataset after orthogonal matrix transformation"""
    pprefix_output: OutputPathType | None
    """Output dataset after permutation transformation"""
    qprefix_sval: OutputPathType | None
    """Singular values from the BC' decomposition"""
    qprefix_qmat: OutputPathType | None
    """Q matrix"""
    pprefix_perm: OutputPathType | None
    """Permutation indexes p(i)"""


def v_3d_brain_sync(
    inset1: InputPathType,
    inset2: InputPathType,
    qprefix: str | None = None,
    pprefix: str | None = None,
    normalize: bool = False,
    mask: InputPathType | None = None,
    verb: bool = False,
    runner: Runner | None = None,
) -> V3dBrainSyncOutputs:
    """
    'Synchronizes' the -inset2 dataset to match the -inset1 dataset, using
    orthogonal or permutation transformation.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        inset1: Reference dataset.
        inset2: Dataset to be matched to the reference dataset.
        qprefix: Specifies the output dataset to be used for the orthogonal\
            matrix transformation.
        pprefix: Specifies the output dataset to be used for the permutation\
            transformation.
        normalize: Normalize the output dataset(s) so that each time series has\
            sum-of-squares = 1.
        mask: Only operate on nonzero voxels in the mask dataset.
        verb: Print some progress reports and auxiliary information.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dBrainSyncOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_BRAIN_SYNC_METADATA)
    cargs = []
    cargs.append("3dBrainSync")
    cargs.extend([
        "-inset1",
        execution.input_file(inset1)
    ])
    cargs.extend([
        "-inset2",
        execution.input_file(inset2)
    ])
    if qprefix is not None:
        cargs.extend([
            "-Qprefix",
            qprefix
        ])
    if pprefix is not None:
        cargs.extend([
            "-Pprefix",
            pprefix
        ])
    if normalize:
        cargs.append("-normalize")
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    if verb:
        cargs.append("-verb")
    ret = V3dBrainSyncOutputs(
        root=execution.output_file("."),
        qprefix_output=execution.output_file(qprefix + ".nii") if (qprefix is not None) else None,
        pprefix_output=execution.output_file(pprefix + ".nii") if (pprefix is not None) else None,
        qprefix_sval=execution.output_file(qprefix + ".sval.1D") if (qprefix is not None) else None,
        qprefix_qmat=execution.output_file(qprefix + ".qmat.1D") if (qprefix is not None) else None,
        pprefix_perm=execution.output_file(pprefix + ".perm.1D") if (pprefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dBrainSyncOutputs",
    "V_3D_BRAIN_SYNC_METADATA",
    "v_3d_brain_sync",
]
