[Mne_analysis] Fwd: Convert pandas dataframe back to Evoked (UPDATED!)

d p aglasis at gmail.com
Tue Aug 7 11:18:07 EDT 2018
Search archives:

        External Email - Use Caution        

Dear all,

Sorry for spamming, but the second I pressed "send" I realized that I could
simply set the time points correctly as NewEvoked.times =
OriginalEvoked.times. That seems to work fine and that would solve my main
question.

However, I am still puzzled about the mentioned timing issue (samples in
steps of 2ms). Is this something I should worry about? Or is this something
to be expected, considering the down-sampling (or some other factor?)?
Thanks and regards,
D.


---------- Forwarded message ----------
From: d p <aglasis at gmail.com>
Date: 7 August 2018 at 17:08
Subject: Convert pandas dataframe back to Evoked
To: mne_analysis at nmr.mgh.harvard.edu


Dear list,

I used the .to_dataFrame() method to convert an Evoked object to a pandas
data frame, performed some channel operations, and now I would like to read
the data frame back as a new evoked object with the .EvokedArray() method.
The EvokedArray() call works fine, except that the created time points do
not match the original ones.

On the original Evoked file, time ranges from -500 to 13000 ms, but it
progresses in 2ms steps (minimum and maximum Evoked.times are -0.5 and
1.300 respectively, but the length of the .times vector is 923 items). This
structure is preserved in the pandas data frame, but the problem is that
when I read it back the data frame as Evoked, the time/index of the
dataframe is ignored, and the Evoked object creates its own time, which do
not correspond to the actual timing of the original signal (i.e. the time
points in the data frame.

My questions would be then:
- How create an Evoked object using the both the data and the time points
stored in the pandas data frame?
- More or less unrelated to the question, but I am puzzled by the time
points and the fact that they progress on 2ms steps. Raw data was
originally sampled ad 2048Hz, but during pre-processing it was down-sampled
to 512Hz (The sampling frequency I am feeding to the EvokedArray() call).
Could this be the reason for having samples on 2ms steps? Or is this a sign
that I made some kind of mistake during pre-processing / Epoching /
averaging?
- Is it possible to altogether avoid the conversion to pandas data frame? I
am trying to compute event-related lateralizations, and for those I need to
perform some additions and subtractions between symmetrical left and right
electrodes depending on the visual hemifield in which an image is
presented. I could not manage to do that directly on the Evoked object, so
I figured the easiest way would be to convert the Evoked to a data frame,
perform the computations necessary computations there, and then read back
the results as a new evoked object that I can use to calculate grand
averages and generate plots. That worked ok, in principle, except for the
timing issue.

Thanks in advance for any ideas!
Best,
D.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180807/1ec00fd1/attachment.html 


More information about the Mne_analysis mailing list