extract values from figures


Sorry if this have been already explained. Do you know how to extract the values from the figures?
Let’s say I have a psd figure or a topomap saved in fig. Do you know how can I get the corresponding array with channels and values? Is it possible or are there other functions I should call instead of trying to do this. It seems the most immediate functions are plot_psd() and plot_topomap() so I don’ know if there are equivalent ones to get the actual values that produce them.


I am not sure how to extract values from figures, although i assume it’s possible using matplotlib. But for the example you provide you could compute the values using something like psd_welch mne.time_frequency.psd_welch — MNE 0.23.4 documentation

Does this help? Or do you specifically want the figure values?

Thanks @rob-luke ! I initially tried the psd_welch funtion, and then try to plot by myself but I’m having some other issues like ploting on the layout, small differences in values due to the different methods, etc. So I was maybe considering using the other approach and just extract the values I got from mne figures. But maybe it’s not a common one?

Hello @guiomar,

to plot topographies of PSDs, please have a look at how mne.viz.plot_epochs_psd_topomap() does it (please follow the link to display the full block of code I highlighted for you – the below preview in the forum is truncated):

It’s really not much code and I think it demonstrates precisely what you need, without having to fiddle with montages or manually needing to extract data from the figure post-hoc.

Best wishes,