# Issue with set\_montage

**URL:** <https://mne.discourse.group/t/issue-with-set-montage/3873>\
**Category:** Support & Discussions\
**Tags:** visualization, montage\
**Created:** [October 29, 2021, 10:35pm UTC](https://mne.discourse.group/t/issue-with-set-montage/3873 "2021-10-29T22:35:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chapochn](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/chapochn/32/915_2.png) [@chapochn](https://mne.discourse.group/u/chapochn)\
**Post date:** [October 29, 2021, 10:35pm UTC](https://mne.discourse.group/t/issue-with-set-montage/3873/1 "2021-10-29T22:35:20Z")

</div>

- MNE-Python version: 0.23.4
- operating system: Mac OS 11.6

Hello,

I am working through the example:

> [Working with sEEG data — MNE 1.6.0 documentation](https://mne.tools/stable/auto_tutorials/clinical/20_seeg.html#tut-working-with-seeg)

Instead of the lines:

```python
raw = mne.io.read_raw_edf(misc_path + '/seeg/sample_seeg.edf')

raw.info['bads'].extend([ch for ch in raw.ch_names if ch not in ch_names])
raw.load_data()
raw.drop_channels(raw.info['bads'])
raw.crop(0, 2) # just process 2 sec of data for speed

```

I put:

```python
info = mne.create_info(ch_names=ch_names, sfreq=512)
raw = mne.io.RawArray(np.zeros((len(ch_names), 10)), info)

```

then, at the line:

`raw.set_montage(montage)`

I get the following error:

```python
---------------------------------------------------------------------------

TypeError Traceback (most recent call last)

~/opt/anaconda3/envs/mne/lib/python3.9/site-packages/IPython/core/formatters.py in __call__ (self, obj)
    343 method = get_real_method(obj, self.print_method)
    344 if method is not None:
--> 345 return method()
    346 return None
    347 else:

~/opt/anaconda3/envs/mne/lib/python3.9/site-packages/mne/io/base.py in _repr_html_(self, caption)
   1761 
   1762 def _repr_html_(self, caption=None):
-> 1763 basenames = [os.path.basename(f) for f in self._filenames]
   1764 m, s = divmod(self._last_time - self.first_time, 60)
   1765 h, m = divmod(m, 60)

~/opt/anaconda3/envs/mne/lib/python3.9/site-packages/mne/io/base.py in <listcomp>(.0)
   1761 
   1762 def _repr_html_(self, caption=None):
-> 1763 basenames = [os.path.basename(f) for f in self._filenames]
   1764 m, s = divmod(self._last_time - self.first_time, 60)
   1765 h, m = divmod(m, 60)

~/opt/anaconda3/envs/mne/lib/python3.9/posixpath.py in basename(p)
    140 def basename(p):
    141 """Returns the final component of a pathname"""
--> 142 p = os.fspath(p)
    143 sep = _get_sep(p)
    144 i = p.rfind(sep) + 1

TypeError: expected str, bytes or os.PathLike object, not NoneType

```

Could someone help me understand what is going on? Thank you!

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 29, 2021, 11:28pm UTC](https://mne.discourse.group/t/issue-with-set-montage/3873/2 "2021-10-29T23:28:06Z")

</div>

Hello @chapochn and welcome to the forum!

This behavior is a [bug](https://github.com/mne-tools/mne-python/issues/9865) that has recently been fixed in the development version of MNE-Python; the bugfix will be included in MNE-Python 0.24, which will be released in a few days.

As a workaround for now, avoid having a function or method return a `Raw` object in the last line of a Jupyter cell / in the IPython interpreter. Specifically what you can do is, instead of:

```python
raw.set_montage(montage)

```

do e.g.

```python
raw.set_montage(montage)
print(raw)

```

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![chapochn](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/chapochn/32/915_2.png) [@chapochn](https://mne.discourse.group/u/chapochn)\
**Post date:** [October 29, 2021, 11:50pm UTC](https://mne.discourse.group/t/issue-with-set-montage/3873/3 "2021-10-29T23:50:21Z")

</div>

Thank you very much for the quick and helpful answer!
