Ploting Topographical maps

  • MNE version: 1.6.1 in google colab
    I am trying to plot topographical map for MI Physionet dataset. The channel names in the montage and dataset vary eventhough I tried changing I am having digitization points error or wrong electrode locations plotted.I have provided the code snippet

original_names = [‘Fp1’, ‘AF7’, ‘AF3’, ‘F1’, ‘F3’, ‘F5’, ‘F7’, ‘FT7’, ‘FC5’, ‘FC3’, ‘FC1’, ‘C1’, ‘C3’, ‘C5’, ‘T7’,
‘TP7’, ‘CP5’, ‘CP3’, ‘CP1’, ‘P1’, ‘P3’, ‘P5’, ‘P7’, ‘P9’, ‘PO7’, ‘PO3’, ‘O1’, ‘Iz’, ‘Oz’, ‘POz’,
‘Pz’, ‘CPz’, ‘Fpz’, ‘Fp2’, ‘AF8’, ‘AF4’, ‘AFz’, ‘Fz’, ‘F2’, ‘F4’, ‘F6’, ‘F8’, ‘FT8’, ‘FC6’, ‘FC4’,
‘FC2’, ‘FCz’, ‘Cz’, ‘C2’, ‘C4’, ‘C6’, ‘T8’, ‘TP8’, ‘CP6’, ‘CP4’, ‘CP2’, ‘P2’, ‘P4’, ‘P6’, ‘P8’,
‘P10’, ‘PO8’, ‘PO4’, ‘O2’]
selected_electrodes = [‘FC5’, ‘FC3’, ‘FC1’,‘FCz’,‘FC2’, ‘FC4’, ‘FC6’, ‘C5’, ‘C3’, ‘C1’, ‘Cz’, ‘C2’, ‘C4’, ‘C6’,‘CP5’, ‘CP3’, ‘CP1’,‘CPz’, ‘CP2’, ‘CP4’, ‘CP6’]
subset_montage = mne.channels.make_standard_montage(‘biosemi64’)
subset_montage.ch_names = selected_electrodes
print(subset_montage.ch_names)
import mne

Define your selected channels

selected_channels = [‘Fc5.’, ‘Fc3.’, ‘Fc1.’, ‘Fcz.’, ‘Fc2.’, ‘Fc4.’, ‘Fc6.’, ‘C5…’, ‘C3…’, ‘C1…’, ‘Cz…’, ‘C2…’, ‘C4…’, ‘C6…’,‘Cp5.’, ‘Cp3.’, ‘Cp1.’, ‘Cpz.’, ‘Cp2.’, ‘Cp4.’, ‘Cp6.’]

Load or create your montage, for example:

montage = mne.channels.make_standard_montage(‘biosemi64’)

Pick only the selected channels from the montage

selected_montage = montage.copy().pick_channels(selected_channels)

Print the selected channels from the new montage

print(“Selected channels from the montage:”, selected_montage.ch_names)

Would you mind formatting your code appropriately so that it is easier to read? Also, please post the error message you are seeing.

The code and the error message as follows:
data1= mne.io.read_raw_edf(‘S002R03.edf’,preload=True)
data = mne.io.concatenate_raws([data1], on_mismatch=‘ignore’)
print(“Original Channel Names:”, data.ch_names)
selected_channels = [‘Fc5.’, ‘Fc3.’, ‘Fc1.’, ‘Fcz.’, ‘Fc2.’, ‘Fc4.’, ‘Fc6.’, ‘C5…’, ‘C3…’, ‘C1…’, ‘Cz…’, ‘C2…’, ‘C4…’, ‘C6…’,‘Cp5.’, ‘Cp3.’, ‘Cp1.’, ‘Cpz.’, ‘Cp2.’, ‘Cp4.’, ‘Cp6.’]
custom_mapping = {‘T1’:1}
(events_needed,event_dict1) = mne.events_from_annotations(data, event_id=custom_mapping)
print(event_dict1)
print(events_needed)
len(events_needed)
epochs = mne.Epochs(data, events_needed, tmin=0, tmax=4.1,proj=False, picks=selected_channels,
baseline=None, preload=True)
evoked = epochs[“1”].average()

original_names = [‘Fp1’, ‘AF7’, ‘AF3’, ‘F1’, ‘F3’, ‘F5’, ‘F7’, ‘FT7’, ‘FC5’, ‘FC3’, ‘FC1’, ‘C1’, ‘C3’, ‘C5’, ‘T7’,
‘TP7’, ‘CP5’, ‘CP3’, ‘CP1’, ‘P1’, ‘P3’, ‘P5’, ‘P7’, ‘P9’, ‘PO7’, ‘PO3’, ‘O1’, ‘Iz’, ‘Oz’, ‘POz’,
‘Pz’, ‘CPz’, ‘Fpz’, ‘Fp2’, ‘AF8’, ‘AF4’, ‘AFz’, ‘Fz’, ‘F2’, ‘F4’, ‘F6’, ‘F8’, ‘FT8’, ‘FC6’, ‘FC4’,
‘FC2’, ‘FCz’, ‘Cz’, ‘C2’, ‘C4’, ‘C6’, ‘T8’, ‘TP8’, ‘CP6’, ‘CP4’, ‘CP2’, ‘P2’, ‘P4’, ‘P6’, ‘P8’,
‘P10’, ‘PO8’, ‘PO4’, ‘O2’]
selected_electrodes = [‘FC5’, ‘FC3’, ‘FC1’,‘FCz’,‘FC2’, ‘FC4’, ‘FC6’, ‘C5’, ‘C3’, ‘C1’, ‘Cz’, ‘C2’, ‘C4’, ‘C6’,‘CP5’, ‘CP3’, ‘CP1’,‘CPz’, ‘CP2’, ‘CP4’, ‘CP6’]
montage = mne.channels.make_standard_montage(‘biosemi64’)
montage.ch_names = selected_electrodes
print(montage.ch_names)

epochs.ch_names, montage.ch_names

epochs.rename_channels({old_name: new_name for old_name, new_name in zip(epochs.ch_names, montage.ch_names)})
epochs.info.set_montage(montage1)
evoked = epochs[“1”].average()
Evoked.plot_topomap(ch_type=“eeg”, times=[0.5, 1,1.5,2])

#Error Message
Digitalization of points is not found