Repository: mne-tools/mne-python

Issue:
Filtering if info["highpass"] is None
I have Brainvision files with a very truncated header. The BV import filter knows how to deal with these - it sets info["highpass"] and info["lowpass"] to None. This however causes an error when attempting to filter the data:

```
Filtering ...
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-0dd729552dea> in <module>()
     16 print("Filtering ...")
---> 17 raw_f.filter(1, 50, n_jobs=1, method="iir")

/home/FB/fb05/sassenha/tools/mne-python/mne/io/base.py in filter(self, l_freq, h_freq, picks, filter_length, l_trans_bandwidth, h_trans_bandwidth, n_jobs, method, iir_params, verbose)

/home/FB/fb05/sassenha/tools/mne-python/mne/utils.py in verbose(function, *args, **kwargs)
    532         # set it back if we get an exception
    533         try:
--> 534             return function(*args, **kwargs)
    535         finally:
    536             set_log_level(old_level)

/home/FB/fb05/sassenha/tools/mne-python/mne/io/base.py in filter(self, l_freq, h_freq, picks, filter_length, l_trans_bandwidth, h_trans_bandwidth, n_jobs, method, iir_params, verbose)
    366             # and it's not a band-stop filter
    367             if h_freq is not None and (l_freq is None or l_freq < h_freq) and \
--> 368                     h_freq < self.info['lowpass']:
    369                 self.info['lowpass'] = h_freq
    370             if l_freq is not None and (h_freq is None or l_freq < h_freq) and \

TypeError: unorderable types: float() < NoneType()
```

The easiest solution is for the BV filter to set info["highpass”] to 0 and info["lowpass"] to the sampling rate if no online filtering info is found (no idea what the other importers do). Alternatively, `raw.filter` can be adapted. 
(I can probably do a PR for either of these options.)



Discussion:
+1 for PR with filter less strict just logging the absence of l_freq and
h_freq


Resolving patch:
diff --git a/mne/io/base.py b/mne/io/base.py
--- a/mne/io/base.py
+++ b/mne/io/base.py
@@ -364,12 +364,16 @@ def filter(self, l_freq, h_freq, picks=None, filter_length='10s',
 
             # update info if filter is applied to all data channels,
             # and it's not a band-stop filter
-            if h_freq is not None and (l_freq is None or l_freq < h_freq) and \
-                    h_freq < self.info['lowpass']:
-                self.info['lowpass'] = h_freq
-            if l_freq is not None and (h_freq is None or l_freq < h_freq) and \
-                    l_freq > self.info['highpass']:
-                self.info['highpass'] = l_freq
+            if h_freq is not None:
+                if (l_freq is None or l_freq < h_freq) and \
+                   (self.info["lowpass"] is None or
+                   h_freq < self.info['lowpass']):
+                        self.info['lowpass'] = h_freq
+            if l_freq is not None:
+                if (h_freq is None or l_freq < h_freq) and \
+                   (self.info["highpass"] is None or
+                   l_freq > self.info['highpass']):
+                        self.info['highpass'] = l_freq
         if l_freq is None and h_freq is not None:
             logger.info('Low-pass filtering at %0.2g Hz' % h_freq)
             low_pass_filter(self._data, fs, h_freq,


Test patch:
diff --git a/mne/io/brainvision/tests/test_brainvision.py b/mne/io/brainvision/tests/test_brainvision.py
--- a/mne/io/brainvision/tests/test_brainvision.py
+++ b/mne/io/brainvision/tests/test_brainvision.py
@@ -32,9 +32,11 @@ def test_brainvision_data_filters():
     """Test reading raw Brain Vision files
     """
     raw = read_raw_brainvision(vhdr_highpass_path, montage, eog=eog,
-                               preload=False)
+                               preload=True)
     assert_equal(raw.info['highpass'], 0.1)
     assert_equal(raw.info['lowpass'], 250.)
+    raw.info["lowpass"] = None
+    raw.filter(1, 30)
 
 
 def test_brainvision_data():