Dear all,
I am having an issue plotting computed spatial patterns (see image attached), as the sensors are totally unscaled with the head model.
One (maybe useful?) information side note : it was working properly before the āmne.channels.read_montageā was not depreciated.
In fact, there are already sensor locations in the data before calling set_montage() ā so Iām wondering whether you even need to call this method?
As for the notebook, itās unfortunately overwhelming as it contains an entire analysis pipeline, and I donāt have enough time to look into the details. Also a few functions are missing, so I cannot simply run it. Youād need to create something much less complex that contains just enough code to demonstrate your problem, otherwise it will be very difficult for others to reproduce and understand the issue youāre experiencing.
If any of you is also having this kind of problem, I might have found how to deal with it.
The problem came from the layout that I was taking from the data file and that seemed to be inaccurate :
Instead, I used the three following lines (as a checkup, I also used a second method using the ādigā info of the data and I get the save results.
So here is the updated plotting function :
use_ch = [ch for ch in raw.info['ch_names'] if ch.startswith('E') and ch not in ['ECG', 'EMG-Leg','E257']]
posarray = np.array([raw.info['chs'][i]['loc'][:2].tolist() for i,p in enumerate(raw.info['chs']) if raw.info['chs'][i]['ch_name'] in use_ch])
posarray_names = np.array([raw.info['chs'][i]['ch_name'] for i,p in enumerate(raw.info['chs']) if raw.info['chs'][i]['ch_name'] in use_ch])
fig = plt.figure()
fig.tight_layout()
for idx, (band, sp) in enumerate(zip(bands, spatial_pattern.T)):
scale = np.percentile(np.abs(sp), 99)
print(' Spatial patterns over %i - %i Hz' % band)
im, _ = mne.viz.plot_topomap(sp,
pos=posarray,
ch_type='eeg',
names = posarray_names,
show_names=True,
vmin=-scale, vmax=+scale,
#extrapolate = 'head',
cmap='RdBu_r', show=True)
plt.colorbar(im,ax=ax,fraction=0.046, pad=0.04)
ax.set_title('%i - %i Hz' % band)
plt.close()