mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Reading in bvct digitizer file without LPA and RPA throws key error

Open MatthewChen37 opened this issue 9 months ago • 6 comments

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

MatthewChen37 avatar Feb 14 '25 21:02 MatthewChen37

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

welcome[bot] avatar Feb 14 '25 21:02 welcome[bot]

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.

sappelhoff avatar Feb 15 '25 19:02 sappelhoff

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.

MatthewChen37 avatar Feb 17 '25 19:02 MatthewChen37

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 ?

sappelhoff avatar Feb 17 '25 20:02 sappelhoff

Sure, I'll try to see if I can contact the authors first.

MatthewChen37 avatar Feb 20 '25 01:02 MatthewChen37

Any news on this @MatthewChen37?

sappelhoff avatar Apr 17 '25 08:04 sappelhoff