From d78fbc3730cf42463938a4b2ae4144bfd60ff348 Mon Sep 17 00:00:00 2001 From: Scott Huberty <52462026+scott-huberty@users.noreply.github.com> Date: Sun, 30 Apr 2023 21:46:44 -0400 Subject: [PATCH 1/4] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/main_pylossless-qc-demo.yml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/main_pylossless-qc-demo.yml diff --git a/.github/workflows/main_pylossless-qc-demo.yml b/.github/workflows/main_pylossless-qc-demo.yml new file mode 100644 index 0000000..04b2245 --- /dev/null +++ b/.github/workflows/main_pylossless-qc-demo.yml @@ -0,0 +1,63 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions + +name: Build and deploy Python app to Azure Web App - pylossless-qc-demo + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python version + uses: actions/setup-python@v1 + with: + python-version: '3.7' + + - name: Create and start virtual environment + run: | + python -m venv venv + source venv/bin/activate + + - name: Install dependencies + run: pip install -r requirements.txt + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v2 + with: + name: python-app + path: | + . + !venv/ + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: python-app + path: . + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v2 + id: deploy-to-webapp + with: + app-name: 'pylossless-qc-demo' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_B1F7B3988A884792AC90F3E962E01A2B }} From 8119eb7d322b1f60ff83eb528e73b90d550d21de Mon Sep 17 00:00:00 2001 From: Scott Huberty Date: Thu, 26 Oct 2023 15:28:20 -0400 Subject: [PATCH 2/4] DOC: Switch sphinx theme --- .gitignore | 2 ++ docs/requirements_doc.txt | 4 ++-- docs/source/conf.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 12f1a23..4d18513 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ instance/ # Sphinx documentation docs/_build/ docs/build/ +docs/source/generated/auto_tutorials/ # PyBuilder target/ @@ -131,6 +132,7 @@ dmypy.json # Demo thing to let people not pollute repos my_project_ll_config.yaml +project_ll_config_face13_egi.yaml # VSCode ignore .vscode \ No newline at end of file diff --git a/docs/requirements_doc.txt b/docs/requirements_doc.txt index e2a45ad..884bce8 100644 --- a/docs/requirements_doc.txt +++ b/docs/requirements_doc.txt @@ -1,5 +1,5 @@ -sphinx!=4.1.0,<6 -pydata-sphinx-theme +sphinx>=6 +shibuya sphinx-design sphinx-gallery sphinxemoji diff --git a/docs/source/conf.py b/docs/source/conf.py index 17a04eb..db783fc 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -67,7 +67,7 @@ # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = "pydata_sphinx_theme" +html_theme = "shibuya" html_static_path = ["_static"] html_theme_options = { "logo": { From 0721378fb145e8cb651b714406297a8d774c5a69 Mon Sep 17 00:00:00 2001 From: Scott Huberty Date: Thu, 26 Oct 2023 16:20:37 -0400 Subject: [PATCH 3/4] FIX: fix flakes and doc errors --- docs/source/conf.py | 13 ++++++------- docs/source/contributing.rst | 4 ++-- docs/source/implementation.rst | 2 +- pylossless/flagging.py | 7 ++++--- pylossless/pipeline.py | 34 ++++++++++++++++++++++++++++++++-- pyproject.toml | 2 +- 6 files changed, 46 insertions(+), 16 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index db783fc..5d02672 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -69,12 +69,11 @@ html_theme = "shibuya" html_static_path = ["_static"] -html_theme_options = { - "logo": { - "image_light": "logo-lightmode_color.png", - "image_dark": "logo_white.png", - } -} +# TODO: add a svg file for the logo +# html_theme_options = { +# "light_logo": "logo-lightmode_color.png", +# "dark_logo": "logo_white.png", +# } # user made CSS to customize look html_css_files = [ @@ -82,7 +81,7 @@ ] # Custom sidebar templates, maps document names to template names. -html_sidebars = {"index": ["search-field.html", "sidebar-nav-bs", "globaltoc.html"]} +# html_sidebars = {"index": ["search-field.html", "sidebar-nav-bs", "globaltoc.html"]} # NumPyDoc configuration ----------------------------------------------------- diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index a2e3320..4bf9b5b 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -9,8 +9,8 @@ Building and Contributing to the Docs pyLossless uses `Sphinx `__ for building documentation. Specifically, we use the `PyData-sphinx-theme `__ as a -design template for our page. We also use the `Napolean -`__ +design template for our page. We also use the `Numpydoc +`__ and `autodoc `__ sphinx extensions to build API documentation directly from the pyLossless diff --git a/docs/source/implementation.rst b/docs/source/implementation.rst index 6471bee..8966cdd 100644 --- a/docs/source/implementation.rst +++ b/docs/source/implementation.rst @@ -147,7 +147,7 @@ Step 13: Run final ICA ---------------------- A final ICA will be run, excluding the epochs that were identified to contain -large deviations across ICs. These time periods are exlcuded to improve the +large deviations across ICs. These time periods are excluded to improve the final ICA's decomposition. MNE-ICAlabel will be run on this decomposition to classify the ICs as brain, diff --git a/pylossless/flagging.py b/pylossless/flagging.py index cb364a0..a4a16ba 100644 --- a/pylossless/flagging.py +++ b/pylossless/flagging.py @@ -24,7 +24,8 @@ class FlaggedChs(dict): Attributes ---------- ll : LosslessPipeline - the LosslessPipeline object that is flagging artifactual channels. + the :class:`~pylossless.pipeline.LosslessPipeline` object that is flagging + artifactual channels. Methods ------- @@ -86,10 +87,10 @@ def rereference(self, inst, **kwargs): Parameters ---------- inst : mne.io.Raw - An instance of :class:`mne.io.Raw` that contains EEG channels. + An instance of :class:`~mne.io.Raw` that contains EEG channels. kwargs : dict dictionary of valid keyword arguments for the - :meth:`mne.io.Raw.set_eeg_reference` method. + :meth:`~mne.io.Raw.set_eeg_reference` method. """ # Concatenate and remove duplicates bad_chs = list( diff --git a/pylossless/pipeline.py b/pylossless/pipeline.py index 78bc3ac..a06a721 100644 --- a/pylossless/pipeline.py +++ b/pylossless/pipeline.py @@ -477,7 +477,37 @@ def warp_locs(self, raw): class LosslessPipeline: - """Class used to handle pipeline parameters.""" + """Class used to handle pipeline parameters. + + Parameters + ---------- + config_fname : pathlib.Path + path to config file specifying the parameters to be used + in the pipeline. + + Attributes + ---------- + flags : dict + A dictionary of detailing the flagged channels, epochs, and ICs. + keys are ``'ch'``, ``'epoch'``, and ``'ic'``, and values are instances of + :class:`~pylossless.flagging.FlaggedChs`, + :class:`~pylossless.flagging.FlaggedEpochs`, and + :class:`~pylossless.flagging.FlaggedICs`, respectively. + config_fname : pathlib.Path + path to the config file specifying the parameters to be used in the + in the pipeline. + config : dict + A dictionary containing the pipeline parameters. + raw : mne.Raw + An instance of :class:`~mne.io.Raw` containing that will + be processed by the pipeline. + ica1 : mne.preprocessing.ICA + An instance of :class:`~mne.preprocessing.ICA`. The result of the initial ICA + run during the pipeline. + ica2 : mne.preprocessing.ICA + An instance of :class:`~mne.preprocessing.ICA`. The result of the final ICA run + during the pipeline. + """ def __init__(self, config_fname=None): """Initialize class. @@ -695,7 +725,7 @@ def _flag_volt_std(self, flag_dim, threshold=5e-5): def find_outlier_chs(self, inst): """Detect outlier Channels to leave out of rereference.""" - # TODO: Re-use _detect_outliers here. + # TODO: Reuse _detect_outliers here. logger.info("🔍 Detecting channels to leave out of reference.") if isinstance(inst, mne.Epochs): epochs = inst diff --git a/pyproject.toml b/pyproject.toml index 1e35962..a870304 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.codespell] -skip = "docs/source/generated" +skip = "docs/source/generated,pylossless/assets" [tool.ruff] select = ["E", "F", "W", "D"] # pycodestle, pyflakes, Warning, Docstring From 4cc96e63bb1a79706cb582249b1e6718d786efe8 Mon Sep 17 00:00:00 2001 From: Scott Huberty Date: Thu, 26 Oct 2023 16:22:41 -0400 Subject: [PATCH 4/4] FIX: another typo --- pylossless/tests/test_simulated.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylossless/tests/test_simulated.py b/pylossless/tests/test_simulated.py index 44d552a..efa54f5 100644 --- a/pylossless/tests/test_simulated.py +++ b/pylossless/tests/test_simulated.py @@ -69,7 +69,7 @@ def data_fun(times): add_eog(raw_sim, random_state=rng) raw_sim.pick("eeg") -# Save Info and Montage for later re-use +# Save Info and Montage for later reuse montage = raw_sim.get_montage() info = mne.create_info( ch_names=raw_sim.ch_names,