mne-tools / mne-nirs

Process Near-Infrared Spectroscopy Data in MNE
https://mne.tools/mne-nirs/
BSD 3-Clause "New" or "Revised" License
79 stars 35 forks source link

Error while reading snirf data #393

Closed LeiGuo0812 closed 2 years ago

LeiGuo0812 commented 2 years ago

Describe the bug

I am trying to use the mne_nirs module to process my fNIRS data. My device is NIRx and it provides snirf output. However, when I use the function mne.io.read_raw_snirf( ), it threw a valueError.

Steps to reproduce

mne.io.read_raw_snirf('bug_demo.snirf')

Expected results

Data loaded

Actual results


ValueError Traceback (most recent call last)

c:\Users\GuoLei\Desktop\test_wtc\data_preprocess.py in

----> 7 data1 = mne.io.read_raw_snirf('./whu0001_001/whu0001_001.snirf',preload=True)

D:\Softwares\Anaconda3\envs\data_analysis\lib\site-packages\mne\io\snirf_snirf.py in read_raw_snirf(fname, preload, verbose)

 45     mne.io.Raw : Documentation of attribute and methods.

 46     """

---> 47 return RawSNIRF(fname, preload, verbose)

 48 

 49 
in __init__(self, fname, preload, verbose) D:\Softwares\Anaconda3\envs\data_analysis\lib\site-packages\mne\io\snirf\_snirf.py in __init__(self, fname, preload, verbose) 270 else: 271 extra_ps[f'EEG{len(extra_ps) + 1:03d}'] = diglocs[idx] --> 272 info['dig'] = _make_dig_points(nasion=nasion, lpa=lpa, rpa=rpa, 273 hpi=hpi, dig_ch_pos=extra_ps, 274 coord_frame=_frame_to_str[ D:\Softwares\Anaconda3\envs\data_analysis\lib\site-packages\mne\io\_digitization.py in _make_dig_points(nasion, lpa, rpa, hpi, extra_points, dig_ch_pos, coord_frame) 375 lpa = np.asarray(lpa) 376 if lpa.shape != (3,): --> 377 raise ValueError('LPA should have the shape (3,) instead of %s' 378 % (lpa.shape,)) 379 dig.append({'r': lpa, 'ident': FIFF.FIFFV_POINT_LPA, ValueError: LPA should have the shape (3,) instead of (4,) --------------------------------------------------------------------------- #### Additional information mne.sys_info() Platform: Windows-10-10.0.22000-SP0 Python: 3.9.5 (default, May 18 2021, 14:42:02) [MSC v.1916 64 bit (AMD64)] Executable: D:\Softwares\Anaconda3\envs\data_analysis\python.exe CPU: Intel64 Family 6 Model 142 Stepping 12, GenuineIntel: 8 cores Memory: 15.8 GB mne: 0.23.0 numpy: 1.20.2 {blas=mkl_rt, lapack=mkl_rt} scipy: 1.6.2 matplotlib: 3.3.4 {backend=module://ipykernel.pylab.backend_inline} sklearn: 0.24.2 numba: Not found nibabel: 3.2.1 nilearn: 0.8.0 dipy: Not found cupy: Not found pandas: 1.2.5 mayavi: Not found pyvista: Not found vtk: 9.0.3 PyQt5: 5.9.2 ### Bug demo file link of google drive Here below you can find my newly acquired data and the header file that can reproduce this bug: https://drive.google.com/file/d/1LeuEw0Q9X1VCcMxzESZLz6s-IKbn6-dh/view?usp=sharing, https://drive.google.com/file/d/1aDQB-6ugB4EYC1GvNyLJi0U-b2AsD4Yc/view?usp=sharing
rob-luke commented 2 years ago

Hi @LeiGuo0812, thanks for taking the time to try MNE-NIRS and reporting this issue. Your report was very clear.

Looking at your system output I think the issue is that you are using the release version of MNE-Python, but you need the development version. You can see the update instructions at https://mne.tools/dev/install/updating.html#upgrading-to-the-development-version but in short you need to run...

pip install -U https://github.com/mne-tools/mne-python/archive/main.zip

Can you please let me know if this solves your issue.


On a side note. Soon there will be a new stable release of MNE-Python, and then the installation procedure will be much simpler. We are actively working on making this a smoother process for users. Thanks for the patience.

rob-luke commented 2 years ago

Ok @LeiGuo0812 it was not a version issue, I just downloaded your file and I get the same issue with the following system info...

Platform:      macOS-10.15.7-x86_64-i386-64bit
Python:        3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:13:15)  [Clang 11.1.0 ]
Executable:    /Users/rluke/opt/anaconda3/envs/mne/bin/python
CPU:           i386: 16 cores
Memory:        32.0 GB

mne:           0.24.dev0
numpy:         1.20.2 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:         1.6.3
matplotlib:    3.4.2 {backend=MacOSX}

sklearn:       0.24.2
numba:         0.53.1
nibabel:       3.2.1
nilearn:       0.8.1.dev
dipy:          1.4.1
cupy:          Not found
pandas:        1.2.4
mayavi:        4.7.2
pyvista:       0.30.1 {pyvistaqt=0.4.0, OpenGL 4.1 ATI-3.10.18 via AMD Radeon RX 570 OpenGL Engine}
vtk:           9.0.1
PyQt5:         5.12.3

I will dig a bit deeper, please hold the line....

rob-luke commented 2 years ago

@LeiGuo0812 can you list exactly the NIRx system and software that you have please

rob-luke commented 2 years ago

Ok I found the issue. The files you have use the optional 4th column of index in the SNIRF specification for landmark positions. I have made the required change in the PR above to fix this for you.

Once the fix is merged I will ping back here and ask you to test it again @LeiGuo0812

rob-luke commented 2 years ago

@LeiGuo0812 this should now be fixed. Could you please update mne-python and try again. Update using ...

pip install -U https://github.com/mne-tools/mne-python/archive/main.zip

Please report back here if this solves your problem or not.

LeiGuo0812 commented 2 years ago

Dear Robert : I tested on my original data and the newly acquired data today, and it worked very well without any error. Thank you very much for your quick response and effort! Best wishes!

Lei Guo

At 2021-09-25 19:51:27, "Robert Luke" @.***> wrote:

@LeiGuo0812 this should now be fixed. Could you please update mne-python and try again. Update using ...

pip install -U https://github.com/mne-tools/mne-python/archive/main.zip

Please report back here if this solves your problem or not.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

rob-luke commented 2 years ago

🎉