# mne-python saving epochs drop log plot

**URL:** <https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [January 25, 2014, 1:46am UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660 "2014-01-25T01:46:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 25, 2014, 1:46am UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660/1 "2014-01-25T01:46:32Z")

</div>

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](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140124/6fa594e5/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 25, 2014, 9:56am UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660/2 "2014-01-25T09:56:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 25, 2014, 7:01pm UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660/3 "2014-01-25T19:01:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 26, 2014, 12:35pm UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660/4 "2014-01-26T12:35:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 26, 2014, 12:38pm UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660/5 "2014-01-26T12:38:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 28, 2014, 7:09pm UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660/6 "2014-01-28T19:09:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 28, 2014, 7:13pm UTC](https://mne.discourse.group/t/mne-python-saving-epochs-drop-log-plot/660/7 "2014-01-28T19:13:44Z")

</div>

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](https://gist.github.com/dengemann/8674149#file-bashrc-L31)

and the following line

Cheers,  
Denis
