conninfpy._enhancement
Shared stat_dict → score_dict enhancement wrappers used by both the
t-test pipeline (conninfpy.pairwise_stats) and the GLM pipeline
(conninfpy.glm_stats).
These five wrappers are pure, key-agnostic transformations: a statistic
dictionary keyed by effect direction ('g2>g1'/'g1>g2' for the
two-sample / paired t-test, 'positive'/'negative' for the GLM, or
'omnibus' for the F-contrast pipeline) maps to an enhanced score
dictionary with the same keys. Both the input statistic map and the
output enhanced map are non-negative (N, N) symmetric matrices with
zero diagonal.
The mathematical definitions of each operator are in the corresponding sections of the methods chapter.
Shared enhancement wrappers for both t-test and GLM pipelines.
Each wrapper is a pure transformation: stat_dict → score_dict. It takes a
per-direction statistic dict ({'positive': ..., 'negative': ...}) and
applies the corresponding network-based enhancement to each direction
independently.
Wrappers accept the legacy keys 'g2>g1' / 'g1>g2' from the v1.x
t-test pipeline (silently remapped via conninfpy._compat.normalize_keys())
and always return a TailResult with canonical
'positive' / 'negative' keys. The legacy keys remain readable on
the result with a DeprecationWarning until v2.1.
Wrappers do NOT compute statistics internally — the caller is responsible for providing the raw statistic (t-stat, β, etc.). This matches the design pattern documented in CLAUDE.md.
- conninfpy._enhancement.apply_tfnbs(stat_dict: Dict[str, ndarray[tuple[Any, ...], dtype[float64]]], e: float | List[float] = 0.3, h: float | List[float] = 3.0, n: int = 10, start_thres: float = 1.65, **kwargs) TailResult[source]
Apply TFNBS (threshold-free cluster enhancement) to each direction.
- conninfpy._enhancement.apply_nbs(stat_dict: Dict[str, ndarray[tuple[Any, ...], dtype[float64]]], threshold: float = 2.0, nbs_stat: str = 'extent', **kwargs) TailResult[source]
Apply classical NBS (fixed threshold) to each direction.
- conninfpy._enhancement.apply_cnbs(stat_dict: Dict[str, ndarray[tuple[Any, ...], dtype[float64]]], net_labels: ndarray[tuple[Any, ...], dtype[int64]], **kwargs) TailResult[source]
Apply constrained NBS (block-constrained scoring) to each direction.
- conninfpy._enhancement.apply_ni_tfnbs(stat_dict: Dict[str, ndarray[tuple[Any, ...], dtype[float64]]], net_labels: ndarray[tuple[Any, ...], dtype[int64]], e: float | List[float] = 0.3, h: float | List[float] = 3.0, n: int = 10, start_thres: float = 1.65, normalization: str = 'sqrt', **kwargs) TailResult[source]
Apply network-informed TFNBS (block-density weighted) to each direction.
- conninfpy._enhancement.apply_fbc_tfnbs(stat_dict: Dict[str, ndarray[tuple[Any, ...], dtype[float64]]], net_labels: ndarray[tuple[Any, ...], dtype[int64]], e: float | List[float] = 0.3, h: float | List[float] = 3.0, n: int = 10, start_thres: float = 1.65, min_cluster_size: int = 3, **kwargs) TailResult[source]
Apply functional-block-clustering TFNBS to each direction.