Skip to content

Commit

Permalink
ruff + fix FAQ + remove announcement (#199)
Browse files Browse the repository at this point in the history
* ruff + fix FAQ

* update docs params

* Remove announcement

* remove docs workflow for PR
  • Loading branch information
raphaelvallat authored Jan 19, 2025
1 parent 83cb56c commit 99b31a9
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 135 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ name: Build and Deploy Sphinx Docs to GitHub Pages
on:
push:
branches:
- pydata-theme
- master
release:
types:
- published
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
# When backslash stripping is enabled then every occurrence of \\ in a domain directive
# will be changed to \, even within string literals.
# Options: True | False (default)
strip_signature_backslash = False
strip_signature_backslash = False

# Create table of contents entries for domain objects (e.g. functions, classes, attributes, etc.).
# Options: True (default) | False
Expand Down Expand Up @@ -269,7 +269,7 @@
"navbar_center": ["navbar-nav"],

# Defaults to ['theme-switcher', 'navbar-icon-links']
"navbar_end": ["theme-switcher", "navbar-icon-links"],
"navbar_end": ["theme-switcher", "navbar-icon-links"],

# Defaults to ['search-button-field']
"navbar_persistent": ["search-button"],
Expand Down Expand Up @@ -315,7 +315,7 @@
"show_version_warning_banner": True,

# Defaults to ""
"announcement": "&#128680; This is documentation for the <b>unstable development version</b> of YASA. <a href='https://raphaelvallat.com/yasa'>Switch to stable version</a> &#128680;",
# "announcement": "&#128680; This is documentation for the <b>unstable development version</b> of YASA. <a href='https://raphaelvallat.com/yasa'>Switch to stable version</a> &#128680;",
# "announcement": "<span style='font-family: Consolas, monospace;'>pip install yasa --upgrade</span> &#127881;",
}

Expand Down Expand Up @@ -369,7 +369,7 @@

# A dictionary defining custom sidebar templates, mapping document names to template names.
# The keys can contain glob-style patterns,
# in which case all matching documents will get the specified sidebars.
# in which case all matching documents will get the specified sidebars.
# The bundled first-party sidebar templates that can be rendered are:
# * localtoc.html – a fine-grained table of contents of the current document
# * globaltoc.html – a coarse-grained table of contents for the whole documentation set, collapsed
Expand Down
8 changes: 1 addition & 7 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Loading and visualizing polysomnography data
:animate: fade-in-slide-down
:icon: question
:name: load_edf

If you have polysomnography data in European Data Format (.edf), you can use the `MNE package <https://mne.tools/stable/index.html>`_ to load and preprocess your data in Python. MNE also supports several other standard formats (e.g. BrainVision, BDF, EEGLab). A simple preprocessing pipeline using MNE is shown below.

.. code-block:: python
Expand Down Expand Up @@ -122,8 +122,6 @@ Sleep staging

YASA does not come with a graphical user interface (GUI) and therefore editing the predicted hypnogram is not currently possible. The simplest way is therefore to export the hypnogram in CSV format and then open the file — together with the corresponding polysomnography data — in an external GUI, as shown below.

----------

**EDFBrowser**

`EDFBrowser <https://www.teuniz.net/edfbrowser/>`_ is a free software for visualizing polysomnography data in European Data Format (.edf), which also provides a module for visualizing and editing hypnograms.
Expand Down Expand Up @@ -152,8 +150,6 @@ Sleep staging
.. figure:: https://raw.githubusercontent.com/raphaelvallat/yasa/refs/tags/v0.6.5/docs/pictures/edfbrowser_with_hypnogram.png
:align: center

----------

**SpiSOP**

`SpiSOP <https://www.spisop.org/>`_ is an open-source Matlab toolbox for the analysis and visualization of polysomnography sleep data. It comes with a sleep scoring GUI.
Expand All @@ -165,8 +161,6 @@ Sleep staging
hypno_export = pd.DataFrame({"label": hypno_int, "artefact": 0})
hypno_export.to_csv("my_hypno_SpiSOP.txt", sep="\t", header=False, index=False)
----------

**Visbrain**

`Visbrain <https://visbrain.org/sleep.html>`_ is an open-source Python toolbox that includes a module for visualizing polysomnography sleep data and scoring sleep (see screenshot below).
Expand Down
16 changes: 7 additions & 9 deletions src/yasa/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _check_data_hypno(data, sf=None, ch_names=None, hypno=None, include=None, ch
assert include.size >= 1, "`include` must have at least one element."
assert hypno.dtype.kind == include.dtype.kind, "hypno and include must have same dtype"
assert np.isin(hypno, include).any(), (
"None of the stages specified " "in `include` are present in " "hypno."
"None of the stages specified in `include` are present in hypno."
)

# 4) Check data amplitude
Expand Down Expand Up @@ -1828,9 +1828,9 @@ def sw_detect(
if coupling:
# Get phase and amplitude for each centered epoch
time_before = time_after = coupling_params["time"]
assert (
float(sf * time_before).is_integer()
), "Invalid time parameter for coupling. Must be a whole number of samples."
assert float(sf * time_before).is_integer(), (
"Invalid time parameter for coupling. Must be a whole number of samples."
)
bef = int(sf * time_before)
aft = int(sf * time_after)
# Center of each epoch is defined as the negative peak of the SW
Expand Down Expand Up @@ -2476,7 +2476,7 @@ def rem_detect(

# If all channels are bad
if any(bad_chan):
logger.warning("At least one channel has bad amplitude. " "Returning None.")
logger.warning("At least one channel has bad amplitude. Returning None.")
return None

# Bandpass filter
Expand Down Expand Up @@ -3119,8 +3119,7 @@ def art_detect(
# Only shows if user actually pass an hypnogram
perc_reject = 100 * (art.sum() / art.size)
text = (
f"Stage {stage}: {art.sum()} / {art.size} "
f"epochs rejected ({perc_reject:.2f}%)"
f"Stage {stage}: {art.sum()} / {art.size} epochs rejected ({perc_reject:.2f}%)"
)
logger.info(text)
# Append to global vector
Expand Down Expand Up @@ -3158,8 +3157,7 @@ def art_detect(
# Only shows if user actually pass an hypnogram
perc_reject = 100 * (art.sum() / art.size)
text = (
f"Stage {stage}: {art.sum()} / {art.size} "
f"epochs rejected ({perc_reject:.2f}%)"
f"Stage {stage}: {art.sum()} / {art.size} epochs rejected ({perc_reject:.2f}%)"
)
logger.info(text)
# Append to global vector
Expand Down
Loading

0 comments on commit 99b31a9

Please sign in to comment.