[Mne_analysis] question about epochs.next()

Dan McCloy drmccloy at uw.edu
Tue Apr 5 20:51:42 EDT 2016
Search archives:

I see. Sounds like that would work, I'll give it a try. thanks.

FWIW, from the POV of a new mne-python user, the examples quite prominently
use "evoked" to mean "average of epochs" (e.g.,
http://martinos.org/mne/dev/auto_tutorials/plot_introduction.html?highlight=evoked).
I probably missed the Epochs.iter_evoked method() on the basis of its name
(because I didn't want averages, and it wasn't immediately obvious that
"nave=1" meant "n_epochs_to_average=1", i.e., no averaging).

So now I'm doubly-puzzled: why does Epochs.next() not return a single
epoch, and why does Epochs.iter_evoked() not return an average of epochs?
I understand the need to preserve some backwards-compatibility, but the
naming conventions here seem very ad-hoc to me and worth changing prior to
a 1.0 release.  Until then, I guess I'll just change the docstrings to
match what these methods actually do.
On Apr 5, 2016 5:11 PM, "Mainak Jas" <mainakjas at gmail.com> wrote:

> Sorry if I wasn't clear but iter_evoked() gives you a single epoch -- not
> an average. It has nave=1.
>
> Mainak
>
> On Wed, Apr 6, 2016 at 1:45 AM, Dan McCloy <drmccloy at uw.edu> wrote:
>
>> thanks Mainak, but my use case is a little strange, and I don't think
>> iter_evoked will help.  I need potentially different crop windows for each
>> event type (same length, but different start/end points), but I need to
>> keep the individual epochs (not averages) because they're getting fed into
>> a classifier.  I'm happy to do a PR to change the docs if the consensus is
>> that it is indeed the docs that should change, not the implementation of
>> next().
>>
>> On Tue, Apr 5, 2016 at 4:27 PM, Mainak Jas <mainakjas at gmail.com> wrote:
>>
>>> Hi Dan,
>>>
>>> Since you are iterating over single epochs, it might make more sense to
>>> use the iterator which returns an evoked object. You can do something like:
>>>
>>> for ev in epochs.iter_evoked()
>>>     ev.crop(tmin, tmax)
>>>
>>> Does this help? Fix to the docs is more than welcome.
>>>
>>> Best regards,
>>> Mainak
>>>
>>>
>>> On Tue, Apr 5, 2016 at 10:05 PM, Dan McCloy <drmccloy at uw.edu> wrote:
>>>
>>>> On Tue, Apr 5, 2016 at 12:19 PM, Chris Holdgraf <choldgraf at berkeley.edu
>>>> > wrote:
>>>>
>>>>> sometimes it's more useful to return arrays.
>>>>>
>>>>
>>>> Sure, but that's why there is a get_data method, right?  IMO the
>>>> docstring reflects how I expected it to work before even reading the
>>>> docstring, so my vote would be to make .next() actually do that, rather
>>>> than changing the docstring to reflect what it does currently.  Issue
>>>> created: https://github.com/mne-tools/mne-python/issues/3099
>>>>
>>>>
>>>>> On Tue, Apr 5, 2016 at 12:03 PM, Dan McCloy <drmccloy at uw.edu> wrote:
>>>>>
>>>>>> I was puzzled today why this works...
>>>>>>
>>>>>> for ix, _ in enumerate(epochs):
>>>>>>     new_epoch = epochs[ix].crop(tmin, tmax, copy=True)
>>>>>>
>>>>>> ... but this does not:
>>>>>>
>>>>>> for epoch in epochs:
>>>>>>     new_epoch = epoch.crop(..., copy=True)
>>>>>>
>>>>>> AttributeError: 'numpy.ndarray' object has no attribute 'crop'
>>>>>>
>>>>>> According to the docs, Epochs.next() is supposed to return an
>>>>>> instance of the epochs object, but it doesn't: looking at the code, it
>>>>>> actually returns something like self._data[self._current].  I would have
>>>>>> expected it to return something like self.__get_item__(self._current).  So
>>>>>> are the docs wrong, or is the definition of Epochs.next() implemented wrong?
>>>>>>
>>>>>> Daniel McCloy
>>>>>> http://dan.mccloy.info/
>>>>>> Postdoctoral Research Associate
>>>>>> Institute for Learning and Brain Sciences
>>>>>> University of Washington
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> _____________________________________
>>>>>
>>>>> PhD Candidate in Neuroscience | UC Berkeley <http://hwni.org/>
>>>>> Editor and Web Director | Berkeley Science Review
>>>>> <http://sciencereview.berkeley.edu/>
>>>>> _____________________________________
>>>>>
>>>>> _______________________________________________
>>>>> 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.
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> 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.
>>>>
>>>>
>>>
>>> _______________________________________________
>>> 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.
>>>
>>>
>>
>> _______________________________________________
>> 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.
>>
>>
>
> _______________________________________________
> 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/20160405/5102a219/attachment-0001.html 


More information about the Mne_analysis mailing list