Repository: mne-tools/mne-python

Issue:
problem in check for set_channel_type
I get a weird error when trying to set channel type. cc @Eric89GXL 

script to reproduce:

``` py
import mne
import os.path as op

raw = mne.io.RawFIF(
    op.join(mne.datasets.sample.data_path(), 'MEG', 'sample',
            'sample_audvis_raw.fif'))

events = mne.find_events(raw, stim_channel='STI 014')
event_id = dict(left=1, right=2)

epochs = mne.Epochs(raw, events, event_id, tmin=-0.1, tmax=1,
                    baseline=(None, 0), preload=True)
epochs.set_channel_types({'MEG 2443': 'stim'})
```



Discussion:
Dict needs to be updated to reflect the proper unit:

```
constants.py:FIFF.FIFF_UNIT_T_M   = 201  # T/m
```


Resolving patch:
diff --git a/mne/channels/channels.py b/mne/channels/channels.py
--- a/mne/channels/channels.py
+++ b/mne/channels/channels.py
@@ -178,6 +178,8 @@ def __contains__(self, ch_type):
                'stim': FIFF.FIFF_UNIT_NONE,
                'syst': FIFF.FIFF_UNIT_NONE}
 _unit2human = {FIFF.FIFF_UNIT_V: 'V',
+               FIFF.FIFF_UNIT_T: 'T',
+               FIFF.FIFF_UNIT_T_M: 'T/m',
                FIFF.FIFF_UNIT_NONE: 'NA'}
 
 
@@ -286,7 +288,7 @@ def set_channel_types(self, mapping):
             unit_old = self.info['chs'][c_ind]['unit']
             unit_new = _human2unit[ch_type]
             if unit_old != _human2unit[ch_type]:
-                warnings.warn("The unit for Channel %s has changed "
+                warnings.warn("The unit for channel %s has changed "
                               "from %s to %s." % (ch_name,
                                                   _unit2human[unit_old],
                                                   _unit2human[unit_new]))


Test patch:
diff --git a/mne/channels/tests/test_channels.py b/mne/channels/tests/test_channels.py
--- a/mne/channels/tests/test_channels.py
+++ b/mne/channels/tests/test_channels.py
@@ -6,6 +6,7 @@
 import os.path as op
 
 from copy import deepcopy
+import warnings
 
 import numpy as np
 from numpy.testing import assert_array_equal
@@ -17,11 +18,13 @@
 from mne.io.constants import FIFF
 from mne.fixes import partial, savemat
 from mne.utils import _TempDir, run_tests_if_main
-from mne import pick_types
+from mne import pick_types, pick_channels
 
 base_dir = op.join(op.dirname(__file__), '..', '..', 'io', 'tests', 'data')
 raw_fname = op.join(base_dir, 'test_raw.fif')
 
+warnings.simplefilter('always')
+
 
 def test_rename_channels():
     """Test rename channels
@@ -72,12 +75,19 @@ def test_set_channel_types():
     mapping = {'EOG 061': 'xxx'}
     assert_raises(ValueError, raw.set_channel_types, mapping)
     # Test changing type if in proj (avg eeg ref here)
-    mapping = {'EEG 060': 'eog', 'EEG 059': 'ecg', 'EOG 061': 'seeg'}
+    mapping = {'EEG 060': 'eog', 'EEG 059': 'ecg', 'EOG 061': 'seeg',
+               'MEG 2441': 'eeg', 'MEG 2443': 'eeg'}
     assert_raises(RuntimeError, raw.set_channel_types, mapping)
     # Test type change
     raw2 = Raw(raw_fname, add_eeg_ref=False)
     raw2.info['bads'] = ['EEG 059', 'EEG 060', 'EOG 061']
-    raw2.set_channel_types(mapping)
+    assert_raises(RuntimeError, raw2.set_channel_types, mapping)  # has proj
+    raw2.add_proj([], remove_existing=True)
+    with warnings.catch_warnings(record=True) as w:
+        warnings.simplefilter('always')
+        raw2.set_channel_types(mapping)
+    assert_equal(len(w), 2)
+    assert_true(all('The unit for channel' in str(ww.message) for ww in w))
     info = raw2.info
     assert_true(info['chs'][374]['ch_name'] == 'EEG 060')
     assert_true(info['chs'][374]['kind'] == FIFF.FIFFV_EOG_CH)
@@ -91,6 +101,10 @@ def test_set_channel_types():
     assert_true(info['chs'][375]['kind'] == FIFF.FIFFV_SEEG_CH)
     assert_true(info['chs'][375]['unit'] == FIFF.FIFF_UNIT_V)
     assert_true(info['chs'][375]['coil_type'] == FIFF.FIFFV_COIL_EEG)
+    for idx in pick_channels(raw.ch_names, ['MEG 2441', 'MEG 2443']):
+        assert_true(info['chs'][idx]['kind'] == FIFF.FIFFV_EEG_CH)
+        assert_true(info['chs'][idx]['unit'] == FIFF.FIFF_UNIT_V)
+        assert_true(info['chs'][idx]['coil_type'] == FIFF.FIFFV_COIL_EEG)
 
 
 def test_read_ch_connectivity():