Reputation: 1263
I've loaded some EEG data using Python's MNE package. The data has 46 recording channels obtained from a 10-20 montage, but we've identified numerous dead channels and only want to focus on the remaining ones.
I'm able to remove the channels, but I can't figure out how to plot the updated montage.
First I load my edf file, make a copy and drop the desired channels:
import mne as mn
raw = mn.io.read_raw_edf("patient_001.edf",preload=True)
raw_temp=raw.copy()
raw_temp.drop_channels(['E', 'LIO', 'RIO', 'X1', 'X2',
'X3','X4''X5', 'X6', 'X7', 'X8', 'X9', 'X10', 'X11', 'O2%', 'HR',
'DC03','DC04', 'EEG Mark1', 'EEG Mark2', 'BP1', 'BP2','STI 014'])
I checked and the channels are removed. What I want to now do is plot an updated montage using only my remaining 23 channels:
raw_temp.info["ch_names"]
['Fp1', 'Fp2', 'F3', 'F4', 'C3', 'C4', 'P3', 'P4', 'O1', 'O2', 'F7', 'F8', 'T7', 'T8', 'P7', 'P8', 'Fz', 'Cz', 'Pz', 'A1', 'A2', 'T1', 'T2']
From my extremely limited knowledge of channel placement, I understand letters represent locations and digits represent hemispheres, e.g. F4 denotes frontal lobe, right side.
The following prints the montage for a 10-20 93-channel layout:
montage = mn.channels.read_montage("standard_1020")
raw_temp.set_montage(montage)
montage.plot()
Other montage options are listed at
https://github.com/mne-tools/mne-python/blob/master/mne/channels/montage.py
but I don't see a 46 channel option.
Is there a way to plot the montage for my 23 channels somehow?
Upvotes: 5
Views: 4860
Reputation: 149
attention: ind = [i for (i, channel) in enumerate(mont1020.ch_names) prints: this is ind : [0, 2, 15, 17, 19, 21, 23, 39, 41, 43, 61, 63, 65, 80, 81, 82, 86, 87, 88, 89]
ind = [channel for (i, channel) in enumerate(mont1020.ch_names) prints: this is ind : ['Fp1', 'Fp2', 'F7', 'F3', 'Fz', 'F4', 'F8', 'C3', 'Cz', 'C4', 'P3', 'Pz', 'P4', 'O1', 'Oz', 'O2', 'T3', 'T5', 'T4', 'T6']
Upvotes: 0
Reputation: 26
When reading the raw eeg file, you should assign a montage to your raw data (you can also do it after you create the epochs). This can be done using the coordinates of each electrode and some fiducial points (see https://mne.tools/stable/generated/mne.channels.make_dig_montage.html#mne.channels.make_dig_montage). If your data is taken from the standard 10-20 system then you can use the built in function mne.channels.make_standard_montage('standard_1020')
to obtain the 93 channel montage and then keep only the electrodes you are interested in using the code below:
# Form the 10-20 montage
mont1020 = mne.channels.make_standard_montage('standard_1020')
# Choose what channels you want to keep
# Make sure that these channels exist e.g. T1 does not exist in the standard 10-20 EEG system!
kept_channels = ['Fp1', 'Fp2', 'F3', 'F4', 'C3', 'C4', 'P3', 'P4', 'O1', 'O2', 'F7', 'F8', 'T7', 'T8', 'P7', 'P8', 'Fz', 'Cz', 'Pz', 'A1', 'A2', 'T1', 'T2']
ind = [i for (i, channel) in enumerate(mont1020.ch_names) if channel in kept_channels]
mont1020_new = mont1020.copy()
# Keep only the desired channels
mont1020_new.ch_names = [mont1020.ch_names[x] for x in ind]
kept_channel_info = [mont1020.dig[x+3] for x in ind]
# Keep the first three rows as they are the fiducial points information
mont1020_new.dig = mont1020.dig[0:3]+kept_channel_info
mont1020.plot()
mont1020_new.plot()
I would suggest that you assign a montage (see to the raw data before rejecting any channels. In this way, after dropping bad channels you can very easily get the updated montage at any point of the preprocessing using:
raw = raw.set_montage(mont)
updated_mont = raw.get_montage() #also works with epo.get_montage()
Then you can simply plot the updated montage:
updated_mont.plot()
Upvotes: 1
Reputation: 108
If you only want to plot the electrode layout, you can use the Layout
class instead of the Montage
class:
import mne
layout = mne.channels.read_layout("EEG1005")
selection = [
"Fp1",
"Fp2",
"F3",
"F4",
"C3",
"C4",
"P3",
"P4",
"O1",
"O2",
"F7",
"F8",
"T7",
"T8",
"P7",
"P8",
"Fz",
"Cz",
"Pz",
"A1",
"A2",
"T1",
"T2",
]
picks = []
for channel in selection:
picks.append(layout.names.index(channel))
display = layout.plot(picks=picks)
which gives you at least for mne==0.18.0
.
Upvotes: 2