How to pick channels by their location in brain region?

Hi,

I have 5 subjects with ieeg data. I realized that the channel location is different for each subject as below:

Now I want to do comparative study of subject 73, 76, 77 using only the channels on the right hemisphere of the brain, and for subject 71 and 79 for left hemisphere channels. How can I pick channels from a specific hemisphere?

Thanks

  • MNE version: e.g. 0.24.0
  • operating system: e.g. macOS 12 / Windows 10 / Ubuntu 18.04

I’m curious too if this is implementable on MNE side, so following this thread…

The first thing that comes to mind is that sEEG electrodes are generally named by the side that they are implanted on e.g. LPLI 6 is a typical channel name. If that’s your naming scheme, you could just take the channels that start with L.

Otherwise, the channels in mri coordinates will be in RAS (right anterior superior). The first dimension is right left and values greater than 0 will be right (since it’s zero-centered). So if you do something like

montage = raw.get_montage()
montage.apply_trans(trans)  # needs to be in MRI not head, although head might work too
pos = montage.get_positions()['ch_pos']
right = [ch for ch, pos in ch_pos.items() if pos[0] >=0]

that should get you the correct channels.

3 Likes

Thanks for the help. The channel names are ;
J’2", β€œJ’3”, β€œJ’4”, β€œJ’5”, β€œJ’6”, β€œJ’7”, β€œJ’8”, β€œB’2”, β€œB’3”, β€œB’4”, β€œB’5”, β€œB’6”, β€œB’7”, β€œB’8”, β€œB’9”, β€œB’10”, β€œB’11”, β€œB’12”, β€œC’2”, β€œC’3”, β€œC’4”, β€œC’5”, β€œC’6”, β€œC’7”, β€œC’8”, β€œC’9”, β€œC’10”, β€œC’11”, β€œC’12”, β€œD’2”, β€œD’3”, β€œD’4”, β€œD’5”, β€œD’6”, β€œD’7”, β€œD’8”, β€œD’9”, β€œD’10”, β€œD’11”, β€œD’12”, β€œE’2”, β€œE’3”, β€œE’4”, β€œE’5”, β€œE’6”, β€œE’7”, β€œE’8”, β€œE’9”, β€œE’10”, β€œE’11”, β€œE’12”, β€œT’2”, β€œT’3”, β€œT’4”, β€œT’5”, β€œT’6”, β€œT’7”, β€œT’8”, β€œL’2”, β€œL’3”, β€œL’4”, β€œL’5”, β€œL’6”, β€œL’7”, β€œL’8”, β€œL’9”, β€œL’10”, β€œL’11”, β€œL’12”, β€œH’2”, β€œH’3”, β€œH’4”, β€œH’5”, β€œH’6”, β€œH’7”, β€œH’8”, β€œO’2”, β€œO’3”, β€œO’4”, β€œO’5”, β€œO’6”, β€œO’7”, β€œO’8”, β€œO’9”, β€œO’10”, β€œO’11”, β€œO’12”, β€œO’13”, β€œO’14”, β€œO’15”, β€˜B2’, β€˜B3’, β€˜B4’, β€˜B5’, β€˜B6’, β€˜B7’, β€˜B8’, β€˜B9’, β€˜B10’, β€˜B11’, β€˜B12’]

I do not understand how to interpret the side by looking at the name. How can I find their side by looking the names.

Thanks.

Looks like one-letter identifiers were used so that’s not possible, you’ll have to use the second approach.

You can also use mne.get_montage_volume_labels β€” MNE 1.1.dev0 documentation to get the labels for each electrode contact using the Freesurfer reconstruction which will have rights and lefts in them.

2 Likes

Tha dataset also contains a TSV file with MNI coordinates for each subject. Can I get any help from this file? If yes, please tell how?

Thanks

MNI coordinates should also be in RAS so if the first coordinate is greater than 0, it should be on the right.

1 Like

The coordinates are given as:

name x y z
A1 18.1 -4.44 -19.84
A2 21.42 -4.32 -19.69
A3 24.74 -4.27 -19.52
A4 28.14 -4.33 -19.34

So you mean if x>0, it is right and x<0 implies left hemisphere? Thanks

So you mean if x>0, it is right and x<0 implies left hemisphere?

This is right. Normally the center of the brain is zero.

I notice that the group name of your channels is like A or A’.
The clinicians I collaborate with always set group names as A, B, C… in the left hemi and A’, B’, C’ … in the right hemi. So you may find the hemi based on the group name.
But the coordinates are more accurate.

I suppose you want to analyze some channels in some specific regions, if so, the hemi’s info is not enough. The labels of the brain regions are still needed.

1 Like

I wrote some code to find the group name of contacts. It may be helpful to you.


def get_chan_group(chans, exclude=None, return_df=False):
    """Group iEEG channel
    Parameters
    ----------
    chans: list
        channels' name
    exclude: list
        channels need to be excluded
    Returns
    -------
    chan_group: dict  group: channels
        channels belong to each group
    """
    import re

    if isinstance(exclude, list):
        [chans.pop(chans.index(ch)) for ch in exclude]

    group_chs = dict()
    for ch in chans:
        match = r"([a-zA-Z]+')" if "'" in ch else r"([a-zA-Z]+)"
        group = re.match(match, ch, re.I).group()
        if group not in group_chs:
            group_chs[group] = [ch]
        else:
            group_chs[group].append(ch)
    return group_chs

You can use it easily. Like if the clinicians set groups like A in the left hemi and Aβ€˜ in the right hemi.
Just

chs = raw.ch_names
group_chs = get_chan_group(chans=chs)
right_hemi_chs = []
for group in group_chs:
    if "'" in group:
        right_hemi_chs += group_chs[group]
if len(right_hemi_chs):
    raw.pick_channels(right_hemi_chs)
1 Like

Thanks a lot for your help and detailed explanation.