[Mne_analysis] stc.plot() Error: raise ValueError('time is not the same length as array.shape[1]')

Nakagawa Tristan T nakagawa-t at ifrec.osaka-u.ac.jp
Fri May 13 02:01:24 EDT 2016
Search archives:

I figured it out, it seems the code is still not compatible with python3.

adding to viz.py :
 
try:
    basestring
except NameError:
    basestring = str

fixes this error and makes the plot possible.

I never worked with python2 (and didn't know basestring was a type);
do I have to expect silent wrong results using the
python3/mayavi4.4.4/vtk7 combination?


---
If anybody is interested (unless this isn't advised), The install
procedure gave me some trouble but finally worked in this combination
(with anaconda python):
conda install -c menpo vtk=7.0.0
pip install mayavi
pip install pysurfer

cheers
Tristan


On 2016年05月13日 13:39, Nakagawa Tristan T wrote:
> I was confused, sorry. the actual error is:
>
> --> 876             if isinstance(time_label, basestring):
>
> as in:
> In [96]: stc.plot()
> Updating smoothing matrix, be patient..
> Smoothing matrix creation, step 1
> Smoothing matrix creation, step 2
> Smoothing matrix creation, step 3
> Smoothing matrix creation, step 4
> Smoothing matrix creation, step 5
> Smoothing matrix creation, step 6
> Smoothing matrix creation, step 7
> Smoothing matrix creation, step 8
> Smoothing matrix creation, step 9
> Smoothing matrix creation, step 10
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call last)
> <ipython-input-96-2a3e72fcca14> in <module>()
> ----> 1 stc.plot()
>
> /home/tristan/anaconda3/lib/python3.5/site-packages/mne-0.12.dev0-py3.5.egg/mne/source_estimate.py
> in plot(self, subject, surface, hemi, colormap, time_label,
> smoothing_steps, transparent, alpha, time_viewer, config_opts,
> subjects_dir, figure, views, colorbar, clim)
>    1376                                       subjects_dir=subjects_dir,
> figure=figure,
>    1377                                       views=views,
> colorbar=colorbar,
> -> 1378                                       clim=clim)
>    1379         return brain
>    1380
>
> /home/tristan/anaconda3/lib/python3.5/site-packages/mne-0.12.dev0-py3.5.egg/mne/viz/_3d.py
> 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)
>     747                            smoothing_steps=smoothing_steps,
> time=time,
>     748                            time_label=time_label, alpha=alpha,
> hemi=hemi,
> --> 749                            colorbar=colorbar)
>     750
>     751         # scale colormap and set time (index) to display
>
> /home/tristan/anaconda3/lib/python3.5/site-packages/surfer/viz.py in
> add_data(self, array, min, max, thresh, colormap, alpha, vertices,
> smoothing_steps, time, time_label, colorbar, hemi, remove_existing,
> time_label_size)
>     874                 raise ValueError('time is not the same length as '
>     875                                  'array.shape[1]')
> --> 876             if isinstance(time_label, basestring):
>     877                 time_label_fmt = time_label
>     878                 time_label = lambda x: time_label_fmt % x
>
> NameError: name 'basestring' is not defined
>
> In [97]: stc.time_label
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
> <ipython-input-97-3f447cdfe95d> in <module>()
> ----> 1 stc.time_label
>
> AttributeError: 'SourceEstimate' object has no attribute 'time_label'
>
>
>
>
>
> On 2016年05月13日 11:54, Nakagawa Tristan T wrote:
>> Hi,
>>
>> I get this error when trying to plot my source estimates:
>> stc.plot()  Error: raise ValueError('time is not the same length as
>> array.shape[1]')
>>
>> however,
>> stc: <SourceEstimate  |  10629 vertices, subject : S23, tmin : -1100.0
>> (ms), tmax : 1000.0 (ms), tstep : 1.0 (ms), data size : 10629 x 2101>
>>
>> In [93]:   stc.times.shape
>> Out[93]: (2101,)
>>
>> In [94]:   stc.shape
>> Out[94]: (10629, 2101)
>>
>> Here is one of the hemispheres stc:
>> https://www.dropbox.com/s/d3vvmy79gddvuev/grad_CS-lh.stc?dl=0
>>
>> Any ideas?
>> I just installed mayavi 4.4.4 with vtk 7.0 on python3, not sure if that
>> might cause problems, but the error doesn't look like it.
>>
>> Thanks,
>> Tristan
>>

-- 
Tristan T. Nakagawa, Ph.D.
Laboratory for Brain-Immune Interaction,
iFReC, Osaka University 
3-1 Yamadaoka, Suita, Osaka, Japan
Tel: 0668789710
Office: CiNet R 2B6-2
http://seymourlab.com



More information about the Mne_analysis mailing list