mne-tools / mne-tools/mne-python

mne.io.Raw.filter Error with NIRS data

Open
#11,660 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

BUG
Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

Description of the problem

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
Steps to reproduce
Here is an example of a working code with MNE 1.0.3 but with MNE 1.1 or 1.3 I have a warning with same function : 
import mne
import mne_bids
import mne_nirs
#steps to import data
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)
#convert data
OD=mne.preprocessing.nirs.optical_density(raw_data)
Conc=mne.preprocessing.nirs.beer_lambert_law(OD,ppf=6)
#filter data
Filtered=Conc.copy().filter(0.05,0.1, l_trans_bandwidth=0.01, h_trans_bandwidth=0.01, verbose=False)
Link to data

You can find NIRS dataset here: https://osf.io/b4wck/

Expected results

Filtered data with only this warning:
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.,

Actual results

Result with MNE 1.3:

File "", line 1, in
File "", 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 "", 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 "", 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

Additional information

Platform: Windows-10-10.0.19044-SP0
mne: 1.0.3
numpy: 1.22.3 {}
scipy: 1.10.1
matplotlib: 3.7.1 {backend=TkAgg}

sklearn: 1.2.2
numba: Not found
nibabel: 5.1.0
nilearn: 0.10.0
dipy: Not found
cupy: Not found
pandas: 2.0.0
pyvista: Not found
pyvistaqt: Not found
ipyvtklink: Not found
vtk: Not found
PyQt5: Not found
ipympl: Not found
pooch: v1.7.0

mne_bids: 0.10
mne_nirs: 0.5.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported failure using the OSF dataset and the NIRS import path in read_raw_bids. Start with _handle_channels_reading in mne_bids/read.py and the rename_channels call in mne/channels/channels.py, then determine whether the duplicate-name failure belongs in mne-python or mne-bids. Done means the package ownership and expected behavior are clear, with a regression test identified or added for the confirmed issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.