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

fixes to get docs building by github action #210

Merged
merged 3 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
15 changes: 8 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ name: Docs

on:
push:
branches: [ master, develop, 'dev/*' ]
branches: [ '**' ]
pull_request:
branches: [ master, develop ]
branches: [ '**' ]

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install attrdict

# Install wxPython wheels since they are distribution-specific and therefore not on PyPI
# See: https://wxpython.org/pages/downloads/index.html
pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython
pip install -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04 wxPython

pip install .
- name: Build docs
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ examples/visual_cueing/*.csv
.coverage
coverage.xml
htmlcov

# PyCharm
.idea/
4 changes: 2 additions & 2 deletions examples/visual_cueing/01r__cueing_singlesub_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
# Left Cue
tfr, itc = tfr_morlet(epochs['LeftCue'], freqs=frequencies,
n_cycles=wave_cycles, return_itc=True)
tfr = tfr.apply_baseline([-1,-.5],mode='mean')
tfr = tfr.apply_baseline((-1,-.5),mode='mean')
tfr.plot(picks=[0], mode='logratio',
title='TP9 - Ipsi');
tfr.plot(picks=[1], mode='logratio',
Expand All @@ -143,7 +143,7 @@
# Right Cue
tfr, itc = tfr_morlet(epochs['RightCue'], freqs=frequencies,
n_cycles=wave_cycles, return_itc=True)
tfr = tfr.apply_baseline([-1,-.5],mode='mean')
tfr = tfr.apply_baseline((-1,-.5),mode='mean')
tfr.plot(picks=[0], mode='logratio',
title='TP9 - Contra');
tfr.plot(picks=[1], mode='logratio',
Expand Down
4 changes: 2 additions & 2 deletions examples/visual_cueing/02r__cueing_group_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
# Left Cue
tfr, itc = tfr_morlet(epochs['LeftCue'], freqs=frequencies,
n_cycles=wave_cycles, return_itc=True)
tfr = tfr.apply_baseline([-1,-.5],mode='mean')
tfr = tfr.apply_baseline((-1,-.5),mode='mean')
#tfr.plot(picks=[0], mode='logratio',
# title='TP9 - Ipsi');
#tfr.plot(picks=[3], mode='logratio',
Expand All @@ -134,7 +134,7 @@
# Right Cue
tfr, itc = tfr_morlet(epochs['RightCue'], freqs=frequencies,
n_cycles=wave_cycles, return_itc=True)
tfr = tfr.apply_baseline([-1,-.5],mode='mean')
tfr = tfr.apply_baseline((-1,-.5),mode='mean')
#tfr.plot(picks=[0], mode='logratio',
# title='TP9 - Contra');
#tfr.plot(picks=[3], mode='logratio',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@
# Left Cue
tfr, itc = tfr_morlet(epochs['LeftCue'], freqs=frequencies,
n_cycles=wave_cycles, return_itc=True)
tfr = tfr.apply_baseline([-1,-.5],mode='mean')
tfr = tfr.apply_baseline((-1,-.5),mode='mean')
power_Ipsi_TP9 = tfr.data[0,:,:]
power_Contra_TP10 = tfr.data[1,:,:]

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

Expand Down
4 changes: 2 additions & 2 deletions examples/visual_cueing/CueingAnalysis_Colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
"# 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 = tfr.apply_baseline((-1,-.5),mode='mean')\n",
"tfr.plot(picks=[0], mode='logratio', \n",
" title='TP9 - Ipsi');\n",
"tfr.plot(picks=[1], mode='logratio', \n",
Expand All @@ -445,7 +445,7 @@
"# 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 = tfr.apply_baseline((-1,-.5),mode='mean')\n",
"tfr.plot(picks=[0], mode='logratio', \n",
" title='TP9 - Contra');\n",
"tfr.plot(picks=[1], mode='logratio', \n",
Expand Down
4 changes: 2 additions & 2 deletions examples/visual_cueing/CueingGroupAnalysis_Colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
" # 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 = 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",
Expand All @@ -226,7 +226,7 @@
" # 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 = 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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@
" # 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 = tfr.apply_baseline((-1,-.5),mode='mean')\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 = tfr.apply_baseline((-1,-.5),mode='mean')\n",
" power_Contra_TP9 = tfr.data[0,:,:]\n",
" power_Ipsi_TP10 = tfr.data[1,:,:]\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/visual_cueing/cueing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
"# 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 = tfr.apply_baseline((-1,-.5),mode='mean')\n",
"tfr.plot(picks=[0], mode='logratio', \n",
" title='TP9 - Ipsi');\n",
"tfr.plot(picks=[1], mode='logratio', \n",
Expand All @@ -540,7 +540,7 @@
"# 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 = tfr.apply_baseline((-1,-.5),mode='mean')\n",
"tfr.plot(picks=[0], mode='logratio', \n",
" title='TP9 - Contra');\n",
"tfr.plot(picks=[1], mode='logratio', \n",
Expand Down
4 changes: 2 additions & 2 deletions examples/visual_cueing/cueing_group_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
" # 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 = 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",
Expand All @@ -236,7 +236,7 @@
" # 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 = 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",
Expand Down
4 changes: 2 additions & 2 deletions examples/visual_cueing/cueing_loop.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@
" # 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 = 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",
Expand All @@ -612,7 +612,7 @@
" # 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 = 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",
Expand Down
5 changes: 3 additions & 2 deletions examples/visual_ssvep/01r__ssvep_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@
axs[0].plot(freq1, psd1_mean[[0, 3], :].mean(0), color='b', label='30 Hz')
axs[0].plot(freq2, psd2_mean[[0, 3], :].mean(0), color='r', label='20 Hz')

axs[1].plot(freq1, psd1_mean[4, :], color='b', label='30 Hz')
axs[1].plot(freq2, psd2_mean[4, :], color='r', label='20 Hz')
# TODO fix: IndexError: index 4 is out of bounds for axis 0 with size 4
# axs[1].plot(freq1, psd1_mean[4, :], color='b', label='30 Hz')
# axs[1].plot(freq2, psd2_mean[4, :], color='r', label='20 Hz')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting out these lines of code is out of the scope of "Fixing the Docs" and messes with a visualization for SSVEP. This should be reverted and changed in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the docs won't build without the change, I think I noticed the same issue a long time ago when trying to run the example locally. Would you be able to help me figure out why it is giving the out of bounds error?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem seems to be that this line

>> psd1, freq1 = psd_welch(epochs['30 Hz'], n_fft=1028, n_per_seg=256 * 3, picks='all')

Is returning only 4 chans in its output object, whereas in this example there are 5 chans used (i.e. a muse 2016 with one extra auxiliary electrode over occipital cortex).

>> psd1.shape
>> (105, 4, 129)

Trying to determine why this is happening...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok got it: the channel type for the Aux electrode is not 'eeg'

In [83]: raw.ch_names
Out[83]: ['TP9', 'AF7', 'AF8', 'TP10', 'POz', 'stim']
In [82]: raw.get_channel_types()
Out[82]: ['eeg', 'eeg', 'eeg', 'eeg', 'misc', 'stim']

Easily fixed with

raw.set_channel_types({'POz': 'eeg'})

or something similar


axs[0].set_title('TP9 and TP10')
axs[1].set_title('POz')
Expand Down