mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.68k stars 1.31k forks source link

Failing example: plot_epochs_as_data_frame.py #286

Closed larsoner closed 11 years ago

larsoner commented 11 years ago

I have a failing example:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 487, in runfile
    execfile(filename, namespace)
  File "/home/larsoner/custombuilds/mne-python/examples/export/plot_epochs_as_data_frame.py", line 176, in <module>
    df.set_index('condition', append=True, inplace=True)
TypeError: set_index() got an unexpected keyword argument 'append'

Thoughts @christianmbrodbeck @dengemann? I am running Ubuntu 12.10 (latest) with pandas from the repos, so I think the version (pandas 0.8.0) should probably be supported...

larsoner commented 11 years ago

@christianmbrodbeck depending on how much debugging you want to do, now that you know basic plotting works, you could try "dumbing down" (commenting out large portions of) the mne-python plotting code to see what the culprit is. Or you could use debugging with breakpoints, but I'm not sure how that would interact with the plotting.

dengemann commented 11 years ago

Btw. #133 folks.

i hope you noticed how this toy-like example exposes some of the functionality we've been discussing, especially the groupby, as it splits your observations into cells resulting from crossing factors.

What would you think about something similar for epochs on construction / as method? @christianmbrodbeck, does this relate to eelbrain factors / ndvars, and if yes, how?

On 19.12.2012, at 01:21, Christian Brodbeck notifications@github.com wrote:

somebody else has mac/EPD to confirm this? If it's just something about my specific configuration maybe it's not worth the trouble

— Reply to this email directly or view it on GitHub.

dengemann commented 11 years ago

but also with a fresh data frame?

df=DataFrame(my2darray, columns=['a', 'b'])

df.plot()

On 19.12.2012, at 01:30, Christian Brodbeck notifications@github.com wrote:

[christian@Christians-MacBook-Pro] ~/Documents/Eclipse/projects/mne-python/examples$ python Enthought Python Distribution -- www.enthought.com Version: 7.3-2 (32-bit)

Python 2.7.3 |EPD 7.3-2 (32-bit)| (default, Apr 12 2012, 11:28:34) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "credits", "demo" or "enthought" for more information.

from pylab import * import numpy as np plot(np.random.normal(0,1,5)) [<matplotlib.lines.Line2D object at 0x5b406f0>] here the rocket app icon appears but I'm still in the terminal

show() Now the plot shows up until I dismiss it

— Reply to this email directly or view it on GitHub.

christianbrodbeck commented 11 years ago

[deleted]

christianbrodbeck commented 11 years ago

actually (disregard what I just said) with a proper short script the plot is displayed as it should:

import numpy as np
import pandas as P

df = P.DataFrame(np.eye(2), columns=['a', 'b'])

df.plot()

import pylab as pl
pl.show()
dengemann commented 11 years ago

that's what i was suggesting, ok. at least one foot in the door...

On 19.12.2012, at 01:46, Christian Brodbeck notifications@github.com wrote:

actually (disregard what I just said) with a proper short script the plot is displayed as it should:

import numpy as np import pandas as P

df = P.DataFrame(np.eye(2), columns=['a', 'b'])

df.plot()

import pylab as pl pl.show() — Reply to this email directly or view it on GitHub.

christianbrodbeck commented 11 years ago

i hope you noticed how this toy-like example exposes some of the functionality we've been discussing, especially the groupby, as it splits your observations into cells resulting from crossing factors.

What would you think about something similar for epochs on construction / as method? @christianmbrodbeck, does this relate to eelbrain factors / ndvars, and if yes, how?

Well with a interaction you could easily produce indexes to sort an epoch into cells, i.e.

>>> A = factor('ab', rep=4, name='A')
>>> B = factor('ccddccdd', name='B')
>>> print dataset(A, B)
A   B
-----
a   c
a   c
a   d
a   d
b   c
b   c
b   d
b   d
>>> i = A % B
>>> i.cells
[('a', 'c'), ('a', 'd'), ('b', 'c'), ('b', 'd')]
>>> i == i.cells[0]
array([ True,  True, False, False, False, False, False, False], dtype=bool)
christianbrodbeck commented 11 years ago

The culprit is your pl.ion() call :)

dengemann commented 11 years ago

i like that! think we should keep up this discussion and see how to get cells into epochs for 0.6 . technically it's not a problem, i know. it's just that it should be compliant with our overall style / our API. @Eric89GXL what do you think, how does this cells example / the pandas groupby relate to your merge ids? I think we are approaching the same target from different directions.

On 19.12.2012, at 01:53, Christian Brodbeck notifications@github.com wrote:

i hope you noticed how this toy-like example exposes some of the functionality we've been discussing, especially the groupby, as it splits your observations into cells resulting from crossing factors.

What would you think about something similar for epochs on construction / as method? @christianmbrodbeck, does this relate to eelbrain factors / ndvars, and if yes, how?

Well with a interaction you could easily produce indexes to sort an epoch into cells, i.e.

A = factor('ab', rep=4, name='A') B = factor('ccddccdd', name='B') print dataset(A, B)

A B

a c a c a d a d b c b c b d b d i = A % B i.cells [('a', 'c'), ('a', 'd'), ('b', 'c'), ('b', 'd')] i == i.cells[0] array([ True, True, False, False, False, False, False, False], dtype=bool) — Reply to this email directly or view it on GitHub.

dengemann commented 11 years ago

oh, is it? great!!! should confirm that on temporally knocking out my ipython config..

thanks!

On 19.12.2012, at 01:55, Christian Brodbeck notifications@github.com wrote:

The culprit is your pl.ion() call :)

— Reply to this email directly or view it on GitHub.

larsoner commented 11 years ago

@dengemann yes, it sounds like these are converging. It could be cool to see a gist for the simple example in the sample dataset of trial-count equalizing LAud / RAud / LVis / RVis, then doing L vs R and Aud vs Vis contrasts using pandas to compare the complexity to the current method.

dengemann commented 11 years ago

yes sounds nice indeed! the pandas is certainly somewhat less natural as its extrenal to the mne-eco-system, also i would regard it as rather complementary, sth. to use after mne / or just to quickly explore things in between.

anyways, the question is, could we already close #133 or is there more to get?

one more thing i see in the moment would be formulas to generate crazy contrasts...

... and tuple / double key access to epochs with merge as instance method

On 19.12.2012, at 02:09, Eric89GXL notifications@github.com wrote:

@dengemann yes, it sounds like these are converging. It could be cool to see a gist for the simple example in the sample dataset of trial-count equalizing LAud / RAud / LVis / RVis, then doing L vs R and Aud vs Vis contrasts using pandas to compare the complexity to the current method.

— Reply to this email directly or view it on GitHub.

larsoner commented 11 years ago

@dengemann I think it makes sense to close #133. If you want to take a stab at a PR using pandas to do the example we talked about, that would be excellent.

dengemann commented 11 years ago

Let us just before try to note the overhead of ideas from #133, as I think it's not fully exploited yet. The basic functionality now is there, but as i said, the support for more complex contrasts / epochs can be improved.

So maybe close #133 but then open the above mentioned isues ;-)

On 19.12.2012, at 08:44, Eric89GXL notifications@github.com wrote:

@dengemann I think it makes sense to close #133. If you want to take a stab at a PR using pandas to do the example we talked about, that would be excellent.

— Reply to this email directly or view it on GitHub.

larsoner commented 11 years ago

Yeah, starting a fresh issue might be a good idea since it'll be easier to track.

Speaking of which, what's the status of this bugfix?

dengemann commented 11 years ago

I'll send a PR later, still stuck reducing my re-christmas institute-jobs stack :-(

On Wed, Dec 19, 2012 at 4:41 PM, Eric89GXL notifications@github.com wrote:

Yeah, starting a fresh issue might be a good idea since it'll be easier to track.

Speaking of which, what's the status of this bugfix?

— Reply to this email directly or view it on GitHubhttps://github.com/mne-tools/mne-python/issues/286#issuecomment-11534461.