# mne.io.Raw.filter Error with NIRS data

**URL:** <https://mne.discourse.group/t/mne-io-raw-filter-error-with-nirs-data/6785>\
**Category:** Support & Discussions\
**Tags:** fnirs\
**Created:** [April 25, 2023, 1:22pm UTC](https://mne.discourse.group/t/mne-io-raw-filter-error-with-nirs-data/6785 "2023-04-25T13:22:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nolwenn](https://avatars.discourse-cdn.com/v4/letter/n/82dd89/32.png) [@Nolwenn](https://mne.discourse.group/u/Nolwenn)\
**Post date:** [April 25, 2023, 1:22pm UTC](https://mne.discourse.group/t/mne-io-raw-filter-error-with-nirs-data/6785/1 "2023-04-25T13:22:09Z")

</div>

Hello, I’m working with NIRS data have trouble updating my code to MNE latest version because of the following MNE filtering function stops working when I do. [mne.io.Raw — MNE 1.2.2 documentation](https://mne.tools/1.2/generated/mne.io.Raw.html#mne.io.Raw.filter)

- MNE version: 1.0.3
- MNE-BIDS version : 0.10
- MNE-NIRS version : 0.5.0
- operating system: Windows 10

Here is an example of a working code : where BPfilt and Conc is respectively a list of instance of Raw filtered data and a list of Raw haemoglobin concentrations.

```python
import mne
import mne_bids
import mne_nirs
BidsPath="C:/datafolder"
dataset = mne_bids.BIDSPath(root=BidsPath, task=mne_bids.get_entity_vals(BidsPath, 'task')[0], datatype="nirs", suffix="nirs", extension=".snirf")
subjects = mne_bids.get_entity_vals(BidsPath, 'subject')
sessions = mne_bids.get_entity_vals(BidsPath,'session')
bids_path=dataset.update(subject=subjects[0])
bids_path=dataset.update(session=sessions[0])
raw_data=mne_bids.read_raw_bids(bids_path=bids_path, extra_params=None, verbose=False)
OD=mne.preprocessing.nirs.optical_density(raw_data)
Conc=mne.preprocessing.nirs.beer_lambert_law(OD,ppf=6)
Filtered=Conc.copy().filter(0.05,0.1, l_trans_bandwidth=0.01, h_trans_bandwidth=0.01, verbose=False)

```

With the above package versions I have a warning but the code runs correctly :

```python
mne\filter.py:312: DeprecationWarning: Keyword argument 'nyq' is deprecated in favour of 'fs' and will be removed in SciPy 1.12.0.
  this_h = firwin(this_N, (prev_freq + this_freq) / 2.,

```

But if I update mne to 1.3 version, the same code fails with this error at the read\_raw\_bids line:

```python
File "<stdin>", line 1, in <module>
  File "<decorator-gen-612>", line 10, in read_raw_bids
  File "C:\environment\lib\site-packages\mne_bids\read.py", line 713, in read_raw_bids
    raw = _handle_channels_reading(channels_fname, raw)
 File "C:\environment\lib\site-packages\mne_bids\read.py", line 552, in _handle_channels_reading
    raw.rename_channels({raw_ch_name: bids_ch_name})
  File "<decorator-gen-43>", line 12, in rename_channels
  File "C:\environment\lib\site-packages\mne\channels\channels.py", line 414, in rename_channels
    rename_channels(self.info, mapping, allow_duplicates)
  File "<decorator-gen-51>", line 12, in rename_channels
  File "C:\environement\lib\site-packages\mne\channels\channels.py", line 1112, in rename_channels
    raise ValueError('New channel names are not unique, renaming failed')
ValueError: New channel names are not unique, renaming failed

```

I tried to change the filter function for another but couldn’t find another. Can you help me identify the problem here ?

Regards,  
Nolwenn

---

<div class="post-metadata">

**Author:** ![Nolwenn](https://avatars.discourse-cdn.com/v4/letter/n/82dd89/32.png) [@Nolwenn](https://mne.discourse.group/u/Nolwenn)\
**Post date:** [May 22, 2023, 8:49am UTC](https://mne.discourse.group/t/mne-io-raw-filter-error-with-nirs-data/6785/2 "2023-05-22T08:49:46Z")

</div>

The error seems to come from mne\_bids, issue addressed here : [Sample NIRS data not read, problem with channel naming · Issue #1117 · mne-tools/mne-bids · GitHub](https://github.com/mne-tools/mne-bids/issues/1117)
