From 478fa49b782e2c0f6ddc50f6ef66cd15ca3d11d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Fri, 3 Mar 2023 15:03:12 +0100 Subject: [PATCH 1/5] ci: update python to 3.8, update wxPython, update setup-python action --- .github/workflows/test.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ccec3e05..58d93909 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,22 +14,25 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - python_version: [3.7] + python_version: ['3.8'] include: - - os: ubuntu-latest - python_version: 3.8 # Experimental: Python 3.9 # Works fine, commented out because mostly covered (at least installing/building deps) by the typecheck job # See issue: https://github.com/NeuroTechX/eeg-notebooks/issues/50 #- os: ubuntu-latest # python_version: 3.9 + # Check 3.10 for future-proofing + - os: ubuntu-latest + python_version: '3.10' + steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python_version }} + # Not needed if pywinhook is installed from wheels #- name: Install swig # if: "startsWith(runner.os, 'windows')" @@ -37,6 +40,7 @@ jobs: # (New-Object System.Net.WebClient).DownloadFile("http://prdownloads.sourceforge.net/swig/swigwin-4.0.1.zip","swigwin-4.0.1.zip"); # Expand-Archive .\swigwin-4.0.1.zip .; # echo "$((Get-Item .).FullName)/swigwin-4.0.1" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Install APT dependencies if: "startsWith(runner.os, 'Linux')" run: | @@ -52,8 +56,9 @@ jobs: python -m pip install --upgrade pip wheel # Install wxPython wheels since they are distribution-specific and therefore not on PyPI + # This could possibly be bumped to 22.04 even. # 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 -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04 wxPython pip install . - name: Install MacOS/Windows dependencies @@ -110,7 +115,7 @@ jobs: # 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 -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04 wxPython pip install . - name: Install MacOS/Windows dependencies From 3bd12a7cb5d618d4237f63c514aed436613fdd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Fri, 3 Mar 2023 15:08:43 +0100 Subject: [PATCH 2/5] ci: pin ubuntu versions to 22.04, updated wxPython urls --- .github/workflows/docs.yml | 4 ++-- .github/workflows/test.yml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 67ad74d8..eb09e561 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - name: Set up Python @@ -22,7 +22,7 @@ jobs: # 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-20.04 wxPython + pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython pip install . - name: Build docs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58d93909..ae7f9302 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: ['ubuntu-22.04', windows-latest, macOS-latest] python_version: ['3.8'] include: # Experimental: Python 3.9 @@ -23,7 +23,7 @@ jobs: # python_version: 3.9 # Check 3.10 for future-proofing - - os: ubuntu-latest + - os: ubuntu-22.04 python_version: '3.10' steps: @@ -56,11 +56,11 @@ jobs: python -m pip install --upgrade pip wheel # Install wxPython wheels since they are distribution-specific and therefore not on PyPI - # This could possibly be bumped to 22.04 even. # See: https://wxpython.org/pages/downloads/index.html - pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04 wxPython + pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython pip install . + - name: Install MacOS/Windows dependencies run: | python -m pip install --upgrade pip wheel @@ -90,7 +90,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: ['ubuntu-22.04'] python_version: [3.9] steps: @@ -115,7 +115,7 @@ jobs: # 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-20.04 wxPython + pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython pip install . - name: Install MacOS/Windows dependencies From a4fe823baa712ba9ca8872378db379c81e876005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Fri, 3 Mar 2023 15:18:29 +0100 Subject: [PATCH 3/5] ci: bumped psychopy to 2023.1.0 --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 568058b3..e21ed8aa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ # Main repo requirements -psychopy==2020.2.3 +psychopy==2023.1.0 psychtoolbox scikit-learn>=0.23.2 pandas>=1.1.4 numpy>=1.19.4 mne>=0.20.8 -seaborn==0.9.0 +seaborn>=0.9.0 pyriemann>=0.2.7 jupyter muselsl>=2.0.2 From c2c5d57aae346bf220777ef42919631efde72426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Fri, 3 Mar 2023 15:23:26 +0100 Subject: [PATCH 4/5] build(deps): set upper supported numpy version to 1.23.x --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e21ed8aa..ddd23eff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ psychopy==2023.1.0 psychtoolbox scikit-learn>=0.23.2 pandas>=1.1.4 -numpy>=1.19.4 +numpy>=1.19.4,<1.24 # due to outdated libs not changing the names after: https://github.com/numpy/numpy/pull/22607 mne>=0.20.8 seaborn>=0.9.0 pyriemann>=0.2.7 From adf5e289cd0c212a792a4e259667369fea39c586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Fri, 3 Mar 2023 15:25:11 +0100 Subject: [PATCH 5/5] chore: applied no_implicit_optional --- eegnb/cli/__main__.py | 19 ++++++++++--------- eegnb/cli/utils.py | 3 ++- eegnb/experiments/auditory_oddball/aMMN.py | 3 ++- eegnb/experiments/auditory_oddball/aob.py | 3 ++- .../auditory_oddball/auditory_erp_arrayin.py | 4 +++- .../experiments/visual_codeprose/codeprose.py | 4 ++-- eegnb/experiments/visual_n170/n170.py | 3 ++- eegnb/experiments/visual_p300/p300.py | 3 ++- eegnb/experiments/visual_ssvep/ssvep.py | 3 ++- eegnb/experiments/visual_vep/vep.py | 3 ++- 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/eegnb/cli/__main__.py b/eegnb/cli/__main__.py index 6a59af38..9a196e8e 100644 --- a/eegnb/cli/__main__.py +++ b/eegnb/cli/__main__.py @@ -12,6 +12,7 @@ from eegnb.devices.eeg import EEG from eegnb.analysis.utils import check_report from eegnb.analysis.pipelines import load_eeg_data, make_erp_plot, analysis_report, example_analysis_report +from typing import Optional @click.group(name="eegnb") @@ -31,10 +32,10 @@ def main(): ) def runexp( experiment: str, - eegdevice: str = None, - macaddr: str = None, - recdur: float = None, - outfname: str = None, + eegdevice: Optional[str] = None, + macaddr: Optional[str] = None, + recdur: Optional[float] = None, + outfname: Optional[str] = None, prompt: bool = False, dosigqualcheck = True, generatereport = True @@ -107,11 +108,11 @@ def askforreportcheck(): ) def create_analysis_report( experiment: str, - eegdevice: str = None, - subject: str = None, - session: str = None, - site: str = None, - filepath:str = None, + eegdevice: Optional[str] = None, + subject: Optional[str] = None, + session: Optional[str] = None, + site: Optional[str] = None, + filepath: Optional[str] = None, prompt: bool = False, ): """ diff --git a/eegnb/cli/utils.py b/eegnb/cli/utils.py index 322a16dd..dfa10699 100644 --- a/eegnb/cli/utils.py +++ b/eegnb/cli/utils.py @@ -15,6 +15,7 @@ from eegnb.experiments.visual_codeprose import codeprose from eegnb.experiments.auditory_oddball import diaconescu from eegnb.experiments.auditory_ssaep import ssaep, ssaep_onefreq +from typing import Optional # New Experiment Class structure has a different initilization, to be noted @@ -40,7 +41,7 @@ def get_exp_desc(exp: str): def run_experiment( - experiment: str, eeg_device: EEG, record_duration: float = None, save_fn=None + experiment: str, eeg_device: EEG, record_duration: Optional[float] = None, save_fn=None ): if experiment in experiments: module = experiments[experiment] diff --git a/eegnb/experiments/auditory_oddball/aMMN.py b/eegnb/experiments/auditory_oddball/aMMN.py index 67305a69..cf809c0a 100644 --- a/eegnb/experiments/auditory_oddball/aMMN.py +++ b/eegnb/experiments/auditory_oddball/aMMN.py @@ -9,10 +9,11 @@ from psychopy import visual, core, event, sound from eegnb import generate_save_fn +from typing import Optional def present( - save_fn: str = None, + save_fn: Optional[str] = None, duration=120, stim_types=None, itis=None, diff --git a/eegnb/experiments/auditory_oddball/aob.py b/eegnb/experiments/auditory_oddball/aob.py index 32ccd1b2..1659100b 100644 --- a/eegnb/experiments/auditory_oddball/aob.py +++ b/eegnb/experiments/auditory_oddball/aob.py @@ -5,11 +5,12 @@ from time import time from eegnb.devices.eeg import EEG from eegnb.experiments import Experiment +from typing import Optional class AuditoryOddball(Experiment.BaseExperiment): - def __init__(self, duration=120, eeg: EEG=None, save_fn=None, n_trials = 2010, iti = 0.3, soa = 0.2, jitter = 0.2, secs=0.2, volume=0.8, random_state=42, s1_freq="C", s2_freq="D", s1_octave=5, s2_octave=6): + def __init__(self, duration=120, eeg: Optional[EEG]=None, save_fn=None, n_trials = 2010, iti = 0.3, soa = 0.2, jitter = 0.2, secs=0.2, volume=0.8, random_state=42, s1_freq="C", s2_freq="D", s1_octave=5, s2_octave=6): """ Auditory Oddball Experiment diff --git a/eegnb/experiments/auditory_oddball/auditory_erp_arrayin.py b/eegnb/experiments/auditory_oddball/auditory_erp_arrayin.py index 27a2e485..1100e49c 100644 --- a/eegnb/experiments/auditory_oddball/auditory_erp_arrayin.py +++ b/eegnb/experiments/auditory_oddball/auditory_erp_arrayin.py @@ -16,10 +16,12 @@ from eegnb import generate_save_fn from eegnb.devices.eeg import EEG +from typing import Optional + #from eegnb.stimuli import FACE_HOUSE -def present(eeg: EEG=None, save_fn=None, +def present(eeg: Optional[EEG]=None, save_fn=None, stim_types=None, itis=None, additional_labels={}, secs=0.07, volume=0.8,tone1_hz =440, tone2_hz = 528, do_fixation=True): diff --git a/eegnb/experiments/visual_codeprose/codeprose.py b/eegnb/experiments/visual_codeprose/codeprose.py index e1ec3912..ec849268 100644 --- a/eegnb/experiments/visual_codeprose/codeprose.py +++ b/eegnb/experiments/visual_codeprose/codeprose.py @@ -9,7 +9,7 @@ # TODO: Switch to using time_ns when Python 3.7 is the minimum version for eegnb from time import time, strftime, gmtime -from typing import List +from typing import Optional, List from pathlib import Path from dataclasses import dataclass, field from ...devices.eeg import EEG @@ -167,7 +167,7 @@ def run(window: visual.Window) -> pd.DataFrame: return pd.DataFrame(responses) -def fixate(window: visual.Window, text: str = None): +def fixate(window: visual.Window, text: Optional[str] = None): visual.TextStim( win=window, text=text, diff --git a/eegnb/experiments/visual_n170/n170.py b/eegnb/experiments/visual_n170/n170.py index 0ff0dbed..0cd27e39 100644 --- a/eegnb/experiments/visual_n170/n170.py +++ b/eegnb/experiments/visual_n170/n170.py @@ -19,11 +19,12 @@ from eegnb.devices.eeg import EEG from eegnb.stimuli import FACE_HOUSE from eegnb.experiments import Experiment +from typing import Optional class VisualN170(Experiment.BaseExperiment): - def __init__(self, duration=120, eeg: EEG=None, save_fn=None, + def __init__(self, duration=120, eeg: Optional[EEG]=None, save_fn=None, n_trials = 2010, iti = 0.4, soa = 0.3, jitter = 0.2): # Set experiment name diff --git a/eegnb/experiments/visual_p300/p300.py b/eegnb/experiments/visual_p300/p300.py index 33f6f3e2..a22ee893 100644 --- a/eegnb/experiments/visual_p300/p300.py +++ b/eegnb/experiments/visual_p300/p300.py @@ -15,10 +15,11 @@ from eegnb.stimuli import CAT_DOG from eegnb.experiments import Experiment from eegnb.devices.eeg import EEG +from typing import Optional class VisualP300(Experiment.BaseExperiment): - def __init__(self, duration=120, eeg: EEG=None, save_fn=None, + def __init__(self, duration=120, eeg: Optional[EEG]=None, save_fn=None, n_trials = 2010, iti = 0.4, soa = 0.3, jitter = 0.2): exp_name = "Visual P300" diff --git a/eegnb/experiments/visual_ssvep/ssvep.py b/eegnb/experiments/visual_ssvep/ssvep.py index b30baffd..21719b92 100644 --- a/eegnb/experiments/visual_ssvep/ssvep.py +++ b/eegnb/experiments/visual_ssvep/ssvep.py @@ -12,11 +12,12 @@ from eegnb.devices.eeg import EEG from eegnb import generate_save_fn +from typing import Optional class VisualSSVEP(Experiment.BaseExperiment): - def __init__(self, duration=120, eeg: EEG=None, save_fn=None, n_trials = 2010, iti = 0.5, soa = 3.0, jitter = 0.2): + def __init__(self, duration=120, eeg: Optional[EEG]=None, save_fn=None, n_trials = 2010, iti = 0.5, soa = 3.0, jitter = 0.2): exp_name = "Visual SSVEP" super().__init__(exp_name, duration, eeg, save_fn, n_trials, iti, soa, jitter) diff --git a/eegnb/experiments/visual_vep/vep.py b/eegnb/experiments/visual_vep/vep.py index 1acd1b11..fd28844e 100644 --- a/eegnb/experiments/visual_vep/vep.py +++ b/eegnb/experiments/visual_vep/vep.py @@ -1,11 +1,12 @@ from time import time, strftime, gmtime from pylsl import StreamInfo, StreamOutlet from eegnb.experiments.Experiment import Experiment +from typing import Optional class VisualVEP(Experiment): - def __init__(self, duration=120, eeg: EEG=None, save_fn=None, + def __init__(self, duration=120, eeg: Optional[EEG]=None, save_fn=None, n_trials = 2000, iti = 0.2, soa = 0.2, jitter = 0.1): exp_name = "Visual VEP"