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

**URL:** <https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [May 13, 2016, 2:54am UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021 "2016-05-13T02:54:37Z")\
**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:** [May 13, 2016, 2:54am UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021/1 "2016-05-13T02:54:37Z")

</div>

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](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

---

<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:** [May 13, 2016, 4:39am UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021/2 "2016-05-13T04:39:30Z")

</div>

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

---

<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:** [May 13, 2016, 6:01am UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021/3 "2016-05-13T06:01:24Z")

</div>

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

adding to viz.py :

try:  
&nbsp;&nbsp;&nbsp;&nbsp;basestring  
except NameError:  
&nbsp;&nbsp;&nbsp;&nbsp;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?

---

<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:** [May 13, 2016, 12:02pm UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021/4 "2016-05-13T12:02:38Z")

</div>

Mayavi does not yet work with Python3 unfortunately. Rumors have been  
existing that there is some unmerged experimental dev branch of VTK that  
supports mayavi 3, but I'm not sure if mayavi can already be used.

Btw. anyone who wants to help writing an API for plotting freesurfer  
outputs using matplotlib without extra dependencies deserves many beers  
{insert favourite drink}. Look also here for the first attempts:  
[https://github.com/nilearn/nilearn/pull/1016](https://github.com/nilearn/nilearn/pull/1016)

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:** [May 14, 2016, 1:26am UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021/5 "2016-05-14T01:26:39Z")

</div>

Actually, as I mention below, vtk7 (main release) is compatible with Python3

[https://blog.kitware.com/vtk-7-0-0/](https://blog.kitware.com/vtk-7-0-0/)

and with this and mayavi 4.4.4, after fixing the viz.py script, I could  
plot meg activity onto the cortical surface without any apparent  
problems so far, all in python 3.

Cheers  
Tristan

---

<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:** [May 14, 2016, 1:53am UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021/6 "2016-05-14T01:53:27Z")

</div>

PySurfer will need to be updated to be Python3 compatible. Can you open a  
GitHub issue on the PySurfer repo?

Eric

---

<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:** [May 14, 2016, 2:24am UTC](https://mne.discourse.group/t/stc-plot-error-raise-valueerror-time-is-not-the-same-length-as-array-shape-1/1021/7 "2016-05-14T02:24:04Z")

</div>

There is already an issue:  
[https://github.com/nipy/PySurfer/issues/143](https://github.com/nipy/PySurfer/issues/143)

I added a comment to the vtk7.0 release.

cheers,  
Tristan
