Skip to content

Commit 5e3ea09

Browse files
committed
deploy: 1257c3a
1 parent 460c004 commit 5e3ea09

File tree

237 files changed

+6775
-16540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+6775
-16540
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 75670e2e8c59814fc976e9ef5fbe74ea
3+
config: 0b0845f06aa0ea4305158e51e2e10944
44
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.

_downloads/18e4b69d6ddc9302425e645c1fec16c3/04r__cueing_group_analysis_winter2019.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from mne.time_frequency import tfr_morlet
2323

2424
# EEG-Noteooks functions
25-
from eegnb.analysis.utils import load_data,plot_conditions
25+
from eegnb.analysis.utils import load_data
2626
from eegnb.datasets import fetch_dataset
2727

2828
# sphinx_gallery_thumbnail_number = 1
@@ -136,14 +136,14 @@
136136
# Left Cue
137137
tfr, itc = tfr_morlet(epochs['LeftCue'], freqs=frequencies,
138138
n_cycles=wave_cycles, return_itc=True)
139-
tfr = tfr.apply_baseline([-1,-.5],mode='mean')
139+
tfr = tfr.apply_baseline((-1,-.5),mode='mean')
140140
power_Ipsi_TP9 = tfr.data[0,:,:]
141141
power_Contra_TP10 = tfr.data[1,:,:]
142142

143143
# Right Cue
144144
tfr, itc = tfr_morlet(epochs['RightCue'], freqs=frequencies,
145145
n_cycles=wave_cycles, return_itc=True)
146-
tfr = tfr.apply_baseline([-1,-.5],mode='mean')
146+
tfr = tfr.apply_baseline((-1,-.5),mode='mean')
147147
power_Contra_TP9 = tfr.data[0,:,:]
148148
power_Ipsi_TP10 = tfr.data[1,:,:]
149149

_downloads/1f56a155b1a68a196eeb8aea2e0b7517/02r__cueing_group_analysis.ipynb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {
7-
"collapsed": false
8-
},
9-
"outputs": [],
10-
"source": [
11-
"%matplotlib inline"
12-
]
13-
},
143
{
154
"cell_type": "markdown",
165
"metadata": {},
@@ -80,7 +69,7 @@
8069
},
8170
"outputs": [],
8271
"source": [
83-
"subs = [101, 102, 103, 104, 105, 106, 108, 109, 110, 111, 112,\n 202, 203, 204, 205, 207, 208, 209, 210, 211, \n 301, 302, 303, 304, 305, 306, 307, 308, 309]\n\ndiff_out = []\nIpsi_out = []\nContra_out = []\nIpsi_spectra_out = []\nContra_spectra_out = []\ndiff_spectra_out = []\nERSP_diff_out = []\nERSP_Ipsi_out = []\nERSP_Contra_out = []\n\nfrequencies = np.linspace(6, 30, 100, endpoint=True)\nwave_cycles = 6\n\n# time frequency window for analysis\nf_low = 7 # Hz\nf_high = 10\nf_diff = f_high-f_low\n \nt_low = 0 # s\nt_high = 1\nt_diff = t_high-t_low\n\nbad_subs= [6, 7, 13, 26]\nreally_bad_subs = [11, 12, 19]\nsub_count = 0 \n \n \n \nfor sub in subs:\n print(sub)\n \n sub_count += 1\n\n \n if (sub_count in really_bad_subs):\n rej_thresh_uV = 90\n elif (sub_count in bad_subs):\n rej_thresh_uV = 90\n else:\n rej_thresh_uV = 90\n\n rej_thresh = rej_thresh_uV*1e-6\n \n \n # Load both sessions\n raw = load_data(sub,1, # subject, session\n experiment='visual-cueing',site='kylemathlab_dev',device_name='muse2016',\n data_dir = eegnb_data_path)\n \n raw.append(\n load_data(sub,2, # subject, session\n experiment='visual-cueing', site='kylemathlab_dev', device_name='muse2016',\n data_dir = eegnb_data_path))\n \n\n # Filter Raw Data\n raw.filter(1,30, method='iir')\n\n #Select Events\n events = find_events(raw)\n event_id = {'LeftCue': 1, 'RightCue': 2}\n epochs = Epochs(raw, events=events, event_id=event_id, \n tmin=-1, tmax=2, baseline=(-1, 0), \n reject={'eeg':rej_thresh}, preload=True,\n verbose=False, picks=[0, 3])\n print('Trials Remaining: ' + str(len(epochs.events)) + '.')\n\n # Compute morlet wavelet\n\n # Left Cue\n tfr, itc = tfr_morlet(epochs['LeftCue'], freqs=frequencies, \n n_cycles=wave_cycles, return_itc=True)\n tfr = tfr.apply_baseline([-1,-.5],mode='mean')\n #tfr.plot(picks=[0], mode='logratio', \n # title='TP9 - Ipsi');\n #tfr.plot(picks=[3], mode='logratio', \n # title='TP10 - Contra');\n power_Ipsi_TP9 = tfr.data[0,:,:]\n power_Contra_TP10 = tfr.data[1,:,:]\n\n # Right Cue\n tfr, itc = tfr_morlet(epochs['RightCue'], freqs=frequencies, \n n_cycles=wave_cycles, return_itc=True)\n tfr = tfr.apply_baseline([-1,-.5],mode='mean')\n #tfr.plot(picks=[0], mode='logratio', \n # title='TP9 - Contra');\n #tfr.plot(picks=[3], mode='logratio', \n # title='TP10 - Ipsi');\n power_Contra_TP9 = tfr.data[0,:,:]\n power_Ipsi_TP10 = tfr.data[1,:,:]\n\n # Plot Differences\n #%matplotlib inline\n times = epochs.times\n power_Avg_Ipsi = (power_Ipsi_TP9+power_Ipsi_TP10)/2;\n power_Avg_Contra = (power_Contra_TP9+power_Contra_TP10)/2;\n power_Avg_Diff = power_Avg_Ipsi-power_Avg_Contra;\n\n\n #find max to make color range\n plot_max = np.max([np.max(np.abs(power_Avg_Ipsi)), np.max(np.abs(power_Avg_Contra))])\n plot_diff_max = np.max(np.abs(power_Avg_Diff))\n\n \n \n #Ipsi\n fig, ax = plt.subplots(1)\n im = plt.imshow(power_Avg_Ipsi,\n extent=[times[0], times[-1], frequencies[0], frequencies[-1]],\n aspect='auto', origin='lower', cmap='coolwarm', vmin=-plot_max, vmax=plot_max)\n plt.xlabel('Time (sec)')\n plt.ylabel('Frequency (Hz)')\n plt.title('Power Average Ipsilateral to Cue')\n cb = fig.colorbar(im)\n cb.set_label('Power')\n # Create a Rectangle patch\n rect = patches.Rectangle((t_low,f_low),t_diff,f_diff,linewidth=1,edgecolor='k',facecolor='none')\n # Add the patch to the Axes\n ax.add_patch(rect)\n\n #TP10\n fig, ax = plt.subplots(1)\n im = plt.imshow(power_Avg_Contra,\n extent=[times[0], times[-1], frequencies[0], frequencies[-1]],\n aspect='auto', origin='lower', cmap='coolwarm', vmin=-plot_max, vmax=plot_max)\n plt.xlabel('Time (sec)')\n plt.ylabel('Frequency (Hz)')\n plt.title(str(sub) + ' - Power Average Contra to Cue')\n cb = fig.colorbar(im)\n cb.set_label('Power')\n # Create a Rectangle patch\n rect = patches.Rectangle((t_low,f_low),t_diff,f_diff,linewidth=1,edgecolor='k',facecolor='none')\n # Add the patch to the Axes\n ax.add_patch(rect)\n\n #difference between conditions\n fig, ax = plt.subplots(1)\n im = plt.imshow(power_Avg_Diff,\n extent=[times[0], times[-1], frequencies[0], frequencies[-1]],\n aspect='auto', origin='lower', cmap='coolwarm', vmin=-plot_diff_max, vmax=plot_diff_max)\n plt.xlabel('Time (sec)')\n plt.ylabel('Frequency (Hz)')\n plt.title('Power Difference Ipsi-Contra')\n cb = fig.colorbar(im)\n cb.set_label('Ipsi-Contra Power')\n # Create a Rectangle patch\n rect = patches.Rectangle((t_low,f_low),t_diff,f_diff,linewidth=1,edgecolor='k',facecolor='none')\n # Add the patch to the Axes\n ax.add_patch(rect)\n \n \n \n \n #output data into array\n Ipsi_out.append(np.mean(power_Avg_Ipsi[np.argmax(frequencies>f_low):\n np.argmax(frequencies>f_high)-1,\n np.argmax(times>t_low):np.argmax(times>t_high)-1 ]\n )\n ) \n Ipsi_spectra_out.append(np.mean(power_Avg_Ipsi[:,np.argmax(times>t_low):\n np.argmax(times>t_high)-1 ],1\n )\n )\n \n Contra_out.append(np.mean(power_Avg_Contra[np.argmax(frequencies>f_low):\n np.argmax(frequencies>f_high)-1,\n np.argmax(times>t_low):np.argmax(times>t_high)-1 ]\n )\n )\n \n Contra_spectra_out.append(np.mean(power_Avg_Contra[:,np.argmax(times>t_low):\n np.argmax(times>t_high)-1 ],1))\n \n \n diff_out.append(np.mean(power_Avg_Diff[np.argmax(frequencies>f_low):\n np.argmax(frequencies>f_high)-1,\n np.argmax(times>t_low):np.argmax(times>t_high)-1 ]\n )\n )\n diff_spectra_out.append(np.mean(power_Avg_Diff[:,np.argmax(times>t_low):\n np.argmax(times>t_high)-1 ],1\n )\n )\n \n \n ERSP_diff_out.append(power_Avg_Diff)\n ERSP_Ipsi_out.append(power_Avg_Ipsi)\n ERSP_Contra_out.append(power_Avg_Contra)\n\n\n \nprint(np.shape(ERSP_diff_out))\nprint(np.shape(Contra_spectra_out))\n\nprint(diff_out)"
72+
"subs = [101, 102, 103, 104, 105, 106, 108, 109, 110, 111, 112,\n 202, 203, 204, 205, 207, 208, 209, 210, 211, \n 301, 302, 303, 304, 305, 306, 307, 308, 309]\n\ndiff_out = []\nIpsi_out = []\nContra_out = []\nIpsi_spectra_out = []\nContra_spectra_out = []\ndiff_spectra_out = []\nERSP_diff_out = []\nERSP_Ipsi_out = []\nERSP_Contra_out = []\n\nfrequencies = np.linspace(6, 30, 100, endpoint=True)\nwave_cycles = 6\n\n# time frequency window for analysis\nf_low = 7 # Hz\nf_high = 10\nf_diff = f_high-f_low\n \nt_low = 0 # s\nt_high = 1\nt_diff = t_high-t_low\n\nbad_subs= [6, 7, 13, 26]\nreally_bad_subs = [11, 12, 19]\nsub_count = 0 \n \n \n \nfor sub in subs:\n print(sub)\n \n sub_count += 1\n\n \n if (sub_count in really_bad_subs):\n rej_thresh_uV = 90\n elif (sub_count in bad_subs):\n rej_thresh_uV = 90\n else:\n rej_thresh_uV = 90\n\n rej_thresh = rej_thresh_uV*1e-6\n \n \n # Load both sessions\n raw = load_data(sub,1, # subject, session\n experiment='visual-cueing',site='kylemathlab_dev',device_name='muse2016',\n data_dir = eegnb_data_path)\n \n raw.append(\n load_data(sub,2, # subject, session\n experiment='visual-cueing', site='kylemathlab_dev', device_name='muse2016',\n data_dir = eegnb_data_path))\n \n\n # Filter Raw Data\n raw.filter(1,30, method='iir')\n\n #Select Events\n events = find_events(raw)\n event_id = {'LeftCue': 1, 'RightCue': 2}\n epochs = Epochs(raw, events=events, event_id=event_id, \n tmin=-1, tmax=2, baseline=(-1, 0), \n reject={'eeg':rej_thresh}, preload=True,\n verbose=False, picks=[0, 3])\n print('Trials Remaining: ' + str(len(epochs.events)) + '.')\n\n # Compute morlet wavelet\n\n # Left Cue\n tfr, itc = tfr_morlet(epochs['LeftCue'], freqs=frequencies, \n n_cycles=wave_cycles, return_itc=True)\n tfr = tfr.apply_baseline((-1,-.5),mode='mean')\n #tfr.plot(picks=[0], mode='logratio', \n # title='TP9 - Ipsi');\n #tfr.plot(picks=[3], mode='logratio', \n # title='TP10 - Contra');\n power_Ipsi_TP9 = tfr.data[0,:,:]\n power_Contra_TP10 = tfr.data[1,:,:]\n\n # Right Cue\n tfr, itc = tfr_morlet(epochs['RightCue'], freqs=frequencies, \n n_cycles=wave_cycles, return_itc=True)\n tfr = tfr.apply_baseline((-1,-.5),mode='mean')\n #tfr.plot(picks=[0], mode='logratio', \n # title='TP9 - Contra');\n #tfr.plot(picks=[3], mode='logratio', \n # title='TP10 - Ipsi');\n power_Contra_TP9 = tfr.data[0,:,:]\n power_Ipsi_TP10 = tfr.data[1,:,:]\n\n # Plot Differences\n #%matplotlib inline\n times = epochs.times\n power_Avg_Ipsi = (power_Ipsi_TP9+power_Ipsi_TP10)/2;\n power_Avg_Contra = (power_Contra_TP9+power_Contra_TP10)/2;\n power_Avg_Diff = power_Avg_Ipsi-power_Avg_Contra;\n\n\n #find max to make color range\n plot_max = np.max([np.max(np.abs(power_Avg_Ipsi)), np.max(np.abs(power_Avg_Contra))])\n plot_diff_max = np.max(np.abs(power_Avg_Diff))\n\n \n \n #Ipsi\n fig, ax = plt.subplots(1)\n im = plt.imshow(power_Avg_Ipsi,\n extent=[times[0], times[-1], frequencies[0], frequencies[-1]],\n aspect='auto', origin='lower', cmap='coolwarm', vmin=-plot_max, vmax=plot_max)\n plt.xlabel('Time (sec)')\n plt.ylabel('Frequency (Hz)')\n plt.title('Power Average Ipsilateral to Cue')\n cb = fig.colorbar(im)\n cb.set_label('Power')\n # Create a Rectangle patch\n rect = patches.Rectangle((t_low,f_low),t_diff,f_diff,linewidth=1,edgecolor='k',facecolor='none')\n # Add the patch to the Axes\n ax.add_patch(rect)\n\n #TP10\n fig, ax = plt.subplots(1)\n im = plt.imshow(power_Avg_Contra,\n extent=[times[0], times[-1], frequencies[0], frequencies[-1]],\n aspect='auto', origin='lower', cmap='coolwarm', vmin=-plot_max, vmax=plot_max)\n plt.xlabel('Time (sec)')\n plt.ylabel('Frequency (Hz)')\n plt.title(str(sub) + ' - Power Average Contra to Cue')\n cb = fig.colorbar(im)\n cb.set_label('Power')\n # Create a Rectangle patch\n rect = patches.Rectangle((t_low,f_low),t_diff,f_diff,linewidth=1,edgecolor='k',facecolor='none')\n # Add the patch to the Axes\n ax.add_patch(rect)\n\n #difference between conditions\n fig, ax = plt.subplots(1)\n im = plt.imshow(power_Avg_Diff,\n extent=[times[0], times[-1], frequencies[0], frequencies[-1]],\n aspect='auto', origin='lower', cmap='coolwarm', vmin=-plot_diff_max, vmax=plot_diff_max)\n plt.xlabel('Time (sec)')\n plt.ylabel('Frequency (Hz)')\n plt.title('Power Difference Ipsi-Contra')\n cb = fig.colorbar(im)\n cb.set_label('Ipsi-Contra Power')\n # Create a Rectangle patch\n rect = patches.Rectangle((t_low,f_low),t_diff,f_diff,linewidth=1,edgecolor='k',facecolor='none')\n # Add the patch to the Axes\n ax.add_patch(rect)\n \n \n \n \n #output data into array\n Ipsi_out.append(np.mean(power_Avg_Ipsi[np.argmax(frequencies>f_low):\n np.argmax(frequencies>f_high)-1,\n np.argmax(times>t_low):np.argmax(times>t_high)-1 ]\n )\n ) \n Ipsi_spectra_out.append(np.mean(power_Avg_Ipsi[:,np.argmax(times>t_low):\n np.argmax(times>t_high)-1 ],1\n )\n )\n \n Contra_out.append(np.mean(power_Avg_Contra[np.argmax(frequencies>f_low):\n np.argmax(frequencies>f_high)-1,\n np.argmax(times>t_low):np.argmax(times>t_high)-1 ]\n )\n )\n \n Contra_spectra_out.append(np.mean(power_Avg_Contra[:,np.argmax(times>t_low):\n np.argmax(times>t_high)-1 ],1))\n \n \n diff_out.append(np.mean(power_Avg_Diff[np.argmax(frequencies>f_low):\n np.argmax(frequencies>f_high)-1,\n np.argmax(times>t_low):np.argmax(times>t_high)-1 ]\n )\n )\n diff_spectra_out.append(np.mean(power_Avg_Diff[:,np.argmax(times>t_low):\n np.argmax(times>t_high)-1 ],1\n )\n )\n \n \n ERSP_diff_out.append(power_Avg_Diff)\n ERSP_Ipsi_out.append(power_Avg_Ipsi)\n ERSP_Contra_out.append(power_Avg_Contra)\n\n\n \nprint(np.shape(ERSP_diff_out))\nprint(np.shape(Contra_spectra_out))\n\nprint(diff_out)"
8473
]
8574
},
8675
{
@@ -172,7 +161,7 @@
172161
"name": "python",
173162
"nbconvert_exporter": "python",
174163
"pygments_lexer": "ipython3",
175-
"version": "3.7.12"
164+
"version": "3.8.18"
176165
}
177166
},
178167
"nbformat": 4,
Binary file not shown.

_downloads/2f1a411d3414306e436c6540c86910c5/00x__n170_run_experiment.ipynb

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {
7-
"collapsed": false
8-
},
9-
"outputs": [],
10-
"source": [
11-
"%matplotlib inline"
12-
]
13-
},
143
{
154
"cell_type": "markdown",
165
"metadata": {},
@@ -33,25 +22,7 @@
3322
},
3423
"outputs": [],
3524
"source": [
36-
"import os\nfrom eegnb import generate_save_fn\nfrom eegnb.devices.eeg import EEG\nfrom eegnb.experiments.visual_n170 import n170\n\n# Define some variables\nboard_name = \"muse\"\nexperiment = \"visual_n170\"\nsubject_id = 0\nsession_nb = 0\nrecord_duration = 120"
37-
]
38-
},
39-
{
40-
"cell_type": "markdown",
41-
"metadata": {},
42-
"source": [
43-
"## Initiate EEG device\n\nStart EEG device\n\n"
44-
]
45-
},
46-
{
47-
"cell_type": "code",
48-
"execution_count": null,
49-
"metadata": {
50-
"collapsed": false
51-
},
52-
"outputs": [],
53-
"source": [
54-
"eeg_device = EEG(device=board_name)\n\n# Create save file name\nsave_fn = generate_save_fn(board_name, experiment, subject_id, session_nb)\nprint(save_fn)"
25+
"from eegnb import generate_save_fn\nfrom eegnb.devices.eeg import EEG\nfrom eegnb.experiments import VisualN170\n\n# Define some variables\nboard_name = \"muse2\" # board name\nexperiment_name = \"visual_n170\" # experiment name\nsubject_id = 0 # test subject id\nsession_nb = 0 # session number\nrecord_duration = 120 # recording duration\n\n# generate save path\nsave_fn = generate_save_fn(board_name, experiment_name, subject_id, session_nb)\n\n# create device object\neeg_device = EEG(device=board_name)\n\n# Experiment type\nexperiment = VisualN170(duration=record_duration, eeg=eeg_device, save_fn=save_fn)"
5526
]
5627
},
5728
{
@@ -69,7 +40,7 @@
6940
},
7041
"outputs": [],
7142
"source": [
72-
"n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)"
43+
"experiment.run()\n\n# Saved csv location\nprint(\"Recording saved in\", experiment.save_fn)"
7344
]
7445
}
7546
],
@@ -89,7 +60,7 @@
8960
"name": "python",
9061
"nbconvert_exporter": "python",
9162
"pygments_lexer": "ipython3",
92-
"version": "3.7.12"
63+
"version": "3.8.18"
9364
}
9465
},
9566
"nbformat": 4,
Binary file not shown.

_downloads/335ce423c80436163e4a75b13e3dba64/00x__ssvep_run_experiment.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
import os
1616
from eegnb import generate_save_fn
1717
from eegnb.devices.eeg import EEG
18-
from eegnb.experiments.visual_ssvep import ssvep
18+
from eegnb.experiments import VisualSSVEP
1919

2020
# Define some variables
21-
board_name = "muse"
21+
board_name = "muse2"
2222
experiment = "visual_ssvep"
2323
subject_id = 0
2424
session_nb = 0
@@ -39,4 +39,5 @@
3939
# Run experiment
4040
# ---------------------
4141
#
42-
ssvep.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
42+
ssvep = VisualSSVEP(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
43+
ssvep.run()

0 commit comments

Comments
 (0)