Repository: mne-tools/mne-python

Issue:
BUG: Channel-Adjacency for Neuromag122
#### Describe the bug
When I try to get the channel-adjacency-matrix for Gradiometer from **Neuromag122**-Data with `find_ch_adjacency`
, a matrix with dimensions 306x306 is given (when read from ./mne/channels/data/neighbors/neuromag122_neighb.mat).

And when I try to compute the adjacency with `mne.channels.channels._compute_ch_adjacency`, I get the following result:

```
File "C:\Users\marti\anaconda3\envs\mne\lib\site-packages\mne\channels\channels.py", line 1426, in _compute_ch_adjacency
xy = _find_topomap_coords(info, picks, sphere=HEAD_SIZE_DEFAULT)
File "C:\Users\marti\anaconda3\envs\mne\lib\site-packages\mne\channels\layout.py", line 624, in _find_topomap_coords
pos = _auto_topomap_coords(
File "C:\Users\marti\anaconda3\envs\mne\lib\site-packages\mne\channels\layout.py", line 723, in _auto_topomap_coords
raise ValueError('The following electrodes have overlapping positions,'
ValueError: The following electrodes have overlapping positions, which causes problems during visualization:
MEG 001, MEG 002, MEG 003, [...]
```


#### Steps to reproduce
```
import mne
data_path = "./neuromag122_test_file-raw.fif"
info = mne.io.read_info(data_path)
# Trying the load the channel-adjacency
ch_adjacency = mne.channels.find_ch_adjacency(info, 'grad')
print(ch_adjacency[0].shape)
# Trying to bypass mne.channels.read_ch_adjacency()
mne.channels.channels._compute_ch_adjacency(info, 'grad')
```

#### Expected results
A 122x122 Matrix


#### Actual results
A 306x306 Matrix and a Value Error


#### Additional information
I uploaded an [anonymized raw-file](https://github.com/mne-tools/mne-python/files/6016694/neuromag122_test_file-raw.zip) from our Neuromag122 for reproduction of the issue.



Discussion:
I dug into the problem and other functions like plots are working so probably the problem lies with how the paired gradiometer-channels in Neuromag122 are handled by _compute_ch_adjacency. For the info of my test-file, line 1412 in mne/channels/channels doesn\'t get True. The Coil-Type of Neuromag122 is FIFFV_COIL_NM_122
I will open a draft PR with a possible fix, but I still don't know why the saved matrix from fieldtrip in `/channels/data/neighbours` is 306x306

Resolving patch:
diff --git a/mne/channels/channels.py b/mne/channels/channels.py
--- a/mne/channels/channels.py
+++ b/mne/channels/channels.py
@@ -1383,8 +1383,6 @@ def find_ch_adjacency(info, ch_type):
         conn_name = 'neuromag306mag'
     elif has_vv_grad and ch_type == 'grad':
         conn_name = 'neuromag306planar'
-    elif has_neuromag_122_grad:
-        conn_name = 'neuromag122'
     elif has_4D_mag:
         if 'MEG 248' in info['ch_names']:
             idx = info['ch_names'].index('MEG 248')
@@ -1439,8 +1437,12 @@ def _compute_ch_adjacency(info, ch_type):
     from scipy.spatial import Delaunay
     from .. import spatial_tris_adjacency
     from ..channels.layout import _find_topomap_coords, _pair_grad_sensors
-    combine_grads = (ch_type == 'grad' and FIFF.FIFFV_COIL_VV_PLANAR_T1 in
-                     np.unique([ch['coil_type'] for ch in info['chs']]))
+    combine_grads = (ch_type == 'grad'
+                     and any([coil_type in [ch['coil_type']
+                                            for ch in info['chs']]
+                              for coil_type in
+                              [FIFF.FIFFV_COIL_VV_PLANAR_T1,
+                               FIFF.FIFFV_COIL_NM_122]]))
 
     picks = dict(_picks_by_type(info, exclude=[]))[ch_type]
     ch_names = [info['ch_names'][pick] for pick in picks]
diff --git a/mne/datasets/utils.py b/mne/datasets/utils.py
--- a/mne/datasets/utils.py
+++ b/mne/datasets/utils.py
@@ -251,7 +251,7 @@ def _data_path(path=None, force_update=False, update_path=True, download=True,
     path = _get_path(path, key, name)
     # To update the testing or misc dataset, push commits, then make a new
     # release on GitHub. Then update the "releases" variable:
-    releases = dict(testing='0.116', misc='0.8')
+    releases = dict(testing='0.117', misc='0.8')
     # And also update the "md5_hashes['testing']" variable below.
     # To update any other dataset, update the data archive itself (upload
     # an updated version) and update the md5 hash.
@@ -337,7 +337,7 @@ def _data_path(path=None, force_update=False, update_path=True, download=True,
         sample='12b75d1cb7df9dfb4ad73ed82f61094f',
         somato='32fd2f6c8c7eb0784a1de6435273c48b',
         spm='9f43f67150e3b694b523a21eb929ea75',
-        testing='ee36633fa9872aa434cc91f836beaa45',
+        testing='d8df35b2e625e213769e97e719de205c',
         multimodal='26ec847ae9ab80f58f204d09e2c08367',
         fnirs_motor='c4935d19ddab35422a69f3326a01fef8',
         opm='370ad1dcfd5c47e029e692c85358a374',


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
@@ -29,7 +29,7 @@
 io_dir = op.join(op.dirname(__file__), '..', '..', 'io')
 base_dir = op.join(io_dir, 'tests', 'data')
 raw_fname = op.join(base_dir, 'test_raw.fif')
-eve_fname = op .join(base_dir, 'test-eve.fif')
+eve_fname = op.join(base_dir, 'test-eve.fif')
 fname_kit_157 = op.join(io_dir, 'kit', 'tests', 'data', 'test.sqd')
 
 
@@ -344,6 +344,18 @@ def test_find_ch_adjacency():
     assert ch_names[0] == 'MEG 001'
 
 
+@testing.requires_testing_data
+def test_neuromag122_adjacency():
+    """Test computing the adjacency matrix of Neuromag122-Data."""
+    nm122_fname = op.join(testing.data_path(), 'misc',
+                          'neuromag122_test_file-raw.fif')
+    raw = read_raw_fif(nm122_fname, preload=True)
+    conn, ch_names = find_ch_adjacency(raw.info, 'grad')
+    assert conn.getnnz() == 1564
+    assert len(ch_names) == 122
+    assert conn.shape == (122, 122)
+
+
 def test_drop_channels():
     """Test if dropping channels works with various arguments."""
     raw = read_raw_fif(raw_fname, preload=True).crop(0, 0.1)