import pytest from mne import pick_types, Annotations from mne.annotations import events_from_annotations, read_annotations from mne.datasets import testing from mne.utils import requires_pandas from mne.io import read_raw_edf, read_raw_bdf, read_raw_fif, edf, read_raw_gdf from mne.io.tests.test_raw import _test_raw_reader from mne.io.edf.edf import (_get_edf_default_event_id, _read_annotations_edf, _read_ch, _parse_prefilter_string, _edf_str, _read_edf_header, _read_header) from mne.io.pick import channel_indices_by_type, get_channel_type_constants from mne.tests.test_annotations import _assert_annotations_equal td_mark = testing._pytest_mark() FILE = inspect.getfile(inspect.currentframe()) data_dir = op.join(op.dirname(op.abspath(FILE)), 'data') montage_path = op.join(data_dir, 'biosemi.hpts') # XXX: missing reader bdf_path = op.join(data_dir, 'test.bdf') edf_path = op.join(data_dir, 'test.edf') duplicate_channel_labels_path = op.join(data_dir, 'duplicate_channel_labels.edf') edf_uneven_path = op.join(data_dir, 'test_uneven_samp.edf') bdf_eeglab_path = op.join(data_dir, 'test_bdf_eeglab.mat') edf_eeglab_path = op.join(data_dir, 'test_edf_eeglab.mat') edf_uneven_eeglab_path = op.join(data_dir, 'test_uneven_samp.mat') edf_stim_channel_path = op.join(data_dir, 'test_edf_stim_channel.edf') edf_txt_stim_channel_path = op.join(data_dir, 'test_edf_stim_channel.txt')
'204 Gradiometers', '102 Magnetometers', '9 Stimulus', '60 EEG', '1 EOG' ]: assert ch in html @testing.requires_testing_data def test_invalid_subject_birthday(): """Test handling of an invalid birthday in the raw file.""" with pytest.warns(RuntimeWarning, match='No birthday will be set'): raw = read_raw_fif(raw_invalid_bday_fname) assert 'birthday' not in raw.info['subject_info'] @pytest.mark.parametrize('fname', [ pytest.param(ctf_fname, marks=testing._pytest_mark()), raw_fname, ]) def test_channel_name_limit(tmp_path, monkeypatch, fname): """Test that our remapping works properly.""" # # raw # if fname.endswith('fif'): raw = read_raw_fif(fname) raw.pick_channels(raw.ch_names[:3]) ref_names = [] data_names = raw.ch_names else: assert fname.endswith('.ds') raw = read_raw_ctf(fname)
if renderer._get_3d_backend() == 'mayavi': import mayavi # noqa: F401 analysis:ignore assert isinstance(fig, mayavi.core.scene.Scene) def _assert_n_actors(fig, renderer, n_actors): __tracebackhide__ = True if renderer._get_3d_backend() == 'mayavi': return assert len(fig.plotter.renderer.actors) == n_actors @pytest.mark.slowtest # Slow for Mayavi on Azure @pytest.mark.parametrize('system', [ 'Neuromag', pytest.param('CTF', marks=testing._pytest_mark()), 'BTi', 'KIT', ]) def test_plot_alignment_meg(renderer, system): """Test plotting of MEG sensors + helmet.""" if system == 'Neuromag': this_info = read_info(evoked_fname) elif system == 'CTF': this_info = read_raw_ctf(ctf_fname).info elif system == 'BTi': this_info = read_raw_bti(pdf_fname, config_fname, hs_fname, convert=True, preload=False).info
@pytest.mark.parametrize('fname', ['x.xxx', 'x']) def test_read_raw_unsupported(fname): """Test handling of unsupported file types.""" with pytest.raises(ValueError, match='Unsupported file type'): read_raw(fname) @pytest.mark.parametrize('fname', ['x.vmrk', 'x.eeg']) def test_read_raw_suggested(fname): """Test handling of unsupported file types with suggested alternatives.""" with pytest.raises(ValueError, match='Try reading'): read_raw(fname) @pytest.mark.parametrize('fname', [ base / 'edf/tests/data/test.edf', base / 'edf/tests/data/test.bdf', base / 'brainvision/tests/data/test.vhdr', base / 'kit/tests/data/test.sqd', pytest.param(test_base / 'KIT/data_berlin.con', marks=testing._pytest_mark()), ]) def test_read_raw_supported(fname): """Test supported file types.""" read_raw(fname) read_raw(fname, verbose=False) raw = read_raw(fname, preload=True) assert "data loaded" in str(raw)