Questions with regard to replicate tutorial examples

Dear all,

I try to replicate the example in
http://martinos.org/mne/stable/auto_tutorials/plot_source_localization_basics.html
.

However, there's some problem with PySurfer.
I use Jupyter notebook to run the code. In PySurfer document, it use PyQT (
export QT_API=pyqt ). I'm wondering if I use %matplotlib inline magic,
should I still have to use PyQT. From the tutorial, it seems the results
were shown in notebook environment.

I'm trying to find the TraitsBackendWX backend connector to install (as the
error message complained). But I can't find the proper TraitsBackendWX
package to install.

Any advice would be appreciated!

The following is the traceback.

---------------------------------------------------------------------------ImportError
                              Traceback (most recent call
last)<ipython-input-12-c34103ae717e> in <module>() 2 3
subjects_dir = data_path + '/subjects'----> 4 brain =
stc.plot(surface='inflated', hemi='rh', subjects_dir=subjects_dir)
/mne-python/mne/source_estimate.pyc in plot(self, subject, surface,
hemi, colormap, time_label, smoothing_steps, transparent, alpha,
time_viewer, config_opts, subjects_dir, figure, views, colorbar, clim)
  1364
subjects_dir=subjects_dir, figure=figure, 1365
                views=views, colorbar=colorbar,-> 1366
                      clim=clim) 1367 return brain 1368
/Volumes/SSD/Space/utility/mne-python/mne/viz/_3d.pyc in
plot_source_estimates(stc, subject, surface, hemi, colormap,
time_label, smoothing_steps, transparent, alpha, time_viewer,
config_opts, subjects_dir, figure, views, colorbar, clim) 638
  kwargs['views'] = views 639 with
warnings.catch_warnings(record=True): # traits warnings–> 640
brain = Brain(subject, hemi, surface, **kwargs) 641 for hemi
in hemis: 642 hemi_idx = 0 if hemi == 'lh' else 1
/Volumes/SSD/Space/vEnvs2/ipy2/lib/python2.7/site-packages/surfer/viz.pyc
in __init__(self, subject_id, hemi, surf, curv, title, cortex, size,
background, foreground, figure, subjects_dir, views, show_toolbar,
offscreen, config_opts) 393
self._set_window_properties(size, background, foreground) 394
  figures, _v = _make_viewer(figure, n_row, n_col, title,–> 395
                             self._scene_size, offscreen) 396
  self._figures = figures 397 self._v = _v
/Volumes/SSD/Space/vEnvs2/ipy2/lib/python2.7/site-packages/surfer/viz.pyc
in _make_viewer(figure, n_row, n_col, title, scene_size, offscreen)
210 # Triage: don't make TraitsUI if we don't have to
211 if n_row == 1 and n_col == 1:–> 212
figure = mlab.figure(title, size=(w, h)) 213
mlab.clf(figure) 214 figures = [[figure]]
/Volumes/SSD/Space/vEnvs2/ipy2/lib/python2.7/site-packages/mayavi-4.4.4.dev0-py2.7-macosx-10.11-x86_64.egg/mayavi/tools/figure.pyc
in figure(figure, bgcolor, fgcolor, engine, size) 62 else:
63 if engine is None:—> 64 engine = get_engine()
    65 if figure is None: 66 name =
max(__scene_number_list) + 1
/Volumes/SSD/Space/vEnvs2/ipy2/lib/python2.7/site-packages/mayavi-4.4.4.dev0-py2.7-macosx-10.11-x86_64.egg/mayavi/tools/engine_manager.pyc
in get_engine(self) 95 if
e.__class__.__name__ == 'Engine'] 96 if len(suitable) ==
0:—> 97 return self.new_engine() 98 else:
99 # Return the most engine add to the list most
recently.
/Volumes/SSD/Space/vEnvs2/ipy2/lib/python2.7/site-packages/mayavi-4.4.4.dev0-py2.7-macosx-10.11-x86_64.egg/mayavi/tools/engine_manager.pyc
in new_engine(self) 140 options. 141 """–>
142 check_backend() 143 if options.backend ==
'envisage': 144 from mayavi.plugins.app import Mayavi
/Volumes/SSD/Space/vEnvs2/ipy2/lib/python2.7/site-packages/mayavi-4.4.4.dev0-py2.7-macosx-10.11-x86_64.egg/mayavi/tools/engine_manager.pyc
in check_backend() 47 wxPython: http://www.wxpython.org/ 48
PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro---> 49
''') 50 51
ImportError: Could not import backend for traits

Dear Foucault,

What you see in the tutorial is not an ipython notebook. It is in fact an
restructured text document rendered in the style of ipython notebook using
the sphinx gallery (
http://sphinx-gallery.readthedocs.org/en/latest/tutorials/plot_notebook.html#sphx-glr-tutorials-plot-notebook-py
).

That said, I am able to run the example smoothly on an ipython notebook. It
seems to me that there is something wrong with your mayavi installation.
Are you able to run the example as a regular python script? I suspect you
would need to install mayavi correctly.

Best regards,
Mainak

Dear Foucault,

In addition to checking your Mayavi-installation as Mainak suggests, try the notebook inline-magic

%gui qt

If pyqt is indeed set up, this should allow you to run the example.

Note that you cannot both have the cake and eat it: using %matplotlib inline forces rendering to bitmaps (that can be embedded into HTML and displayed in the browser). To get access to interactive OpenGL-rendering, you need another (GUI) backend, such as qt.

For completeness, I?d like to mention that on my OS X system, despite having wxpython installed, I am unable to run %gui wx. I get an error complaining about access to the screen on a non-?framework? python build. I?d be curious to hear if anyone out there has a fix for this?

/Chris
/Aarhus, DK