mne-python saving epochs drop log plot

Hi all,
Anyone know how to go about saving the figure associated
with mne.viz.plot_drop_log, if possible?

The closest I've gotten is a blank image/file using:
plot_drop_log(epochs.drop_log, subject=subj)
matplotlib.pyplot.draw()
fig = matplotlib.pyplot.gcf()
fig.savefig(fname)

thanks in advance

Kambiz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140124/6fa594e5/attachment.html

hi Kam,

with the current version of mne-python you can do:

epochs.plot_drop_log()
import matplotlib.pyplot as plt
plt.savefig('fig.pdf')

HTH
Alex

Hi Alex,
I've tried this as well with same result i.e., blank file. Here is what I
am doing:

import matplotlib.pyplot as plt
_ = epochs.drop_bad_epochs()
plot_drop_log(epochs.drop_log, subject=subj)
plt.savefig(info.get('filename')[:-4] + '_droplog', dpi=100, format='pdf')

I can verify this works because I see the figure window and appropriate
drop plot. The documentation says plot_drop_log returns a float, so I am
not sure where in the ether the associated figure window ends up. I am
using mne-python version 0,8.

cheers,
Kam

hi Kam,

plt.savefig(info.get('filename')[:-4] + '_droplog.pdf', dpi=100, format='pdf')

works fine on my machine.

Note that I added the .pdf extension.

Alex

Kam,

I've recently spotted a similar problem when trying to save matplotlib
figures from a ipython qt-console that runs in inline mode.

Can you make sure you use ipython with a qt backend?

Best,
Denis

Thanks Denis. I finally got this thing to work. For anyone who is
interested; I edited my matplotlib config file setting for backend to
use Qt4agg and set the bindings for the backend to pyside i.e., the
specific modifications I made in the matplotlibrc file are:

`backend: Qt4agg`
`backend.qt4 : PySide`

cheers,
Kam

P.s. The alternative to PySide is PyQt4, which does not appear to be on
good terms with the Anaconda python environment. I believe it is not
available for install through their repositories, and I was also unable to
find it via `pip`. PyQT4 depends on a module called SIP that installs
rather painlessly after downloading source and building, however I
encountered lots of ugly errors trying the same approach with PyQT4...TBC

Hi Kam,

great to know and thanks for sharing this.
Another way to do it is exemplified in my .bash_profile file :

https://gist.github.com/dengemann/8674149#file-bashrc-L31

and the following line

Cheers,
Denis