Repository: mne-tools/mne-bids

Issue:
iEEGCoordinateSystemDescription is not being written correctly
#### Describe the bug
In my testing of #675 I was adding tests for `iEEGCoordinateSystemDescription` that we add to the `coordsystem.json` files. However, I noticed a bug that writes the description as `'n/a'`.

#### Steps to reproduce
In `test_write.py::test_coordsystem_json`, one can comment out the lines asserting what the CoordinateSystemDescriptions for iEEG should be and you will see that the tests fail.

#### Expected results
In order to overcome this, perhaps it's best to briefly summarize how we dealt with iEEG coordinate frames. There exist coordinate frames represented in three different spaces: i) MNE, ii) filename and iii) BIDS.

For example, in MNE, we'll represent "FreeSurfer" coordsystem as `'fs_tal'`. Since this isn't yet a supported coordinate system in BIDS, in BIDs, it would be represented as `'Other'`. In the filename, then this would be encoded as `space-fs` (note that we get rid of the underscore else it wouldn't be BIDS-compliant). Tbh this is quite confusing and unfortunate, but no way I see around it rn.

#### Possible Solutions
This is probably a mne-bidsv0.8+ problem, since it doesn't really have a huge impact. 

Possibly, a way for tackling this would be to refactor how `coordsystem.json` files are written, and keep track of a "MNE-coord-system" and "BIDS-coord-system" better, so they can be handled correctly in `dig.py::_coordsystem_json`.

#### Additional information
```
>>> sys_info()
Platform:      macOS-10.16-x86_64-i386-64bit
Python:        3.8.5 | packaged by conda-forge | (default, Jul 22 2020, 17:24:51)  [Clang 10.0.0 ]
Executable:    /Users/adam2392/opt/miniconda3/envs/mne/bin/python
CPU:           i386: 8 cores
Memory:        Unavailable (requires "psutil" package)
mne:           0.22.0
numpy:         1.19.1 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:         1.5.2
matplotlib:    3.3.0 {backend=TkAgg}

sklearn:       0.24.0
numba:         Not found
nibabel:       3.2.1
nilearn:       0.7.0
dipy:          Not found
cupy:          Not found
pandas:        1.1.3
mayavi:        Not found
pyvista:       0.26.1 {pyvistaqt=0.2.0, OpenGL 4.1 ATI-4.2.13 via AMD Radeon Pro 560 OpenGL Engine}
vtk:           9.0.1
PyQt5:         5.15.1
```


Discussion:

Resolving patch:
diff --git a/mne_bids/dig.py b/mne_bids/dig.py
--- a/mne_bids/dig.py
+++ b/mne_bids/dig.py
@@ -239,8 +239,10 @@ def _coordsystem_json(*, raw, unit, hpi_coord_system, sensor_coord_system,
         as in BIDS_COORDINATE_UNITS.
     hpi_coord_system : str
         Name of the coordinate system for the head coils.
-    sensor_coord_system : str
+    sensor_coord_system : str | tuple of str
         Name of the coordinate system for the sensor positions.
+        If a tuple of strings, should be in the form:
+        ``(BIDS coordinate frame, MNE coordinate frame)``.
     fname : str
         Filename to save the coordsystem.json to.
     datatype : str
@@ -269,11 +271,21 @@ def _coordsystem_json(*, raw, unit, hpi_coord_system, sensor_coord_system,
                          .format(coord_frame))
 
     # get the coordinate frame description
+    try:
+        sensor_coord_system, sensor_coord_system_mne = sensor_coord_system
+    except ValueError:
+        sensor_coord_system_mne = "n/a"
     sensor_coord_system_descr = (COORD_FRAME_DESCRIPTIONS
                                  .get(sensor_coord_system.lower(), "n/a"))
-    if sensor_coord_system == 'Other' and verbose:
-        print('Using the `Other` keyword for the CoordinateSystem field. '
-              'Please specify the CoordinateSystemDescription field manually.')
+    if sensor_coord_system == 'Other':
+        if verbose:
+            msg = ('Using the `Other` keyword for the CoordinateSystem field. '
+                   'Please specify the CoordinateSystemDescription field '
+                   'manually.')
+            logger.info(msg)
+        sensor_coord_system_descr = (COORD_FRAME_DESCRIPTIONS
+                                     .get(sensor_coord_system_mne.lower(),
+                                          "n/a"))
 
     # create the coordinate json data structure based on 'datatype'
     if datatype == 'meg':
@@ -393,7 +405,8 @@ def _write_dig_bids(bids_path, raw, overwrite=False, verbose=True):
             _electrodes_tsv(raw, electrodes_path,
                             datatype, overwrite, verbose)
             _coordsystem_json(raw=raw, unit=unit, hpi_coord_system='n/a',
-                              sensor_coord_system=coord_frame,
+                              sensor_coord_system=(coord_frame,
+                                                   mne_coord_frame),
                               fname=coordsystem_path, datatype=datatype,
                               overwrite=overwrite, verbose=verbose)
         else:


Test patch:
diff --git a/mne_bids/tests/test_write.py b/mne_bids/tests/test_write.py
--- a/mne_bids/tests/test_write.py
+++ b/mne_bids/tests/test_write.py
@@ -2204,10 +2204,6 @@ def test_coordsystem_json_compliance(
     """Tests that coordsystem.json contents are written correctly.
 
     Tests multiple manufacturer data formats and MEG, EEG, and iEEG.
-
-    TODO: Fix coordinatesystemdescription for iEEG.
-    Currently, iEEG coordinate system descriptions are not written
-    correctly.
     """
     bids_root = _TempDir()
     data_path = op.join(testing.data_path(), dir_name)
@@ -2304,16 +2300,16 @@ def test_coordsystem_json_compliance(
     elif datatype == 'ieeg' and coord_frame == 'mni_tal':
         assert 'space-mni' in coordsystem_fname
         assert coordsystem_json['iEEGCoordinateSystem'] == 'Other'
-        # assert coordsystem_json['iEEGCoordinateSystemDescription'] == \
-        #     COORD_FRAME_DESCRIPTIONS['mni_tal']
+        assert coordsystem_json['iEEGCoordinateSystemDescription'] == \
+            COORD_FRAME_DESCRIPTIONS['mni_tal']
     elif datatype == 'ieeg' and coord_frame == 'fs_tal':
         assert 'space-fs' in coordsystem_fname
         assert coordsystem_json['iEEGCoordinateSystem'] == 'Other'
-        # assert coordsystem_json['iEEGCoordinateSystemDescription'] == \
-        #     COORD_FRAME_DESCRIPTIONS['fs_tal']
+        assert coordsystem_json['iEEGCoordinateSystemDescription'] == \
+            COORD_FRAME_DESCRIPTIONS['fs_tal']
     elif datatype == 'ieeg' and coord_frame == 'unknown':
         assert coordsystem_json['iEEGCoordinateSystem'] == 'Other'
-        # assert coordsystem_json['iEEGCoordinateSystemDescription'] == 'n/a'
+        assert coordsystem_json['iEEGCoordinateSystemDescription'] == 'n/a'
     elif datatype == 'meg' and dir_name == 'CTF':
         assert coordsystem_json['MEGCoordinateSystem'] == 'CTF'
         assert coordsystem_json['MEGCoordinateSystemDescription'] == \