-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into plot_source
- Loading branch information
Showing
16 changed files
with
483 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import osl | ||
from scipy import signal | ||
import matplotlib.pyplot as plt | ||
|
||
raw = osl.utils.simulate_raw_from_template(10000, noise=1/3) | ||
raw.pick(picks='mag') | ||
|
||
|
||
#%% | ||
spec = osl.glm.glm_spectrum(raw) | ||
spec.plot_joint_spectrum(freqs=(1, 10, 17), base=0.5, title='testing123') | ||
|
||
#%% | ||
aper, osc = osl.glm.glm_irasa(raw, mode='magnitude') | ||
plt.figure() | ||
ax = plt.subplot(121) | ||
aper.plot_joint_spectrum(freqs=(1, 10, 17), base=0.5,ax=ax) | ||
ax = plt.subplot(122) | ||
osc.plot_joint_spectrum(freqs=(1, 10, 17), base=0.5,ax=ax) | ||
|
||
|
||
#%% | ||
alpha = raw.copy().filter(l_freq=7, h_freq=13) | ||
covs = {'alpha': np.abs(signal.hilbert(alpha.get_data()[raw.ch_names.index('MEG1711'), :]))} | ||
|
||
spec = osl.glm.glm_spectrum(raw, reg_ztrans=covs) | ||
|
||
plt.figure() | ||
ax = plt.subplot(121) | ||
spec.plot_joint_spectrum(0, freqs=(1, 10, 17), base=0.5,ax=ax) | ||
ax = plt.subplot(122) | ||
spec.plot_joint_spectrum(1, freqs=(1, 10, 17), base=0.5,ax=ax) | ||
|
||
|
||
|
||
|
||
aper, osc = osl.glm.glm_irasa(raw, reg_ztrans=covs) | ||
|
||
plt.figure() | ||
ax = plt.subplot(221) | ||
aper.plot_joint_spectrum(0, freqs=(1, 10, 17), base=0.5,ax=ax) | ||
ax = plt.subplot(222) | ||
aper.plot_joint_spectrum(1, freqs=(1, 10, 17), base=0.5,ax=ax) | ||
ax = plt.subplot(223) | ||
osc.plot_joint_spectrum(0, freqs=(1, 10, 17), base=0.5,ax=ax) | ||
ax = plt.subplot(224) | ||
osc.plot_joint_spectrum(1, freqs=(1, 10, 17), base=0.5,ax=ax) | ||
|
||
|
||
|
||
|
||
gglmsp = osl.glm.read_glm_spectrum('/Users/andrew/Downloads/bigmeg-camcan-movecomptrans_glm-spectrum_grad-noztrans_group-level.pkl') | ||
spec = osl.glm.GroupSensorGLMSpectrum(gglmsp.model, | ||
gglmsp.design, | ||
gglmsp.config, | ||
gglmsp.info, | ||
fl_contrast_names=None, | ||
data=gglmsp.data) | ||
P = osl.glm.MaxStatPermuteGLMSpectrum(spec, 1, nperms=25) |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,41 @@ | ||
"""Tests for glm_spectrum and glm_epochs""" | ||
|
||
import unittest | ||
import tempfile | ||
import os | ||
|
||
import mne | ||
import numpy as np | ||
|
||
|
||
class TestGLMSpectrum(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
from ..utils import simulate_raw_from_template | ||
|
||
cls.flat_channels = None | ||
cls.bad_channels = None | ||
cls.bad_segments = None | ||
|
||
cls.raw = simulate_raw_from_template(500, | ||
flat_channels=cls.flat_channels, | ||
bad_channels=cls.bad_channels, | ||
bad_segments=cls.bad_segments) | ||
|
||
cls.fpath = tempfile.NamedTemporaryFile().name + 'raw.fif' | ||
cls.raw.save(cls.fpath) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
os.remove(cls.fpath) | ||
|
||
def test_glm_spectrum(self): | ||
from ..glm import glm_spectrum | ||
|
||
spec = glm_spectrum(self.raw) | ||
|
||
def test_glm_irasa(self): | ||
from ..glm import glm_irasa | ||
|
||
aper, osc = glm_irasa(self.raw) |
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
Oops, something went wrong.