Hi,
I am working on converting some meg data to BIDS format using mne-bids based on this tutorial.
When I execute the following code snippet I get the error below. Basically the ‘chpi’ channel type in the raw data is not recognized by write_raw_bids.
raw = mne.io.read_raw_fif(raw_fname)
raw.info[‘line_freq’] = 50 # specify power line frequency as required by BIDS
events = mne.find_events(raw)
events = events[np.isin(events[:,2], list(event_id.values())), :]
bids_path = BIDSPath(subject=‘01’, task=‘wordreport’, run=‘01’, root=output_path)
write_raw_bids(raw, bids_path, events_data=events, event_id=event_id, overwrite=True)
KeyError Traceback (most recent call last)
/imaging/davis/users/ma09/Projects/AVSpeechMEG/code/analysis/mne-bids_data_conversion.ipynb Cell 3’ in <cell line: 11>()
10 bids_path = BIDSPath(subject=‘01’, task=‘wordreport’, run=‘01’, root=output_path)
—> 11 write_raw_bids(raw, bids_path, events_data=events, event_id=event_id, overwrite=True)
File :12, in write_raw_bids(raw, bids_path, events_data, event_id, anonymize, format, symlink, empty_room, allow_preload, montage, acpc_aligned, overwrite, verbose)
File ~/.local/lib/python3.10/site-packages/mne_bids/write.py:1668, in write_raw_bids(failed resolving arguments)
1663 make_dataset_description(bids_path.root, name=" ", overwrite=False)
1665 _sidecar_json(raw, task=bids_path.task, manufacturer=manufacturer,
1666 fname=sidecar_path.fpath, datatype=bids_path.datatype,
1667 emptyroom_fname=associated_er_path, overwrite=overwrite)
→ 1668 _channels_tsv(raw, channels_path.fpath, overwrite)
1670 # create parent directories if needed
1671 _mkdir_p(os.path.dirname(data_path))
File ~/.local/lib/python3.10/site-packages/mne_bids/write.py:120, in _channels_tsv(raw, fname, overwrite)
118 if _channel_type in get_specific:
119 _channel_type = coil_type(raw.info, idx, _channel_type)
→ 120 ch_type.append(map_chs[_channel_type])
121 description.append(map_desc[_channel_type])
122 low_cutoff, high_cutoff = (raw.info[‘highpass’], raw.info[‘lowpass’])
KeyError: ‘chpi’
System details:
- MNE version: 1.1.1
- operating system: Ubuntu 20.04.3 LTS (Focal Fossa) 64-bit
- MEG system: Elekta
One solution which works is to remove the chpi channels, but I suspect that these channels are necessary for maxfiltering (which we intend to do with the mne-bids-pipeline), so ideally we would like to keep them.
Could anyone suggest a solution please?
Many thanks,
Máté