Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 36f88de
Merge: 824dbcc 7b70d0b
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 17:35:30 2023 +0200

    Merge branch 'hackathon_2023' of https://github.com/tsbinns/mne-connectivity into hackathon_2023

commit 824dbcc
Author: Thomas Samuel Binns <[email protected]>
Date:   Mon Oct 23 18:58:14 2023 +0200

    refactor epochs functions

commit 7b70d0b
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 17:34:19 2023 +0200

    bug fix refactoring

commit dd46076
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 17:21:07 2023 +0200

    bug fix refactoring

commit 71fa86c
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 16:59:30 2023 +0200

    bug fix refactoring

commit 2ce29eb
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 16:44:02 2023 +0200

    bug fix refactoring

commit ffdf82f
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 14:39:34 2023 +0200

    refactor new funcs

commit 0c4d5c6
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 14:26:36 2023 +0200

    bug fix refactoring

commit 3e93cea
Author: Thomas Samuel Binns <[email protected]>
Date:   Tue Oct 24 11:55:24 2023 +0200

    refactor new funcs

commit 174efc7
Author: Thomas Samuel Binns <[email protected]>
Date:   Mon Oct 23 22:24:32 2023 +0200

    refactor new funcs

commit 5d5d74d
Author: Thomas Samuel Binns <[email protected]>
Date:   Mon Oct 23 19:04:04 2023 +0200

    refactor new funcs

commit 014c22e
Author: Thomas Samuel Binns <[email protected]>
Date:   Mon Oct 23 19:03:18 2023 +0200

    refactor new funcs

commit 6282e67
Author: Thomas Samuel Binns <[email protected]>
Date:   Mon Oct 23 18:58:14 2023 +0200

    refactor new funcs
  • Loading branch information
tsbinns committed Oct 24, 2023
1 parent 5497b55 commit 5bad5fb
Show file tree
Hide file tree
Showing 10 changed files with 2,053 additions and 1,693 deletions.
1 change: 1 addition & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ on numpy array inputs.
phase_slope_index
vector_auto_regression
spectral_connectivity_epochs
spectral_connectivity_epochs_multivariate
spectral_connectivity_time

Reading functions
Expand Down
14 changes: 7 additions & 7 deletions examples/granger_causality.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import mne
from mne.datasets.fieldtrip_cmc import data_path
from mne_connectivity import spectral_connectivity_epochs
from mne_connectivity import spectral_connectivity_epochs_multivariate

###############################################################################
# Background
Expand Down Expand Up @@ -161,10 +161,10 @@
indices_ba = (np.array([signals_b]), np.array([signals_a])) # B => A

# compute Granger causality
gc_ab = spectral_connectivity_epochs(
gc_ab = spectral_connectivity_epochs_multivariate(
epochs, method=['gc'], indices=indices_ab, fmin=5, fmax=30,
rank=(np.array([5]), np.array([5])), gc_n_lags=20) # A => B
gc_ba = spectral_connectivity_epochs(
gc_ba = spectral_connectivity_epochs_multivariate(
epochs, method=['gc'], indices=indices_ba, fmin=5, fmax=30,
rank=(np.array([5]), np.array([5])), gc_n_lags=20) # B => A
freqs = gc_ab.freqs
Expand Down Expand Up @@ -262,10 +262,10 @@
# %%

# compute GC on time-reversed signals
gc_tr_ab = spectral_connectivity_epochs(
gc_tr_ab = spectral_connectivity_epochs_multivariate(
epochs, method=['gc_tr'], indices=indices_ab, fmin=5, fmax=30,
rank=(np.array([5]), np.array([5])), gc_n_lags=20) # TR[A => B]
gc_tr_ba = spectral_connectivity_epochs(
gc_tr_ba = spectral_connectivity_epochs_multivariate(
epochs, method=['gc_tr'], indices=indices_ba, fmin=5, fmax=30,
rank=(np.array([5]), np.array([5])), gc_n_lags=20) # TR[B => A]

Expand Down Expand Up @@ -317,7 +317,7 @@

# %%

gc_ab_60 = spectral_connectivity_epochs(
gc_ab_60 = spectral_connectivity_epochs_multivariate(
epochs, method=['gc'], indices=indices_ab, fmin=5, fmax=30,
rank=(np.array([5]), np.array([5])), gc_n_lags=60) # A => B

Expand Down Expand Up @@ -375,7 +375,7 @@
# %%

try:
spectral_connectivity_epochs(
spectral_connectivity_epochs_multivariate(
epochs, method=['gc'], indices=indices_ab, fmin=5, fmax=30, rank=None,
gc_n_lags=20, verbose=False) # A => B
print('Success!')
Expand Down
10 changes: 6 additions & 4 deletions examples/mic_mim.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import mne
from mne import EvokedArray, make_fixed_length_epochs
from mne.datasets.fieldtrip_cmc import data_path
from mne_connectivity import seed_target_indices, spectral_connectivity_epochs
from mne_connectivity import (seed_target_indices,
spectral_connectivity_epochs,
spectral_connectivity_epochs_multivariate)

###############################################################################
# Background
Expand Down Expand Up @@ -87,7 +89,7 @@
target_names = [epochs.info['ch_names'][idx] for idx in targets]

# multivariate imaginary part of coherency
(mic, mim) = spectral_connectivity_epochs(
(mic, mim) = spectral_connectivity_epochs_multivariate(
epochs, method=['mic', 'mim'], indices=multivar_indices, fmin=5, fmax=30,
rank=None)

Expand Down Expand Up @@ -290,7 +292,7 @@
# %%

indices = (np.array([[*seeds, *targets]]), np.array([[*seeds, *targets]]))
gim = spectral_connectivity_epochs(
gim = spectral_connectivity_epochs_multivariate(
epochs, method='mim', indices=indices, fmin=5, fmax=30, rank=None,
verbose=False)

Expand Down Expand Up @@ -342,7 +344,7 @@

# %%

(mic_red, mim_red) = spectral_connectivity_epochs(
(mic_red, mim_red) = spectral_connectivity_epochs_multivariate(
epochs, method=['mic', 'mim'], indices=multivar_indices, fmin=5, fmax=30,
rank=([25], [25]))

Expand Down
4 changes: 3 additions & 1 deletion mne_connectivity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
from .effective import phase_slope_index
from .envelope import envelope_correlation, symmetric_orth
from .io import read_connectivity
from .spectral import spectral_connectivity_time, spectral_connectivity_epochs
from .spectral import (spectral_connectivity_time,
spectral_connectivity_epochs,
spectral_connectivity_epochs_multivariate)
from .vector_ar import vector_auto_regression, select_order
from .utils import (check_indices, check_multivariate_indices, degree,
seed_target_indices, seed_target_multivariate_indices)
3 changes: 2 additions & 1 deletion mne_connectivity/spectral/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .epochs import spectral_connectivity_epochs
from .epochs_bivariate import spectral_connectivity_epochs
from .epochs_multivariate import spectral_connectivity_epochs_multivariate
from .time import spectral_connectivity_time
Loading

0 comments on commit 5bad5fb

Please sign in to comment.