Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MatthewChen37 opened this issue Feb 14, 2025 · 5 comments
Open
Labels

Comments

@MatthewChen37
Copy link

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

Copy link

welcome bot commented Feb 14, 2025

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

@sappelhoff
Copy link
Member

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.

@MatthewChen37
Copy link
Author

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.

@sappelhoff
Copy link
Member

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 ?

@MatthewChen37
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants