-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
203 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" | ||
.. _ex-trap-music: | ||
================================= | ||
Compute Trap-Music on evoked data | ||
================================= | ||
Compute a Truncated Recursively Applied and Projected MUltiple Signal Classification | ||
(TRAP-MUSIC) :footcite:`Makela2018` on evoked data. | ||
""" | ||
|
||
# Author: Théodore Papadopoulo <Theodore.Papadopoulo@inria.fr> | ||
# | ||
# License: BSD-3-Clause | ||
|
||
# %% | ||
|
||
import mne | ||
|
||
from mne.datasets import sample | ||
from mne.beamformer import trap_music | ||
from mne.viz import plot_dipole_locations, plot_dipole_amplitudes | ||
|
||
print(__doc__) | ||
|
||
data_path = sample.data_path() | ||
subjects_dir = data_path / "subjects" | ||
meg_path = data_path / "MEG" / "sample" | ||
fwd_fname = meg_path / "sample_audvis-meg-eeg-oct-6-fwd.fif" | ||
evoked_fname = meg_path / "sample_audvis-ave.fif" | ||
cov_fname = meg_path / "sample_audvis-cov.fif" | ||
|
||
# Read the evoked response and crop it | ||
condition = "Right Auditory" | ||
evoked = mne.read_evokeds(evoked_fname, condition=condition, baseline=(None, 0)) | ||
# select N100 | ||
evoked.crop(tmin=0.05, tmax=0.15) | ||
|
||
evoked.pick_types(meg=True, eeg=False) | ||
|
||
# Read the forward solution | ||
forward = mne.read_forward_solution(fwd_fname) | ||
|
||
# Read noise covariance matrix | ||
noise_cov = mne.read_cov(cov_fname) | ||
|
||
dipoles, residual = trap_music( | ||
evoked, forward, noise_cov, n_dipoles=2, return_residual=True, verbose=True | ||
) | ||
trans = forward["mri_head_t"] | ||
plot_dipole_locations(dipoles, trans, "sample", subjects_dir=subjects_dir) | ||
plot_dipole_amplitudes(dipoles) | ||
|
||
# Plot the evoked data and the residual. | ||
evoked.plot(ylim=dict(grad=[-300, 300], mag=[-800, 800], eeg=[-6, 8]), time_unit="s") | ||
residual.plot(ylim=dict(grad=[-300, 300], mag=[-800, 800], eeg=[-6, 8]), time_unit="s") | ||
|
||
# %% | ||
# References | ||
# ---------- | ||
# .. footbibliography:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.