[Mne_analysis] Trimming epochs in mne-python

Martin Luessi mluessi at nmr.mgh.harvard.edu
Sun Dec 22 11:24:45 EST 2013
Search archives:

Hi Steve,

Epochs isn't designed to be created from epochs. You have to give it
continuous raw data (an instance of mne.fiff.Raw). If you just want to
change the time interval of the epochs, does Epochs.crop fit your need?

Best,

Martin



On 12/22/13 11:07, Stephen Politzer-Ahles wrote:
> Hello,
> 
> I have an Epochs object with pretty large epochs (tmin==-2 and tmax==3),
> and I'd like to pull out shorter epochs (just a subset of the times in
> the epoch). I tried using mne.Epochs to do so:
> 
> epochs2 = mne.Epochs( epochs, epochs.events, event_id, tmin=-.1, tmax=1,
> baseline=(0,.1) )
> 
> but this caused problems later on; when I tried averaging with
> epochs2.average(), I got an error (traceback below) that I do not get if
> I average my original epochs.
> 
> Does this error have something to do with the way I created those
> epochs? And is there a better way to trim epochs?
> 
> Thanks,
> Steve
> 
> 
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
> <ipython-input-90-a492271ceff2> in <module>()
> ----> 1 epochs2.average()
> 
> /Users/meglab/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/epochs.pyc
> in average(self, picks)
>     339         """
>     340 
> --> 341         return self._compute_mean_or_stderr(picks, 'ave')
>     342 
>     343     def standard_error(self, picks=None):
> 
> /Users/meglab/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/epochs.pyc
> in _compute_mean_or_stderr(self, picks, mode)
>     377             data = np.zeros((n_channels, n_times))
>     378             n_events = 0
> --> 379             for e in self:
>     380                 data += e
>     381                 n_events += 1
> 
> /Users/meglab/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/epochs.pyc
> in next(self, return_event_id)
>     976                     raise StopIteration
>     977                 epoch, epoch_raw =
> self._get_epoch_from_disk(self._current,
> --> 978                                                            
>  proj=proj)
>     979                 self._current += 1
>     980                 is_good, _ = self._is_good_epoch(epoch)
> 
> /Users/meglab/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/utils.pyc
> in dec(*args, **kwargs)
>     378             return ret
>     379         else:
> --> 380             return function(*args, **kwargs)
>     381 
>     382     # set __wrapped__ attribute so ?? in IPython gets the right
> source
> 
> /Users/meglab/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/epochs.pyc
> in _get_epoch_from_disk(self, idx, proj, verbose)
>     748 
>     749         # Read a data segment
> --> 750         first_samp = self.raw.first_samp
>     751         start = int(round(event_samp + self.tmin * sfreq)) -
> first_samp
>     752         stop = start + self._epoch_stop
> 
> AttributeError: 'Epochs' object has no attribute 'first_samp'
> 
> 
> 
> 
> Stephen Politzer-Ahles
> New York University, Abu Dhabi
> Neuroscience of Language Lab
> http://www.nyu.edu/projects/politzer-ahles/
> 
> 
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> 


-- 
Martin Luessi, Ph.D.

Research Fellow

Department of Radiology
Athinoula A. Martinos Center for Biomedical Imaging
Massachusetts General Hospital
Harvard Medical School
149 13th Street
Charlestown, MA 02129

Fax: +1 617 726-7422



More information about the Mne_analysis mailing list