adding a Brain to html report

External Email - Use Caution

Hi,

Is there an easy way to add a rendered brain image to an html report?
I don't know how to get a handle to the figure of a plotted Brain object
and pass it to

report.add_figs_to_section(fig, captions=data_subject + ' sensitivity map',
section='Leadfield')

If I pass a Brain object as fig here, I get

AttributeError: 'Brain' object has no attribute 'scene'

Thanks,

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180606/c670a38f/attachment.html

External Email - Use Caution

Hi Max,

you have to hack it unfortunately. The way to go is to save the mayavi plot to disk, read the image back and plot it using matplotlib imshow and then pass the figure handle.
The good news is that this should work. I remember having done it in the past.

Hope this helps,
Denis

External Email - Use Caution

hi Max,

it should have worked. See:

https://github.com/mne-tools/mne-python/blob/master/mne/report.py#L57

can you share a full code snippet to replicate the pb?

ideally do it in an issue at: https://github.com/mne-tools/mne-python/issues

thanks
Alex

External Email - Use Caution

Hello Max

The following lines of code worked fine for me

Fig1=mlab.figure()
brain = Brain('SUBJECTNAME','lh','pial',views='medial',
                                    subjects_dir=subjects_dir,figure=Fig1)
report.add_figs_to_section(Fig1, captions=[' Hemi '], section='SubjectName')

Kind regards
Bushra Riaz

External Email - Use Caution

Amazing I forgot that we added this in the meantime.
I actually used this code in successfully in the past and
it is mysterious that it does not work in your case.
What Python version are you using btw. ?
I?d also check for Mayavi / Pysurfer versions.
If you share a snippet we can check on our machines and compare.