# Type Error in adaptation of example plot\_source\_space\_time\_frequency.py

**URL:** https://mne.discourse.group/t/type-error-in-adaptation-of-example-plot-source-space-time-frequency-py/685
**Category:** Mailing List Archive (read-only)
**Tags:** list-archive
**Created:** [March 8, 2014, 8:47pm UTC](https://mne.discourse.group/t/type-error-in-adaptation-of-example-plot-source-space-time-frequency-py/685 "2014-03-08T20:47:41Z")
**Posts on this page:** 5
**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: [March 8, 2014, 8:47pm UTC](https://mne.discourse.group/t/type-error-in-adaptation-of-example-plot-source-space-time-frequency-py/685/1 "2014-03-08T20:47:41Z")

</div>

Hi all,

I get the following error when I try the following using my constructed ROI labels : Any pointers would be much appreciated 🙂

thanks// dave

script snippet:

print \_\_doc\_\_

import mne  
from mne import fiff

from mne.minimum\_norm import source\_band\_induced\_power  
epochs=mne.read\_epochs(fname\_epoched, proj= True)  
bands = dict(theta= [3, 8], alpha=[9, 11], beta=[18, 22], gamma=[30, 80])

stcs = source\_band\_induced\_power(epochs, label, inverse\_operator, bands, n\_cycles=2,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use\_fft=False, n\_jobs=1)

for b, stc in stcs.iteritems():  
&nbsp;&nbsp;&nbsp;&nbsp;stc.save('induced\_power\_%s' % b)

---

<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: [March 9, 2014, 7:49am UTC](https://mne.discourse.group/t/type-error-in-adaptation-of-example-plot-source-space-time-frequency-py/685/2 "2014-03-09T07:49:04Z")

</div>

hi David,

can you reproduce the problem with the sample data?  
could you share a gist on [https://gist.github.com/](https://gist.github.com/) ?

thanks  
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: [March 9, 2014, 11:50am UTC](https://mne.discourse.group/t/type-error-in-adaptation-of-example-plot-source-space-time-frequency-py/685/3 "2014-03-09T11:50:50Z")

</div>

Hi David,

It seems to me that you get this error because you use lists for the  
bands instead of arrays. Try to use

import numpy as np  
bands = dict(theta=np.array([3, 8]), alpha=np.array([9, 11]),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beta=np.array([18, 22]), gamma=np.array([30, 80]))

If this works we will also fix the code so that it works with lists.

Best,

Martin

---

<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: [March 9, 2014, 5:11pm UTC](https://mne.discourse.group/t/type-error-in-adaptation-of-example-plot-source-space-time-frequency-py/685/4 "2014-03-09T17:11:38Z")

</div>

will try am not quite sure how to proceed given that I am using my subject roi labels

> hi David,
> 
> can you reproduce the problem with the sample data?  
> could you share a gist on [https://gist.github.com/](https://gist.github.com/) ?
> 
> thanks  
> Alex
> 
> > Hi all,
> > 
> > I get the following error when I try the following using my constructed ROI labels : Any pointers would be much appreciated 🙂
> > 
> > thanks// dave
> > 
> > script snippet:
> > 
> > print \_\_doc\_\_
> > 
> > import mne  
> > from mne import fiff
> > 
> > from mne.minimum\_norm import source\_band\_induced\_power  
> > epochs=mne.read\_epochs(fname\_epoched, proj= True)  
> > bands = dict(theta= [3, 8], alpha=[9, 11], beta=[18, 22], gamma=[30, 80])
> > 
> > stcs = source\_band\_induced\_power(epochs, label, inverse\_operator, bands, n\_cycles=2,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use\_fft=False, n\_jobs=1)
> > 
> > for b, stc in stcs.iteritems():  
> > &nbsp;&nbsp;&nbsp;stc.save('induced\_power\_%s' % b)
> > 
> > ###############################################################################  
> > # plot mean power  
> > import matplotlib.pyplot as plt  
> > plt.plot(stcs['alpha'].times, stcs['alpha'].data.mean(axis=0), label='Alpha')  
> > plt.plot(stcs['beta'].times, stcs['beta'].data.mean(axis=0), label='Beta')  
> > plt.plot(stcs['beta'].times, stcs['beta'].data.mean(axis=0), label='Theta')  
> > plt.plot(stcs['beta'].times, stcs['beta'].data.mean(axis=0), label='Gamma')  
> > plt.xlabel('Time (ms)')  
> > plt.ylabel('Power')  
> > plt.legend()  
> > plt.title('Mean source induced power')  
> > plt.show()
> > 
> > error:
> > 
> > ---------------------------------------------------------------------------  
> > TypeError Traceback (most recent call last)  
> > \<ipython-input-11-2aeed705510d\> in \<module\>()  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 bands = dict(theta=[3, 8], alpha=[9, 11], beta=[18, 22], gamma=[30, 80])  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2  
> > ----\> 3 BFstcs = source\_band\_induced\_power(epochs, label, inverse\_operator, bands, n\_cycles=2, use\_fft=False, n\_jobs=1)
> > 
> > /home/leitman/Enthought/Canopy\_64bit/User/lib/python2.7/site-packages/mne-0.7.1-py2.7.egg/mne/utils.pyc in dec(\*args, \*\*kwargs)  
> > &nbsp;&nbsp;&nbsp;378 return ret  
> > &nbsp;&nbsp;&nbsp;379 else:  
> > --\> 380 return function(\*args, \*\*kwargs)  
> > &nbsp;&nbsp;&nbsp;381  
> > &nbsp;&nbsp;&nbsp;382 # set \_\_wrapped\_\_ attribute so ?? in IPython gets the right source
> > 
> > /home/leitman/Enthought/Canopy\_64bit/User/lib/python2.7/site-packages/mne-0.7.1-py2.7.egg/mne/minimum\_norm/time\_frequency.pyc in source\_band\_induced\_power(epochs, inverse\_operator, bands, label, lambda2, method, nave, n\_cycles, df, use\_fft, decim, baseline, baseline\_mode, pca, n\_jobs, verbose)  
> > &nbsp;&nbsp;&nbsp;&nbsp;84  
> > &nbsp;&nbsp;&nbsp;&nbsp;85 frequencies = np.concatenate([np.arange(band[0], band[1] + df / 2.0, df)  
> > ---\> 86 for \_, band in bands.iteritems()])  
> > &nbsp;&nbsp;&nbsp;&nbsp;87  
> > &nbsp;&nbsp;&nbsp;&nbsp;88 powers, \_, vertno = \_source\_induced\_power(epochs,  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Mne\_analysis mailing list  
> > Mne\_analysis at nmr.mgh.harvard.edu  
> > [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)
> > 
> > The information in this e-mail is intended only for the person to whom it is  
> > addressed. If you believe this e-mail was sent to you in error and the e-mail  
> > contains patient information, please contact the Partners Compliance HelpLine at  
> > [http://www.partners.org/complianceline](http://www.partners.org/complianceline) . If the e-mail was sent to you in error  
> > but does not contain patient information, please contact the sender and properly  
> > dispose of the e-mail.

David I. Leitman PhD

Research Assistant Professor  
Department of Psychiatry-  
Neuropsychiatry program  
Perelman School of Medicine  
University of Pennsylvania  
Gates Pavilion 10th floor room 1042  
3400 Spruce St  
Philadelphia, PA 19104-4283  
P: (215) 662-7389  
F: (215) 662-7903  
E: leitman at mail.med.upenn.edu  
Faculty page: [http://www.med.upenn.edu/apps/faculty/index.php/g275/p8174343](http://www.med.upenn.edu/apps/faculty/index.php/g275/p8174343)  
Lab website:  
[http://davidileitman.com](http://davidileitman.com)

The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the the Neuropsychiatry Section immediately by e-mail, and delete the original message.

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20140309/633eb5fc/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140309/633eb5fc/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: [March 9, 2014, 7:57pm UTC](https://mne.discourse.group/t/type-error-in-adaptation-of-example-plot-source-space-time-frequency-py/685/5 "2014-03-09T19:57:58Z")

</div>

Hi thanks will do and will try wilth sample data when I get to work tomorrow

Dave
