[Mne_analysis] Trimming epochs in mne-python

Stephen Politzer-Ahles spa268 at nyu.edu
Sun Dec 22 11:48:05 EST 2013
Search archives:

Thanks Denis and Martin, epochs.crop is indeed it!

Best,
Steve



Stephen Politzer-Ahles
New York University, Abu Dhabi
Neuroscience of Language Lab
http://www.nyu.edu/projects/politzer-ahles/


On Sun, Dec 22, 2013 at 8:24 PM, Denis A. Engemann <denis.engemann at gmail.com
> wrote:

> Hey Steve,
>
> the Epochs constructor strictly expects a raw object as first argument,
> not an existing Epochs object.
> You are probably looking for epochs.crop
>
> e.g
> epochs.crop(-1.0, 1.5)
>
> watch out, in place changes unless you pass copy==True
>
> sub_epochs = epochs.crop(-1.0, 1.5, copy=True)
>
> HTH,
> Denis
>
> On Dec 22, 2013, at 5:07 PM, Stephen Politzer-Ahles <spa268 at nyu.edu>
> 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
>
>
> 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 . 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20131222/8f3df625/attachment.html 


More information about the Mne_analysis mailing list