conninfpy.nbs_score
Network-Based Statistics (NBS) scoring module.
Provides classical NBS cluster scoring (extent or intensity) and constrained cNBS scoring in a single module, mirroring the role of tfnbs_score.py.
- conninfpy.nbs_score.get_nbs_score(t_stats: ndarray[tuple[Any, ...], dtype[floating]], threshold: float = 2.0, stat_type: str = 'extent') ndarray[tuple[Any, ...], dtype[floating]][source]
Compute NBS cluster statistics for a t-statistic matrix.
- Parameters:
t_stats (ndarray of shape (N, N)) – Non-negative t-statistic matrix (one tail, already separated).
threshold (float) – T-statistic threshold for edge inclusion.
stat_type ({'extent', 'intensity'}) –
‘extent’: cluster size (# edges).
’intensity’: sum of t-values within the cluster.
- Returns:
Matrix where each suprathreshold edge is assigned its cluster statistic. Non-suprathreshold edges are 0.
- Return type:
ndarray of shape (N, N)
- conninfpy.nbs_score.get_cnbs_score(t_stat: ndarray[tuple[Any, ...], dtype[float64]], net_labels: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[float64]][source]
Compute cNBS score: mean t-stat per subnetwork.
- Parameters:
t_stat (ndarray of shape (N, N)) – Non-negative t-statistic matrix (one tail, already separated).
net_labels (ndarray of shape (N,)) – Network label for each node (0..K-1).
- Returns:
Matrix where each edge has its subnetwork’s mean t-stat. Edges below threshold (t_stat=0) get score=0.
- Return type:
ndarray of shape (N, N)
- conninfpy.nbs_score.nbs_bct(group1: ndarray[tuple[Any, ...], dtype[float64]], group2: ndarray[tuple[Any, ...], dtype[float64]] | None = None, threshold: float = 2.0, stat_type: str = 'extent', n_permutations: int = 100, test_type: str = 'paired', use_mp: bool = True, random_state: int | None = None, rng: None | int | Generator | RandomState = None, n_processes: int | None = None, **kwargs) Tuple[Dict[str, ndarray[tuple[Any, ...], dtype[float64]]], Dict[str, ndarray[tuple[Any, ...], dtype[uint8]]], Dict[str, ndarray[tuple[Any, ...], dtype[float64]]]][source]
Compute classical NBS with permutation testing.
Returns p-values, adjacency matrices (thresholded t-stats), and null maxima. P-values use tie-inclusive max-statistic counting and the Phipson-Smyth +1 correction, matching the main
compute_p_valpath.