Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] [BUG] [ENH] [WIP] Bug fixes and enhancements for time-resolved spectral connectivity estimation #104

Merged
merged 51 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
41bd87b
FIX: compute connectivity over multiple tapers when mode='multitaper'…
ruuskas Aug 31, 2022
05ae8f6
require MNE-Python 1.0 or newer due to breaking changes in mne.time_f…
ruuskas Aug 31, 2022
9cc283c
update tests corresponding to API changes and use longer test signal
ruuskas Aug 31, 2022
924b4ab
update docstring: connectivity is not averaged over Epochs by default
ruuskas Sep 1, 2022
c5b75f8
fix docstring typo
ruuskas Sep 1, 2022
7699983
update docstring: faverage is False by default
ruuskas Sep 1, 2022
89f683a
update docstring: lower bound of frequency range for connectivity com…
ruuskas Sep 1, 2022
cb2dab5
update docstring: fmax may be None
ruuskas Sep 1, 2022
0fd34c9
update docstring
ruuskas Sep 2, 2022
f4992a7
new default for fmin
ruuskas Sep 2, 2022
cc1d69d
Merge branch 'spectral_time' of github.com:ruuskas/mne-connectivity i…
ruuskas Sep 2, 2022
fa9bce7
improve docstring and warnings for spectral_connectivity_time
ruuskas Sep 2, 2022
9e9f983
fix bug with indices: connectivity is now computed correctly between …
ruuskas Sep 5, 2022
2e4ccd1
DOC: improve documentation
ruuskas Sep 5, 2022
926c330
change smoothing default to no smoothing
ruuskas Sep 7, 2022
b881c34
DOC: updates to main docstring
ruuskas Sep 7, 2022
73fb937
BUG: number of blocks is now computed correctly
ruuskas Sep 7, 2022
baaca26
add test for time-resolved connectivity with simulated data
ruuskas Sep 12, 2022
2a7e09e
Change block_size default to 1
ruuskas Sep 22, 2022
2a0be06
Add documentation for block_size
ruuskas Sep 22, 2022
53ac7b5
Change for more useful variable names
ruuskas Sep 22, 2022
bc61e54
Remove regression test
ruuskas Oct 5, 2022
7ce13bd
Remove block_size parameter
ruuskas Oct 5, 2022
c7dd18c
Improve documentation
ruuskas Oct 5, 2022
4d2c1f0
Improve comments
ruuskas Oct 5, 2022
1b6224f
Remove unused code
ruuskas Oct 5, 2022
054512b
Merge branch 'main' into spectral_time
adam2392 Oct 16, 2022
283a1a1
Fix style issues
ruuskas Oct 17, 2022
083aa1b
Merge branch 'spectral_time' of github.com:ruuskas/mne-connectivity i…
ruuskas Oct 17, 2022
e89ac77
Add comment
ruuskas Oct 19, 2022
19603bd
Improve comment
ruuskas Oct 19, 2022
e5da3ae
Rename test function
ruuskas Oct 19, 2022
39f0ee6
Update docstring
ruuskas Oct 19, 2022
4b6311c
Add comments
ruuskas Oct 19, 2022
7c64633
Merge branch 'spectral_time' of github.com:ruuskas/mne-connectivity i…
ruuskas Oct 19, 2022
f6684c0
DOC: Fix typos
ruuskas Nov 9, 2022
39fef93
DOC: Improve doc formulation
ruuskas Nov 9, 2022
08b5c79
DOC: Add note on memory mapping
ruuskas Nov 9, 2022
ccb0a2d
Remove unused names parameter
ruuskas Nov 9, 2022
fe727f7
Require sfreq with array input
ruuskas Nov 9, 2022
3b966ec
DOC: Improve documentation
ruuskas Nov 9, 2022
f082d6f
Add test for cwt_freqs
ruuskas Nov 9, 2022
84d073b
BUG: Fix spectral_connectivity time
ruuskas Nov 9, 2022
3e7f208
Compute weighted average over CSD
ruuskas Nov 14, 2022
71b61ad
Fix style
ruuskas Nov 15, 2022
9e073c6
Update the docstring of spectral_connectivity_time
ruuskas Nov 15, 2022
dcfbc8b
Remove unnecessary defaults
ruuskas Nov 15, 2022
fb9869f
Add entries in whats_new.rst and authors.inc
ruuskas Nov 17, 2022
eec0113
FIX: Test
larsoner Nov 17, 2022
b2dda41
FIX: Doc build
larsoner Nov 17, 2022
099f194
FIX: Not pre
larsoner Nov 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: mne
name: mne-connectivity
channels:
- conda-forge
dependencies:
Expand All @@ -20,5 +20,5 @@ dependencies:
- pyvista>=0.32
- pyvistaqt>=0.4
- pyqt!=5.15.3
- mne
- mne>=1.0
- h5netcdf
19 changes: 9 additions & 10 deletions mne_connectivity/spectral/tests/test_spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def test_spectral_connectivity_time_resolved(method, mode):
sfreq = 50.
n_signals = 3
n_epochs = 2
n_times = 256
n_times = 500
trans_bandwidth = 2.
tmin = 0.
tmax = (n_times - 1) / sfreq
Expand All @@ -506,18 +506,17 @@ def test_spectral_connectivity_time_resolved(method, mode):

# run connectivity estimation
con = spectral_connectivity_time(
data, freqs=freqs, method=method, mode=mode)
assert con.shape == (n_epochs, n_signals * 2, n_freqs, n_times)
data, cwt_freqs=freqs, method=method, mode=mode)
assert con.shape == (n_epochs, n_signals * 2, len(con.freqs))
ruuskas marked this conversation as resolved.
Show resolved Hide resolved
assert con.get_data(output='dense').shape == \
(n_epochs, n_signals, n_signals, n_freqs, n_times)

# average over time
conn_data = con.get_data(output='dense').mean(axis=-1)
conn_data = conn_data.mean(axis=-1)
(n_epochs, n_signals, n_signals, len(con.freqs))

# test the simulated signal
triu_inds = np.vstack(np.triu_indices(n_signals, k=1)).T

# average over frequencies
conn_data = con.get_data(output='dense').mean(axis=-1)

# the indices at which there is a correlation should be greater
# then the rest of the components
for epoch_idx in range(n_epochs):
Expand All @@ -538,7 +537,7 @@ def test_time_resolved_spectral_conn_regression(method, mode):
test_file_path_str = str(_resource_path(
'mne_connectivity.tests',
f'data/test_frite_dataset_{mode}_{method}.npy'))
test_conn = np.load(test_file_path_str)
test_conn = np.load(test_file_path_str).mean(axis=-1)

# paths to mne datasets - sample ECoG
bids_root = mne.datasets.epilepsy_ecog.data_path()
Expand Down Expand Up @@ -581,7 +580,7 @@ def test_time_resolved_spectral_conn_regression(method, mode):
if mode == 'morlet':
mode = 'cwt_morlet'
conn = spectral_connectivity_time(
epochs, freqs=freqs, n_jobs=1, method=method, mode=mode)
epochs, cwt_freqs=freqs, n_jobs=1, method=method, mode=mode)

# frites only stores the upper triangular parts of the raveled array
row_triu_inds, col_triu_inds = np.triu_indices(len(raw.ch_names), k=1)
Expand Down
Loading