pymodalib.algorithms.group_coherence module¶
Group wavelet phase coherence with inter-subject surrogates.
-
dual_group_coherence
(group1_signals_a: numpy.ndarray, group1_signals_b: numpy.ndarray, group2_signals_a: numpy.ndarray, group2_signals_b: numpy.ndarray, fs: float, percentile: float = 95, *wavelet_args, **wavelet_kwargs) → Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]¶ Group wavelet phase coherence algorithm. Calculates coherence for two groups, whose members each have a signal A and a signal B. The groups can be different sizes.
This algorithm calculates inter-subject surrogates and uses them to calculate the residual coherence.
Note
you can also pass *args and **kwargs to this function, which will be used when performing the wavelet transform. For example, wavelet=”Morlet”.
Parameters: - group1_signals_a (ndarray) – [2D array] The set of signals A for group 1.
- group1_signals_b (ndarray) – [2D array] The set of signals B for group 1.
- group2_signals_a (ndarray) – [2D array] The set of signals A for group 2.
- group2_signals_b (ndarray) – [2D array] The set of signals B for group 2.
- fs (float) – The sampling frequency of the signals.
- percentile (float, optional) – (Default value = 95) The percentile of the surrogates which will be subtracted from the coherence.
- wavelet_args (Any, optional) – Arguments to pass to the wavelet transform function.
- wavelet_kwargs (Any, optional) – Keyword arguments to pass to the wavelet transform function.
Returns: - freq (ndarray) – [1D array] The frequencies.
- coh1 (ndarray) – [2D array] The residual coherence for group 1.
- coh2 (ndarray) – [2D array] The residual coherence for group 2.
-
group_coherence
(signals_a: numpy.ndarray, signals_b: numpy.ndarray, fs: float, percentile: float = 95, cleanup: bool = True, *wavelet_args, **wavelet_kwargs) → Tuple[numpy.ndarray, numpy.ndarray]¶ Group wavelet phase coherence algorithm. Calculates coherence for a single group, whose members each have a signal A and a signal B.
This algorithm uses inter-subject surrogates to calculate the residual coherence.
Note
You can also pass *args and **kwargs to this function, which will be used when performing the wavelet transform. For example, wavelet=”Morlet”.
Parameters: - signals_a (ndarray) – [2D array] The set of signals A for each member of the group.
- signals_b (ndarray) – [2D array] The set of signals B for each member of the group.
- fs (float) – The sampling frequency of the signals.
- percentile (float, optional) – (Default value = 95) The percentile of the surrogates which will be subtracted from the coherence.
- cleanup (bool, optional) – (Default value = True) Whether to clean up the cache folder after completion.
- wavelet_args (Any, optional) – Arguments to pass to the wavelet transform function.
- wavelet_kwargs (Any, optional) – Keyword arguments to pass to the wavelet transform function.
Returns: - freq (ndarray) – [1D array] The frequencies.
- coh (ndarray) – [2D array] The residual coherence.
-
statistical_test
(freq: numpy.ndarray, coh1: numpy.ndarray, coh2: numpy.ndarray, bands: List[Tuple[float, float]]) → List[float]¶ Performs a statistical test on the results of dual group wavelet phase coherence, to check for significance.
Parameters: - freq (ndarray) – [1D array] The frequencies.
- coh1 (ndarray) – [2D array] The coherence for group 1.
- coh2 (ndarray) – [2D array] The coherence for group 2.
- bands (List[Tuple[int, int]]) – The frequency intervals which the statistics will be calculated for.
Returns: pvalues – The p-values associated with each frequency interval.
Return type: List[float]