Skip to content

Commit

Permalink
Merge branch 'master' into add-global-coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
edeno committed Oct 31, 2020
2 parents 2547f02 + dbd6485 commit 807e430
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ __pycache__/
*.py[cod]
*$py.class

# IDEs
.idea/

# C extensions
*.so

Expand Down
1 change: 1 addition & 0 deletions spectral_connectivity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# flake8: noqa
from .connectivity import Connectivity
from .wrapper import multitaper_connectivity
from .transforms import Multitaper
from .wrapper import multitaper_connectivity
4 changes: 2 additions & 2 deletions spectral_connectivity/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def connectivity_to_xarray(m, method='coherence_magnitude', signal_names=None,
Only makes sense for one pair of signals and symmetrical measures
"""
assert method not in ['power', 'group_delay', 'canonical_coherence'], \
f'{method} is not supported by xarray interface'
if ((method in ['power', 'group_delay', 'canonical_coherence']) or ('directed' in method)):
raise NotImplementedError(f'{method} is not supported by xarray interface')
connectivity = Connectivity.from_multitaper(m)
if method == 'canonical_coherence':
connectivity_mat, labels = getattr(connectivity, method)(**kwargs)
Expand Down
24 changes: 14 additions & 10 deletions tests/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,26 @@ def test_multitaper_connectivity():
'debiased_squared_phase_lag_index',
'debiased_squared_weighted_phase_lag_index',
'pairwise_phase_consistency',
'phase_lag_index',
'pairwise_spectral_granger_prediction',
# Below measures are not implemented, will throw NotImplementedError
'directed_transfer_function',
'directed_coherence',
'partial_directed_coherence',
'generalized_partial_directed_coherence',
'direct_directed_transfer_function',
'phase_lag_index',
'pairwise_spectral_granger_prediction',
# 'canonical_coherence',
# 'group_delay',
# 'power'
'canonical_coherence',
'group_delay',
'power'
]:
m = multitaper_connectivity(time_series,
method=method,
sampling_frequency=sampling_frequency,
time_window_duration=time_window_duration,
)
try:
m = multitaper_connectivity(time_series,
method=method,
sampling_frequency=sampling_frequency,
time_window_duration=time_window_duration,
)
except NotImplementedError:
pass

assert not (m.values == 0).all()
assert not (np.isnan(m.values)).all()
Expand Down

0 comments on commit 807e430

Please sign in to comment.