Skip to content

Commit d4c2adc

Browse files
authored
Merge branch 'master' into fix/asr-fit-flat-channel
2 parents c2817b1 + 1fcfbfd commit d4c2adc

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
@@ -286,11 +286,6 @@ def clean_windows(X, sfreq, max_bad_chans=0.2, zthresholds=[-3.5, 5],
286286
a channel must lie (relative to a robust estimate of the clean EEG
287287
power distribution in the channel) for it to be considered "not bad".
288288
(default=[-3.5, 5]).
289-
290-
The following are detail parameters that usually do not have to be tuned.
291-
If you can't get the function to do what you want, you might consider
292-
adapting these to your data.
293-
294289
win_len : float
295290
Window length that is used to check the data for artifact content.
296291
This is ideally as long as the expected time scale of the artifacts
@@ -316,6 +311,13 @@ def clean_windows(X, sfreq, max_bad_chans=0.2, zthresholds=[-3.5, 5],
316311
sample_mask : boolean array, shape=(1, n_samples)
317312
Mask of retained samples (logical array).
318313
314+
Notes
315+
-----
316+
``win_len``, ``win_overlap``, ``min_clean_fraction`` and
317+
``max_dropout_fraction`` are detail parameters that usually do not have to
318+
be tuned. If you can't get the function to do what you want, you might
319+
consider adapting these to your data.
320+
319321
"""
320322
assert 0 < max_bad_chans < 1, "max_bad_chans must be a fraction !"
321323

@@ -432,7 +434,7 @@ def asr_calibrate(X, sfreq, cutoff=5, blocksize=100, win_len=0.5,
432434
or more).
433435
sfreq : float
434436
Sampling rate of the data, in Hz.
435-
cutoff: float
437+
cutoff : float
436438
Standard deviation cutoff for rejection. X portions whose variance is
437439
larger than this threshold relative to the calibration data are
438440
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)