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

BIDS electrodes.tsv import leads to incorrect chanlocs when channels.tsv and electrodes.tsv include different extra entries #236

Open
kacross opened this issue Feb 4, 2025 · 7 comments
Assignees

Comments

@kacross
Copy link

kacross commented Feb 4, 2025

When loading BIDS folder to a study the channels are incorrect when the electrodes.tsv and channels.tsv are different.

Extra channels in EEG data that are not in electrodes.tsv (e.g. audio input, auxiliary response device) in combination with extra electrode entries that are not in channels.tsv (e.g. CZ=ref electrode location from 3D cap photo) leads to inappropriate assignment of extra channels in chanlocs due to assumed equivalent row indexing of electrodes.tsv and channels.tsv (lines 52-59 of bids_importchanlocs.m). See attached example where CZ=ref electrode location is included in electrodes.tsv and channels.tsv has different extra channels for audio and auxiliary response device inputs. [attached as .txt as git doesn't allow me to include .tsv files]

Behavior is different when loading the individual file using pop_fileio. This appears to correctly import the same example by matching electrode and channel names (lines 282 - 300).

sub-CM40_task-reaching_run-1_electrodes.txt
sub-CM40_task-reaching_run-1_channels.txt

@arnodelorme
Copy link
Collaborator

@neuromechanist would you mind to have a look?

@neuromechanist
Copy link
Member

@arnodelorme,
This is the problem we discussed two weeks ago about EEG-BIDS not providing a clear linkage between channels.tsv and electrodes.tsv. This is from the BIDS specifications:

the entries in *_electrodes.tsv and *_channels.tsv do not have to match exactly, as for example in the case of recording a single EOG channel from a bipolar referencing scheme of two electrodes, or a data channel originating from an auxiliary, non-electrode device. That is, in most cases *_electrodes.tsv will have more entries than *_channels.tsv.

Without a clear specification, we should anticipate several scenarios, when channels.tsv and electrodes.tsv:

  1. have the same order of channels and electrodes, respectively
  2. have the same channels and electrodes, but out of order
  3. there are more channels than electrodes, like the example above with audio and pressure sensor channels
  4. there are more electrodes than channels, for example, with some bipolar electrodes like EOG, creating fewer channels (the case that the specification was anticipating).

We are addressing this issue on EMG-BIDS (bids-standard/bids-specification#1371) by adding a signal_electrode to the channels.tsv, as can be seen in the example pull request, subject 5: bids-standard/bids-examples#480.

I linked this issue to BIDS-specifications as well bids-standard/bids-specification#2041

@neuromechanist neuromechanist self-assigned this Feb 4, 2025
@arnodelorme
Copy link
Collaborator

@robertoostenveld can you comment on what you think of that issue for EEG?

@kacross
Copy link
Author

kacross commented Feb 4, 2025 via email

@robertoostenveld
Copy link

channels are something inside the amplifier, electrodes are something on the head, as explained on https://bids-specification.readthedocs.io/en/stable/modality-specific-files/electroencephalography.html

There can be both situations where the number of electrodes is larger, the number of channels is larger, or where they are the exactly same (although the latter is unlikely, since voltage is by definition a differential measurement between two electrodes).

For EEG data recorded with a unipolar montage we usually name channels according to the electrode that makes the channel unique (i.e. channel C3 is connected to electrode C3), where the voltage in the channel correspond to the voltage at that specific electrode minus the voltage at the common reference. The channels.tsv file supports this, as you can specify the name of the electrode as the name of the channel and the reference as EEGReference in the eeg.json file. If the reference is not common to all channels, then the reference can be specified per channel in the reference column in the channels.tsv file.

If a common EEG reference is used, the channel-to-electrodeposition mapping (for topographic plotting) is straightforward. If different references are used for different channels, it gets more complex. And channels that are not on the scalp (like triggers) don't have a position of course and should not be included in a topographic display.

@robertoostenveld
Copy link

Dear @kacross, is the problematic dataset (or part of it) somewhere available online? I would like to see how FieldTrip would deal with it.

@kacross
Copy link
Author

kacross commented Feb 13, 2025

@robertoostenveld It is not yet fully converted, but I have put a run from one subject at this link

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

No branches or pull requests

4 participants