mne-tools / mne-bids

MNE-BIDS is a Python package that allows you to read and write BIDS-compatible datasets with the help of MNE-Python.
https://mne.tools/mne-bids/
BSD 3-Clause "New" or "Revised" License
132 stars 87 forks source link

ValueError: Unknown coil of type 5 for channel EOG061 #95

Closed nblauch closed 6 years ago

nblauch commented 6 years ago

I'm using MNE-bids on an MEG dataset. The output and traceback sequence are given below.

Opening raw data file /home/nicholasblauch/MEG/FST/orig/sub-01/ses-03/FST_ER3.fif...
This filename (/home/nicholasblauch/MEG/FST/orig/sub-01/ses-03/FST_ER3.fif) does not conform to MNE naming conventions. All raw files should end with raw.fif, raw_sss.fif, raw_tsss.fif, raw.fif.gz, raw_sss.fif.gz or raw_tsss.fif.gz
    Read a total of 14 projection items:
        mag_ssp.fif : PCA-v1 (1 x 306)  idle
        mag_ssp.fif : PCA-v2 (1 x 306)  idle
        mag_ssp.fif : PCA-v3 (1 x 306)  idle
        mag_ssp.fif : PCA-v4 (1 x 306)  idle
        mag_ssp.fif : PCA-v5 (1 x 306)  idle
        mag_ssp.fif : PCA-v6 (1 x 306)  idle
        mag_ssp.fif : PCA-v7 (1 x 306)  idle
        mag_ssp.fif : PCA-v8 (1 x 306)  idle
        mag_ssp.fif : PCA-v9 (1 x 306)  idle
        grad_ssp.fif : PCA-v1 (1 x 306)  idle
        grad_ssp.fif : PCA-v2 (1 x 306)  idle
        grad_ssp.fif : PCA-v3 (1 x 306)  idle
        grad_ssp.fif : PCA-v4 (1 x 306)  idle
        grad_ssp.fif : PCA-v5 (1 x 306)  idle
    Range : 45000 ... 166999 =     45.000 ...   166.999 secs
Ready.
Current compensation grade : 0
Creating folder: /home/nicholasblauch/MEG/FST/sub-01/ses-01/meg
<ipython-input-87-05598c422f8f>:19: RuntimeWarning: This filename (/home/nicholasblauch/MEG/FST/orig/sub-01/ses-03/FST_ER3.fif) does not conform to MNE naming conventions. All raw files should end with raw.fif, raw_sss.fif, raw_tsss.fif, raw.fif.gz, raw_sss.fif.gz or raw_tsss.fif.gz
  raw_file=full_raw_file, output_path=output_path, overwrite=True)

Writing '/home/nicholasblauch/MEG/FST/dataset_description.json'...

{
    "Name": " ",
    "BIDSVersion": "1.1.1 (draft)"
}
Traceback (most recent call last):

  File "<ipython-input-87-05598c422f8f>", line 19, in <module>
    raw_file=full_raw_file, output_path=output_path, overwrite=True)

  File "/home/nicholasblauch/anaconda3/envs/mne/lib/python3.6/site-packages/mne_bids/mne_bids.py", line 626, in raw_to_bids
    eeg_gnd, verbose)

  File "/home/nicholasblauch/anaconda3/envs/mne/lib/python3.6/site-packages/mne_bids/mne_bids.py", line 450, in _sidecar_json
    ('EEGPlacementScheme', _infer_eeg_placement_scheme(raw)),

  File "/home/nicholasblauch/anaconda3/envs/mne/lib/python3.6/site-packages/mne_bids/utils.py", line 542, in _infer_eeg_placement_scheme
    if coil_type(raw.info, ch_idx) == 'eeg':

  File "/home/nicholasblauch/anaconda3/envs/mne/lib/python3.6/site-packages/mne_bids/pick.py", line 70, in coil_type
    'for channel {1}'.format(ch['coil_type'], ch["ch_name"]))

ValueError: Unknown coil of type 5 for channel EOG061

Any idea how to fix this?

thanks, Nick

jasmainak commented 6 years ago

If you do:

from mne.io.pick import channel_type
from mne import pick_channels

pick = pick_channels(raw.info['ch_names'], ['EOG061'])
ch_type = channel_type(raw.info, pick)
print(ch_type)

what do you get?

nblauch commented 6 years ago

'eog'

jasmainak commented 6 years ago

see proposed fix in #96

give it a try again once we merge this pull request :)

monkeyman192 commented 6 years ago

Do we not just need to add the new type to the pick list in mne_bids?

monkeyman192 commented 6 years ago

To elaborate: coil type 5 is: FIFF.FIFFV_COIL_EEG_BIPOLAR = 5 # Bipolar EEG lead When I did the more specific channels pick function I didn't add any of the specific eeg ones, so I think we just need to add this coil type to the list.

sappelhoff commented 6 years ago

@monkeyman192 Mainak's solution in #96 looks good to me, but I think it'd be good to add the coil type regardless of how the issue is solved. Could you do that?

monkeyman192 commented 6 years ago

I can do, but I am far less familiar with EEG systems. If it is immediately obvious to you what the type should be perhaps it would be better for you to add it? like, is this channel an eeg or eog channel?

sappelhoff commented 6 years ago

like, is this channel an eeg or eog channel?

Unfortunately, it could be both ... EOG channels are often recorded bipolar (almost always) ... but EEG channels can also have a bipolar referencing scheme ... I am not at all familiar with all these FIF types, that's why I asked you to do it - perhaps I'll have to look into it.

nblauch commented 6 years ago

Given the channel name 'EOG061', isn't it likely to be EOG? Wish I could be more helpful - this is my first time analyzing MEG data and I did not collect this set.

jasmainak commented 6 years ago

@monkeyman192 the function coil_type(...) is only for certain channel types it seems, not for EOG. It is so that we can be more precise. We could of course consider extending it for other channel types but in this case, we have a simpler solution :)

sappelhoff commented 6 years ago

Given the channel name 'EOG061', isn't it likely to be EOG?

yes @nblauch, however the underlying FIFF types (e.g., FIFF.FIFFV_COIL_EEG_BIPOLAR) are more general and go beyond your concrete data :-)

Thanks for reporting the issue! It should be fixed now.

jasmainak commented 6 years ago

@nblauch you should update your branch. I think something like:

pip install --upgrade git+https://github.com/mne-tools/mne-bids.git#egg=mne-bids

should work ...

nblauch commented 6 years ago

thank you all. bids conversion worked swimmingly.