Skip to content

Commit eb454b3

Browse files
authored
Merge branch 'master' into fix/asr-online-weighting
2 parents 0433ac5 + 1fcfbfd commit eb454b3

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
@@ -304,11 +304,6 @@ def clean_windows(X, sfreq, max_bad_chans=0.2, zthresholds=[-3.5, 5],
304304
a channel must lie (relative to a robust estimate of the clean EEG
305305
power distribution in the channel) for it to be considered "not bad".
306306
(default=[-3.5, 5]).
307-
308-
The following are detail parameters that usually do not have to be tuned.
309-
If you can't get the function to do what you want, you might consider
310-
adapting these to your data.
311-
312307
win_len : float
313308
Window length that is used to check the data for artifact content.
314309
This is ideally as long as the expected time scale of the artifacts
@@ -334,6 +329,13 @@ def clean_windows(X, sfreq, max_bad_chans=0.2, zthresholds=[-3.5, 5],
334329
sample_mask : boolean array, shape=(1, n_samples)
335330
Mask of retained samples (logical array).
336331
332+
Notes
333+
-----
334+
``win_len``, ``win_overlap``, ``min_clean_fraction`` and
335+
``max_dropout_fraction`` are detail parameters that usually do not have to
336+
be tuned. If you can't get the function to do what you want, you might
337+
consider adapting these to your data.
338+
337339
"""
338340
assert 0 < max_bad_chans < 1, "max_bad_chans must be a fraction !"
339341

@@ -450,7 +452,7 @@ def asr_calibrate(X, sfreq, cutoff=5, blocksize=100, win_len=0.5,
450452
or more).
451453
sfreq : float
452454
Sampling rate of the data, in Hz.
453-
cutoff: float
455+
cutoff : float
454456
Standard deviation cutoff for rejection. X portions whose variance is
455457
larger than this threshold relative to the calibration data are
456458
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)