Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

get_topo_colours.py 995 B

123456789101112131415161718192021222324252627282930313233343536
  1. import mne
  2. import pandas as pd
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. from matplotlib.colors import ListedColormap
  6. # lay object to plot
  7. lay = mne.channels.read_layout("biosemi")
  8. # info object to plot with
  9. info = mne.create_info(lay.names, ch_types=['eeg']*len(lay.names), sfreq=256)
  10. info.set_montage('biosemi64', match_case=False)
  11. # get 3d locations
  12. chs = info["chs"]
  13. locs3d = np.array([ch["loc"][:3] for ch in chs])
  14. # get associated colours from colour wheel
  15. x, y, z = locs3d.T
  16. colors = mne.viz.evoked._rgb(x, y, z)
  17. # get inputs for plot_sensors
  18. ch_grps = [[i] for i in range(len(info.ch_names))]
  19. cmap = ListedColormap(colors)
  20. fig, ax = plt.subplots()
  21. pl = mne.viz.utils.plot_sensors(info, ch_groups=ch_grps, cmap=cmap, linewidth=0, pointsize=250, axes=ax)
  22. topo_cols = pd.DataFrame(colors).rename(columns={0:'r', 1:'g', 2:'b'})
  23. topo_cols['ch_name'] = info.ch_names
  24. topo_cols = topo_cols[['ch_name', 'r', 'g', 'b']]
  25. topo_cols.to_csv('Biosemi64_fiducial.csv', index=False)