DynamicsAndNeuralSystems / pyspi

Comparative analysis of pairwise interactions in multivariate time series.
https://time-series-features.gitbook.io/pyspi/
GNU General Public License v3.0
199 stars 26 forks source link

Handling NaN for spectral Granger causality SPI #16

Closed anniegbryant closed 1 year ago

anniegbryant commented 1 year ago

Incorporating two changes to the spectral Granger causality SPI:

  1. Only examining F values for frequencies > 0 rather than >=0.
  2. Flag ignore_NaN that defaults to True, in which case np.nanmean or np.nanmax is used instead of np.mean or np.max.

For #2, also added a catch that if >10% of F values in the given frequency range are NaN, the result will be manually set to NaN in the corresponding directed region pair.