meanap.pipeline.probabilistic_threshold¶
Probabilistic edge thresholding, port of adjM_thr_parallel.m.
Generates synthetic spike trains by circularly shifting each channel’s real
spike times by a random offset, recomputes STTC on the shuffled data, and
zeroes out any edge whose real STTC value doesn’t clear the tail
significance cutoff across rep_num repetitions.
Not bit-reproducible against MATLAB. The shuffling is driven by a random
number generator and MATLAB’s adjM_thr_parallel.m never seeds one
explicitly, so even two MATLAB runs of the same recording can produce
different adjMci matrices. Only the deterministic, unthresholded STTC
matrix (meanap.pipeline.sttc.get_sttc()) has exact parity coverage —
see python/test_pipeline_step3.py. This module is validated structurally
(shuffled spike counts are conserved, thresholding only ever removes edges,
etc.), not against a specific MATLAB run’s random outcome.
Functions
|
Compute the raw and probabilistically-thresholded STTC adjacency matrices. |
|
Circularly shift each channel's spike times by an independent random offset. |
- meanap.pipeline.probabilistic_threshold.adjm_thr(spike_times_dict, n_channels, lag_ms, tail, fs, duration_s, rep_num, rng=None)[source]¶
Compute the raw and probabilistically-thresholded STTC adjacency matrices.
- Returns:
adj_m ((n, n) raw STTC matrix (deterministic, exact MATLAB parity))
adj_m_ci ((n, n) thresholded matrix — edges not significant at
tail) – (one-sided, upper-tail) acrossrep_numcircular-shift surrogates are zeroed.
- Parameters:
spike_times_dict (dict[int, ndarray])
n_channels (int)
lag_ms (float)
tail (float)
fs (float)
duration_s (float)
rep_num (int)
rng (Generator | None)
- Return type:
tuple[ndarray, ndarray]
- meanap.pipeline.probabilistic_threshold.circular_shift_spikes(spike_times_dict, n_channels, fs, duration_s, rng)[source]¶
Circularly shift each channel’s spike times by an independent random offset.
Port of the per-repetition synthetic-spike-train loop in
adjM_thr_parallel.m(operates in frames, matching MATLAB’sspk_vec = times*fs + k; overhang wraps around num_frames).- Parameters:
spike_times_dict (dict[int, ndarray])
n_channels (int)
fs (float)
duration_s (float)
rng (Generator)
- Return type:
dict[int, ndarray]