Repository: mne-tools/mne-python

Issue:
eeglab reader warns that it failed to find events when no events are present in the file
I either have no events in the file (for example 'resting-state' activity) or have the events somewhere else and I would like to turn off the warnings that I get from eeglab reader. I tried changing `mne.set_log_level()` as well as setting `warnings.filterwarnings("ignore")` but I still get the warnings.
The warning is [here](https://github.com/mne-tools/mne-python/blob/master/mne/io/eeglab/eeglab.py#L613).
I don't think the reader should warn about not being able to find events when there are no events to be found. The intent of this warning was to signal when no events could be coerced to integers etc.



Discussion:
maybe @jona-sassenhagen has comments?

> I don't think the reader should warn about not being able to find events when there are no events to be found.

Agreed, can you open an issue to only warn if the file has events in it?

Im on it. 

That'd be just making L612 in io/eeglab/eeglab.py

```
if len(events) < 1 and len(types) > 0:
```

right?

@jona-sassenhagen yes, that should work (+ a test maybe? :) )

For a test, we'd have to write a new EEGLAB structure. So we're looking at a few lines of test for half a line of code.

@Eric89GXL ?

We can live without a test, just don't tell @agramfort 


Resolving patch:
diff --git a/mne/io/eeglab/eeglab.py b/mne/io/eeglab/eeglab.py
--- a/mne/io/eeglab/eeglab.py
+++ b/mne/io/eeglab/eeglab.py
@@ -578,6 +578,10 @@ def _read_eeglab_events(eeg, event_id=None, event_id_func='strip_to_integer'):
              "discontinuities. Be cautious of filtering and epoching around "
              "these events.")
 
+    if len(types) < 1:  # if there are 0 events, we can exit here
+        logger.info('No events found, returning empty stim channel ...')
+        return np.zeros((0, 3))
+
     not_in_event_id = set(x for x in types if x not in event_id)
     not_purely_numeric = set(x for x in not_in_event_id if not x.isdigit())
     no_numbers = set([x for x in not_purely_numeric
@@ -607,14 +611,15 @@ def _read_eeglab_events(eeg, event_id=None, event_id_func='strip_to_integer'):
             pass  # We're already raising warnings above, so we just drop
 
     if len(events) < len(types):
-        warn("Some event codes could not be mapped to integers. Use the "
-             "`event_id` parameter to map such events to integers manually.")
-    if len(events) < 1:
-        warn("No events found, consider adding an `event_id`. As is, the "
-             "trigger channel will consist entirely of zeros.")
-        return np.zeros((0, 3))
-    else:
-        return np.asarray(events)
+        missings = len(types) - len(events)
+        msg = ("{0}/{1} event codes could not be mapped to integers. Use "
+               "the 'event_id' parameter to map such events manually.")
+        warn(msg.format(missings, len(types)))
+        if len(events) < 1:
+            warn("As is, the trigger channel will consist entirely of zeros.")
+            return np.zeros((0, 3))
+
+    return np.asarray(events)
 
 
 def _strip_to_integer(trigger):


Test patch:
diff --git a/mne/io/eeglab/tests/test_eeglab.py b/mne/io/eeglab/tests/test_eeglab.py
--- a/mne/io/eeglab/tests/test_eeglab.py
+++ b/mne/io/eeglab/tests/test_eeglab.py
@@ -95,6 +95,7 @@ def test_io_set():
     event_id = {'S255/S8': 1, 'S8': 2, 'S255/S9': 3}
 
     epochs = read_epochs_eeglab(epochs_fname, epochs.events, event_id)
+    assert_equal(len(epochs.events), 4)
     epochs = read_epochs_eeglab(epochs_fname, out_fname, event_id)
     assert_raises(ValueError, read_epochs_eeglab, epochs_fname,
                   None, event_id)
@@ -128,8 +129,8 @@ def test_io_set():
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter('always')
         read_raw_eeglab(input_fname=one_chan_fname, preload=True)
-    # one warning for 'no events fond'
-    assert_equal(len(w), 1)
+    # no warning for 'no events found'
+    assert_equal(len(w), 0)
 
     # test if .dat file raises an error
     eeg = io.loadmat(epochs_fname, struct_as_record=False,