mne-python
mne-python copied to clipboard
Reading in bvct digitizer file without LPA and RPA throws key error
Describe the new feature or enhancement
Hi,
I was trying to read a .bvct file and make a DigitMontage from it, but I noticed that _parse_brainvision_dig_montage in _dig_montage_utils.py assumes that an LPA and RPA coordinate is in the CapTrackElectrodeList. I don’t think this should be a rigid assumption since mne.channels.make_dig_montage can take in an LPA and RPA that are none. I was wondering if it was possible to change the implementation in _parse_brainvision_dig_montage from:
return dict( # BVCT stuff nasion=fids["nasion"], lpa=fids["lpa"], rpa=fids["rpa"], ch_pos=dig_ch_pos, coord_frame="unknown", )
to
return dict( # BVCT stuff nasion=fids.get("nasion", None), lpa=fids.get("lpa", None), rpa=fids.get("rpa", None), ch_pos=dig_ch_pos, coord_frame="unknown", )
as this would prevent the function from throwing a key error if no LPA or RPA exist within the bvct file.
Describe your proposed implementation
return dict( # BVCT stuff nasion=fids["nasion"], lpa=fids["lpa"], rpa=fids["rpa"], ch_pos=dig_ch_pos, coord_frame="unknown", )
to
return dict( # BVCT stuff nasion=fids.get("nasion", None), lpa=fids.get("lpa", None), rpa=fids.get("rpa", None), ch_pos=dig_ch_pos, coord_frame="unknown", )
Describe possible alternatives
Please let me know if there are alternatives for defaulting dictionary key access values in Python as I typically use this to resolve to access a key that doesn't exist
Additional context
No response
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴
Thanks for the report.
Out of curiosity: How did you get a BrainVision CapTrak file without LPA and RPA? As far as I know, the CapTrak device always collects data on LPA and RPA, as the internally used coordinate system depends on these two points.
I am working with the dataset from this paper: https://www.nature.com/articles/sdata201874. I received the dataset after contacting the authors, so I am not sure how they modified the bvct files to remove those two electrodes.
Thanks, I also downloaded that data now and had a look. It seems to be organized slightly differently to the CapTrak data that I collected some years back, see for example: https://gin.g-node.org/sappelhoff/mpib_sp_eeg/src/master/sourcedata/sub-01/coords/CapTrakResultFile_sub-01.bvct
I think we should
- contact the authors about their exact procedure of measuring
- contact brain products support as to why LPA and RPA are not supplied and whether this is normal
Would you be willing to do that @MatthewChen37 ?
Sure, I'll try to see if I can contact the authors first.
Any news on this @MatthewChen37?