MCPcopy
hub / github.com/mne-tools/mne-python / test_n_components_none

Function test_n_components_none

mne/preprocessing/tests/test_ica.py:1377–1401  ·  view source on GitHub ↗

Test n_components=None.

(method, tmp_path)

Source from the content-addressed store, hash-verified

1375
1376@pytest.mark.parametrize("method", ["fastica", "picard"])
1377def test_n_components_none(method, tmp_path):
1378 """Test n_components=None."""
1379 _skip_check_picard(method)
1380 raw = read_raw_fif(raw_fname).crop(1.5, stop).load_data()
1381 events = read_events(event_name)
1382 picks = pick_types(raw.info, eeg=True, meg=False)[::5]
1383 epochs = Epochs(
1384 raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), preload=True
1385 )
1386
1387 n_components = None
1388 random_state = 12345
1389
1390 output_fname = tmp_path / "test_ica-ica.fif"
1391 ica = ICA(method=method, n_components=n_components, random_state=random_state)
1392 with _record_warnings():
1393 ica.fit(epochs)
1394 _assert_ica_attributes(ica)
1395 ica.save(output_fname)
1396
1397 ica = read_ica(output_fname)
1398 _assert_ica_attributes(ica)
1399 assert ica.n_pca_components is None
1400 assert ica.n_components is None
1401 assert ica.n_components_ == len(picks)
1402
1403
1404@pytest.mark.slowtest

Callers

nothing calls this directly

Calls 13

fitMethod · 0.95
saveMethod · 0.95
read_raw_fifFunction · 0.90
read_eventsFunction · 0.90
pick_typesFunction · 0.90
EpochsClass · 0.90
_record_warningsFunction · 0.90
read_icaFunction · 0.90
_skip_check_picardFunction · 0.85
_assert_ica_attributesFunction · 0.85
ICAFunction · 0.70
load_dataMethod · 0.45

Tested by

no test coverage detected