Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Unknolwn opened this issue Apr 27, 2023 · 6 comments
Open

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

Unknolwn opened this issue Apr 27, 2023 · 6 comments
Labels

Comments

@Unknolwn
Copy link

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

@Unknolwn Unknolwn added the BUG label Apr 27, 2023
@welcome
Copy link

welcome bot commented Apr 27, 2023

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

@larsoner
Copy link
Member

the following MNE filtering function stops working when I do

To me it looks like it's the reading function that fails much earlier than the filtering function. Can you confirm that the failure is actually up at the read_raw_bids step?

@hoechenberger
Copy link
Member

To me it looks like it's the reading function that fails

Yes, according to the traceback, this issue has nothing to do with filtering. The issue should be transferred over to mne-tools/mne-bids

@Unknolwn
Copy link
Author

Oh, okay, I'm going to do that

@Unknolwn
Copy link
Author

I found this issue (mne-tools/mne-bids#1117) on MNE_BIDS that looks like mine but the conclusion seems to lead back to MNE-python.

@larsoner
Copy link
Member

In mne-tools/mne-bids#1117 I think the conclusion was that MNE-BIDS needs to take care of ordering differences between the data and channels.tsv. Not sure if it's the same problem, will have to test...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants