Skip to content

Commit 3a14166

Browse files
committed
Deprecate Deprecate mne.preprocessing.run_ica()
1 parent 61382c1 commit 3a14166

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

doc/changes/latest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,5 @@ API
288288
- In :class:`~mne.preprocessing.Xdawn`, the components are stored in the rows of attributes ``filters_`` and ``patterns_`` to be consistent with :class:`~mne.decoding.CSP` and :class:`~mne.preprocessing.ICA` by `Henrich Kolkhorst`_
289289

290290
- Drop ``unit`` keyword argument from :func:`mne.channels.read_custom_montage`, as it was unused by `Richard Höchenberger`_
291+
292+
- Deprecate :func:`mne.preprocessing.run_ica`, use :meth:`mne.preprocessing.ICA.detect_artifacts` instead by `Richard Höchenberger`_

mne/preprocessing/ica.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
compute_corr, _get_inst_data, _ensure_int,
5252
copy_function_doc_to_method_doc, _pl, warn, Bunch,
5353
_check_preload, _check_compensation_grade, fill_doc,
54-
_check_option, _PCA)
54+
_check_option, _PCA, deprecated)
5555
from ..utils.check import _check_all_same_channel_names
5656

5757
from ..fixes import _get_args, _safe_svd
@@ -2255,6 +2255,8 @@ def _detect_artifacts(ica, raw, start_find, stop_find, ecg_ch, ecg_score_func,
22552255
logger.info('Ready.')
22562256

22572257

2258+
@deprecated('run_ica() is deprecated and will be removed in 0.21, use '
2259+
'ICA.detect_artifacts() instead')
22582260
@verbose
22592261
def run_ica(raw, n_components, max_pca_components=100,
22602262
n_pca_components=64, noise_cov=None,

mne/preprocessing/tests/test_ica.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,16 @@ def f(x, y):
736736

737737

738738
@requires_sklearn
739-
@pytest.mark.parametrize("method", ["fastica", "picard"])
740-
def test_run_ica(method):
739+
@pytest.mark.parametrize("method", ("fastica", "picard", "infomax"))
740+
# varicance, kurtosis idx
741+
@pytest.mark.parametrize("idx", (None, -1, slice(2), [0, 1]))
742+
# ECG / EOG channel params
743+
@pytest.mark.parametrize("ch_name", (None, 'MEG 1531'))
744+
def test_run_ica(method, idx, ch_name):
741745
"""Test run_ica function."""
742746
_skip_check_picard(method)
743747
raw = read_raw_fif(raw_fname).crop(1.5, stop).load_data()
744-
params = []
745-
params += [(None, -1, slice(2), [0, 1])] # varicance, kurtosis idx
746-
params += [(None, 'MEG 1531')] # ECG / EOG channel params
747-
for idx, ch_name in product(*params):
748+
with pytest.warns(DeprecationWarning, match='run_ica() is deprecated'):
748749
run_ica(raw, n_components=2, start=0, stop=0.5, start_find=0,
749750
stop_find=5, ecg_ch=ch_name, eog_ch=ch_name, method=method,
750751
skew_criterion=idx, var_criterion=idx, kurt_criterion=idx)

0 commit comments

Comments
 (0)