Skip to content

Commit b89951f

Browse files
authored
Merge branch 'master' into fix/asr-round-half-away
2 parents 0daabd0 + 1fcfbfd commit b89951f

2 files changed

Lines changed: 31 additions & 11 deletions

File tree

‎meegkit/asr.py‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ASR:
2424
----------
2525
sfreq : float
2626
Sampling rate of the data, in Hz.
27-
cutoff: float
27+
cutoff : float
2828
Standard deviation cutoff for rejection. X portions whose variance
2929
is larger than this threshold relative to the calibration data are
3030
considered missing data and will be removed. The most aggressive value
@@ -63,18 +63,18 @@ class ASR:
6363
6464
Attributes
6565
----------
66-
``zi_``: array, shape=(n_channels, filter_order)
66+
zi_ : array, shape=(n_channels, filter_order)
6767
Filter initial conditions.
68-
``ab_``: 2-tuple
68+
ab_ : 2-tuple
6969
Coefficients of an IIR filter that is used to shape the spectrum of the
7070
signal when calculating artifact statistics. The output signal does not
7171
go through this filter. This is an optional way to tune the sensitivity
7272
of the algorithm to each frequency component of the signal. The default
7373
filter is less sensitive at alpha and beta frequencies and more
7474
sensitive at delta (blinks) and gamma (muscle) frequencies.
75-
``cov_`` : array, shape=(channels, channels)
75+
cov_ : array, shape=(channels, channels)
7676
Previous covariance matrix.
77-
``state_`` : dict
77+
state_ : dict
7878
Previous ASR parameters (as derived by :func:`asr_calibrate`) for
7979
successive calls to :meth:`transform`. Required fields are:
8080
@@ -295,11 +295,6 @@ def clean_windows(X, sfreq, max_bad_chans=0.2, zthresholds=[-3.5, 5],
295295
a channel must lie (relative to a robust estimate of the clean EEG
296296
power distribution in the channel) for it to be considered "not bad".
297297
(default=[-3.5, 5]).
298-
299-
The following are detail parameters that usually do not have to be tuned.
300-
If you can't get the function to do what you want, you might consider
301-
adapting these to your data.
302-
303298
win_len : float
304299
Window length that is used to check the data for artifact content.
305300
This is ideally as long as the expected time scale of the artifacts
@@ -325,6 +320,13 @@ def clean_windows(X, sfreq, max_bad_chans=0.2, zthresholds=[-3.5, 5],
325320
sample_mask : boolean array, shape=(1, n_samples)
326321
Mask of retained samples (logical array).
327322
323+
Notes
324+
-----
325+
``win_len``, ``win_overlap``, ``min_clean_fraction`` and
326+
``max_dropout_fraction`` are detail parameters that usually do not have to
327+
be tuned. If you can't get the function to do what you want, you might
328+
consider adapting these to your data.
329+
328330
"""
329331
assert 0 < max_bad_chans < 1, "max_bad_chans must be a fraction !"
330332

@@ -441,7 +443,7 @@ def asr_calibrate(X, sfreq, cutoff=5, blocksize=100, win_len=0.5,
441443
or more).
442444
sfreq : float
443445
Sampling rate of the data, in Hz.
444-
cutoff: float
446+
cutoff : float
445447
Standard deviation cutoff for rejection. X portions whose variance is
446448
larger than this threshold relative to the calibration data are
447449
considered missing data and will be removed. The most aggressive value

‎tests/test_asr.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""ASR test."""
2+
import inspect
23
import os
34

45
import matplotlib.pyplot as plt
@@ -22,6 +23,23 @@
2223
rng = np.random.default_rng(9)
2324

2425

26+
@pytest.mark.parametrize("obj", (ASR, clean_windows, asr_calibrate, asr_process))
27+
def test_docstring_parameters(obj):
28+
"""Documented parameters must match the signature (no stray prose)."""
29+
docscrape = pytest.importorskip("numpydoc.docscrape")
30+
doc = docscrape.ClassDoc(obj) if inspect.isclass(obj) else docscrape.FunctionDoc(obj)
31+
documented = {p.name for p in doc["Parameters"]}
32+
signature = set(inspect.signature(obj).parameters)
33+
assert documented <= signature, documented - signature
34+
35+
36+
def test_docstring_attributes():
37+
"""ASR attribute names must not carry literal RST markup."""
38+
docscrape = pytest.importorskip("numpydoc.docscrape")
39+
for attr in docscrape.ClassDoc(ASR)["Attributes"]:
40+
assert "`" not in attr.name, attr.name
41+
42+
2543
@pytest.mark.parametrize(argnames="sfreq", argvalues=(125, 250, 256, 2048))
2644
def test_yulewalk(sfreq, show=False):
2745
"""Test that my version of yulewelk works just like MATLAB's."""

0 commit comments

Comments
 (0)