mne.io.Raw.filter Error with NIRS data

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

  • 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.

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 :

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:

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

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