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

[GSOC] Add surrogate data generation for significant connectivity estimation #223

Merged
merged 31 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6debece
Add EpochsSpectrum support
tsbinns Aug 1, 2024
b517e79
Fix CircleCI
tsbinns Aug 1, 2024
dccecdc
Add reminder to change version
tsbinns Aug 1, 2024
45bf496
Update Spectrum skips
tsbinns Aug 1, 2024
0b8790b
Fix broken tests and version checking
tsbinns Aug 1, 2024
dac4153
Be explicit with intersphinx roles
tsbinns Aug 1, 2024
121b40a
Change empty weights contruction
tsbinns Aug 1, 2024
00c381a
Merge branch 'main' into spec_conn_spectrum_support
tsbinns Aug 1, 2024
ffb256d
Add surrogate data generation
tsbinns Aug 2, 2024
30dc4e7
Adjust n_jobs
tsbinns Aug 6, 2024
2a9c1e2
Adjust n_jobs
tsbinns Aug 6, 2024
50ea4cd
Try CPU count // 3
tsbinns Aug 6, 2024
9e4a11d
Try CPU count // 4
tsbinns Aug 6, 2024
de52286
Use n_jobs=1
tsbinns Aug 6, 2024
cece6a4
Reset tests to upstream-main
tsbinns Aug 7, 2024
17f30cd
Expand test coverage
tsbinns Aug 5, 2024
cabe170
Merge branch 'main' into add_surrogate_conn
tsbinns Aug 7, 2024
a0ebe2a
Update example from review
tsbinns Aug 7, 2024
ca6013d
Update surrogate example
tsbinns Aug 19, 2024
6114bd5
Merge branch 'main' into add_surrogate_conn
tsbinns Aug 20, 2024
7197a17
Merge branch 'add_surrogate_conn' of https://github.com/tsbinns/mne-c…
tsbinns Aug 20, 2024
bd180f0
Merge branch 'main' into add_surrogate_conn
larsoner Aug 20, 2024
88e081b
Merge branch 'main' into add_surrogate_conn
tsbinns Aug 20, 2024
6d1c9bb
Merge branch 'main' into add_surrogate_conn
tsbinns Sep 3, 2024
abfc9ab
Merge branch 'main' into add_surrogate_conn
tsbinns Sep 10, 2024
a710c43
Merge branch 'main' into add_surrogate_conn
tsbinns Oct 7, 2024
f90a58a
Merge branch 'main' into add_surrogate_conn
tsbinns Oct 31, 2024
9dbb10d
Merge branch 'main' into add_surrogate_conn
tsbinns Nov 11, 2024
c7df2da
Merge branch 'main' into add_surrogate_conn
tsbinns Nov 12, 2024
64a3224
Update example from review
tsbinns Nov 12, 2024
8950ce7
Merge branch 'main' into add_surrogate_conn
tsbinns Dec 9, 2024
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
3 changes: 2 additions & 1 deletion doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ Dataset functions
.. autosummary::
:toctree: generated/

make_signals_in_freq_bands
make_signals_in_freq_bands
make_surrogate_data
21 changes: 21 additions & 0 deletions doc/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ @article{Dawson_2016
year = {2016}
}

@article{DowdingHaufe2018,
title={Powerful statistical inference for nested data using sufficient summary statistics},
author={Dowding, Irene and Haufe, Stefan},
doi={10.3389/fnhum.2018.00103},
journal={Frontiers in Human Neuroscience},
volume={12},
pages={103},
year={2018}
}

@article{EwaldEtAl2012,
author = {Ewald, Arne and Marzetti, Laura and Zappasodi, Filippo and Meinecke, Frank C. and Nolte, Guido},
doi = {10.1016/j.neuroimage.2011.11.084},
Expand Down Expand Up @@ -185,6 +195,17 @@ @book{OppenheimEtAl1999
year = {1999}
}

@article{PellegriniEtAl2023,
title={Identifying good practices for detecting inter-regional linear functional connectivity from {EEG}},
author={Pellegrini, Franziska and Delorme, Arnaud and Nikulin, Vadim and Haufe, Stefan},
doi={10.1016/j.neuroimage.2023.120218},
journal={NeuroImage},
volume={277},
pages={120218},
year={2023},
publisher={Elsevier}
}

@book{SekiharaNagarajan2008,
author = {Sekihara, Kensuke and Nagarajan, Srikantan S.},
doi = {10.1007/978-3-540-79370-0},
Expand Down
31 changes: 14 additions & 17 deletions examples/sensor_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#
# License: BSD (3-clause)

# %%

import os.path as op

import mne
Expand All @@ -22,7 +24,8 @@

print(__doc__)

###############################################################################
# %%

# Set parameters
data_path = sample.data_path()
raw_fname = op.join(data_path, "MEG", "sample", "sample_audvis_filt-0-40_raw.fif")
Expand All @@ -41,7 +44,7 @@
)

# Create epochs for the visual condition
event_id, tmin, tmax = 3, -0.2, 1.5 # need a long enough epoch for 5 cycles
event_id, tmin, tmax = 3, -0.2, 1.5 # want a long enough epoch for 5 cycles
epochs = mne.Epochs(
raw,
events,
Expand All @@ -52,24 +55,18 @@
baseline=(None, 0),
reject=dict(grad=4000e-13, eog=150e-6),
)
epochs.load_data().pick("grad") # just keep MEG and no EOG now

# Compute connectivity for band containing the evoked response.
# We exclude the baseline period:
fmin, fmax = 4.0, 9.0
sfreq = raw.info["sfreq"] # the sampling frequency
# Compute Fourier coefficients for the epochs (returns an EpochsSpectrum object)
# (storing Fourier coefficients in EpochsSpectrum objects requires MNE >= 1.8)
tmin = 0.0 # exclude the baseline period
epochs.load_data().pick_types(meg="grad") # just keep MEG and no EOG now
spectrum = epochs.compute_psd(method="multitaper", tmin=tmin, output="complex")

# Compute connectivity for the frequency band containing the evoked response
# (passing EpochsSpectrum objects as data requires MNE-Connectivity >= 0.8)
fmin, fmax = 4.0, 9.0
con = spectral_connectivity_epochs(
epochs,
method="pli",
mode="multitaper",
sfreq=sfreq,
fmin=fmin,
fmax=fmax,
faverage=True,
tmin=tmin,
mt_adaptive=False,
n_jobs=1,
data=spectrum, method="pli", fmin=fmin, fmax=fmax, faverage=True, n_jobs=1
)

# Now, visualize the connectivity in 3D:
Expand Down
Loading