beOn / cili

cili - bring your eye tracking data into focus
Other
24 stars 10 forks source link

Error while extracting ranges: 'Events' object has no atribute 'index' #11

Closed egorananyev closed 8 years ago

egorananyev commented 8 years ago

Thanks a lot for a great package! I'm getting an error while trying to extract ranges from events:

from cili.util import *
from cili.cleanup import *
from cili.extract import extract_event_ranges
samps, events = load_eyelink_dataset(subjEtPath)
ranges = extract_event_ranges(samps, events, end_offset=1000)

I'm getting the following error:


AttributeError Traceback (most recent call last)

in () 13 #samps = interp_eyelink_blinks(samps, events, interp_fields=["pup_l"]) 14 #samps = interp_zeros(samps, interp_fields=["pup_l"]) ---> 15 ranges = extract_event_ranges(samps, events, end_offset=1000) /Users/egor/Library/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/cili/extract.pyc in extract_event_ranges(samples, events_dataframe, start_offset, end_offset, round_indices, borrow_attributes) 44 raise ValueError("start_offset must be < end_offset") 45 # get the list of start and stop times ---> 46 e_starts = events_dataframe.index.to_series() 47 r_times = pd.DataFrame(e_starts + end_offset) 48 r_times.index += start_offset /Users/egor/Library/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/cili/models.pyc in **getattr**(self, name) 136 return self.dframes[name] 137 raise AttributeError("'%s' object has no attribute '%s'" % --> 138 (type(self).**name**, name)) 139 140 def initialize_hdf5(): AttributeError: 'Events' object has no attribute 'index'

print dir(events)

['EBLINK', 'EFIX', 'END', 'ESACC', 'MSG', 'START', 'class', 'delattr', 'dict', 'dir', 'doc', 'format', 'getattr', 'getattribute', 'hash', 'init', 'module', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'weakref', '_local_dir', 'from_dict', 'from_list_of_dicts', 'load_saved', 'save']

beOn commented 8 years ago

Hm. Any luck yet? If not, send a sample dataset and I'll take a look.

How often do you get this - with every dataset, once in a while, or just once?

egorananyev commented 8 years ago

Please see the data set attached. Not sure if this is really the problem though, because, as you can see in the printout, the "events" lacks an attribute, so could have something to do with package version or what not. Please let me know if you need more info. data.asc.zip

beOn commented 8 years ago

A dump of your package versions might help. On Mon, Oct 31, 2016 at 10:47 PM Egor Ananyev notifications@github.com wrote:

Please see the data set attached. Not sure if this is really the problem though, because, as you can see in the printout, the "events" lacks an attribute, so could have something to do with package version or what not. Please let me know if you need more info. data.asc.zip https://github.com/beOn/cili/files/563308/data.asc.zip

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/beOn/cili/issues/11#issuecomment-257482536, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC-RP-v00Wq_2lTta27xLSonInI1O2Mks5q5rZNgaJpZM4KeFR3 .

egorananyev commented 8 years ago

pip list

alabaster (0.7.9) altgraph (0.12) appinst (2.1.2) appnope (0.1.0) apptools (4.2.1) astroid (1.4.8) atom (0.3.9) Babel (2.3.4) backports.functools-lru-cache (1.3) backports.shutil-get-terminal-size (1.0.0) backports.ssl-match-hostname (3.2a3) bambi (0.0.3) blaze (0.7.0) Canopy (1.5.2.dev7471) canopydebugger (0.1.1.dev0) canopydebugger-addon (0.1.1.dev0) casuarius (1.1) certifi (2016.8.31) chaco (4.5.0) cili (0.5.3) cloud (2.4.6) codetools (4.2.0) CommonMark (0.5.4) configobj (5.0.6) configparser (3.5.0) coverage (3.7.1) DataShape (0.4.2) decorator (4.0.10) distribute (0.6.49) docutils (0.12) enable (4.4.1) enaml (0.9.8) enclosure (0.2) encore (0.6.0) enstaller (4.8.1) entrypoints (0.2.2) enum34 (1.1.6) envisage (4.4.0) esky (0.9.8.dev0) etsproxy (0.1.2) Examples (7.3) faulthandler (2.4) feedparser (5.1.3) flake8 (2.2.5) freetype (2.5.3) functools32 (3.2.3.post2) futures (2.2.0) gevent (1.1.2) greenlet (0.4.10) grits-client (0.1) hdf5 (1.8.14) idle (2.7.3) imagesize (0.7.1) into (0.1.3) ipykernel (4.5.0) ipython (5.1.0) ipython-genutils (0.1.0) ipywidgets (5.2.2) isort (4.2.5) jedi (0.9.0) Jinja2 (2.7.3) joblib (0.10.2) jsonpickle (0.4.0) jsonschema (2.5.1) jupyter (1.0.0) jupyter-client (4.4.0) jupyter-console (5.0.0) jupyter-core (4.2.0) jupyterthemes (0.12.3) kernmagic (0.2.0) keyring (4.0) kiwisolver (0.1.3) lazy-object-proxy (1.2.2) lesscpy (0.11.1) libjpeg (7.0) libpng (1.6.12) libxml2 (2.9.2) macholib (1.7) MarkupSafe (0.23) matplotlib (1.4.2) mccabe (0.5.2) memory-profiler (0.31.0) mistune (0.7.3) MKL (10.3) mock (1.0.1) modulegraph (0.12.1) msgpack-python (0.4.8) nbconvert (4.2.0) nbformat (4.1.0) nbsphinx (0.2.9) nose (1.3.4) notebook (4.2.3) numexpr (2.4.0) numpy (1.8.1) numpydoc (0.6.0) pandas (0.15.2) pathlib2 (2.1.0) patsy (0.4.1) pep8 (1.7.0) pexpect (4.2.1) pickleshare (0.7.4) PIL (1.1.7) pip (6.0.8) ply (3.4) prompt-toolkit (1.0.7) psutil (2.2.0) PsychoPy (1.84.1) ptyprocess (0.5.1) pyaudio (0.2.4) pycrypto (2.6.1) pyface (4.4.0) pyflakes (0.4.5.dev80) pyglet (1.2.4) Pygments (2.0.2) pylint (1.6.4) pymc3 (3.0rc1) pyobjc-core (3.1.1) pyobjc-framework-Cocoa (3.1.1) pyobjc-framework-Quartz (3.1.1) pyparsing (2.0.2) PySide (1.2.2) pytables (3.1.1) python-dateutil (2.2.0) PythonDoc (2.7.3) pytz (2014.9.0) PyYAML (3.12) pyzmq (14.5.0) Qt (4.8.6) QtAwesome (0.3.3) qtconsole (4.2.1) QtPy (1.1.2) readline (6.2.1) recommonmark (0.4.0) requests (2.5.1) rope (0.10.3) scipy (0.14.1rc1) seaborn (0.7.1) setuptools (27.3.0) shiboken (1.2.2) simplegeneric (0.8.1) six (1.8.0) snowballstemmer (1.2.1) Sphinx (1.4.8) spyder (3.0.0) ssl-match-hostname (3.4.0.2) statsmodels (0.6.1) supplement (0.5dev.dev202) sympy (0.7.6) tables (3.3.0) terminado (0.6) Theano (0.8.2) tornado (4.0.2) traitlets (4.3.0) traits (4.5.0) traits-enaml (0.2.1) traitsui (4.4.0) wcwidth (0.1.7) widgetsnbextension (1.2.6) wrapt (1.10.8) wxPython (2.8.10.1) zeromq (4.0.5)

beOn commented 8 years ago

Thank you. I'll take a look. On Mon, Oct 31, 2016 at 10:51 PM Egor Ananyev notifications@github.com wrote:

pip list

alabaster (0.7.9) altgraph (0.12) appinst (2.1.2) appnope (0.1.0) apptools (4.2.1) astroid (1.4.8) atom (0.3.9) Babel (2.3.4) backports.functools-lru-cache (1.3) backports.shutil-get-terminal-size (1.0.0) backports.ssl-match-hostname (3.2a3) bambi (0.0.3) blaze (0.7.0) Canopy (1.5.2.dev7471) canopydebugger (0.1.1.dev0) canopydebugger-addon (0.1.1.dev0) casuarius (1.1) certifi (2016.8.31) chaco (4.5.0) cili (0.5.3) cloud (2.4.6) codetools (4.2.0) CommonMark (0.5.4) configobj (5.0.6) configparser (3.5.0) coverage (3.7.1) DataShape (0.4.2) decorator (4.0.10) distribute (0.6.49) docutils (0.12) enable (4.4.1) enaml (0.9.8) enclosure (0.2) encore (0.6.0) enstaller (4.8.1) entrypoints (0.2.2) enum34 (1.1.6) envisage (4.4.0) esky (0.9.8.dev0) etsproxy (0.1.2) Examples (7.3) faulthandler (2.4) feedparser (5.1.3) flake8 (2.2.5) freetype (2.5.3) functools32 (3.2.3.post2) futures (2.2.0) gevent (1.1.2) greenlet (0.4.10) grits-client (0.1) hdf5 (1.8.14) idle (2.7.3) imagesize (0.7.1) into (0.1.3) ipykernel (4.5.0) ipython (5.1.0) ipython-genutils (0.1.0) ipywidgets (5.2.2) isort (4.2.5) jedi (0.9.0) Jinja2 (2.7.3) joblib (0.10.2) jsonpickle (0.4.0) jsonschema (2.5.1) jupyter (1.0.0) jupyter-client (4.4.0) jupyter-console (5.0.0) jupyter-core (4.2.0) jupyterthemes (0.12.3) kernmagic (0.2.0) keyring (4.0) kiwisolver (0.1.3) lazy-object-proxy (1.2.2) lesscpy (0.11.1) libjpeg (7.0) libpng (1.6.12) libxml2 (2.9.2) macholib (1.7) MarkupSafe (0.23) matplotlib (1.4.2) mccabe (0.5.2) memory-profiler (0.31.0) mistune (0.7.3) MKL (10.3) mock (1.0.1) modulegraph (0.12.1) msgpack-python (0.4.8) nbconvert (4.2.0) nbformat (4.1.0) nbsphinx (0.2.9) nose (1.3.4) notebook (4.2.3) numexpr (2.4.0) numpy (1.8.1) numpydoc (0.6.0) pandas (0.15.2) pathlib2 (2.1.0) patsy (0.4.1) pep8 (1.7.0) pexpect (4.2.1) pickleshare (0.7.4) PIL (1.1.7) pip (6.0.8) ply (3.4) prompt-toolkit (1.0.7) psutil (2.2.0) PsychoPy (1.84.1) ptyprocess (0.5.1) pyaudio (0.2.4) pycrypto (2.6.1) pyface (4.4.0) pyflakes (0.4.5.dev80) pyglet (1.2.4) Pygments (2.0.2) pylint (1.6.4) pymc3 (3.0rc1) pyobjc-core (3.1.1) pyobjc-framework-Cocoa (3.1.1) pyobjc-framework-Quartz (3.1.1) pyparsing (2.0.2) PySide (1.2.2) pytables (3.1.1) python-dateutil (2.2.0) PythonDoc (2.7.3) pytz (2014.9.0) PyYAML (3.12) pyzmq (14.5.0) Qt (4.8.6) QtAwesome (0.3.3) qtconsole (4.2.1) QtPy (1.1.2) readline (6.2.1) recommonmark (0.4.0) requests (2.5.1) rope (0.10.3) scipy (0.14.1rc1) seaborn (0.7.1) setuptools (27.3.0) shiboken (1.2.2) simplegeneric (0.8.1) six (1.8.0) snowballstemmer (1.2.1) Sphinx (1.4.8) spyder (3.0.0) ssl-match-hostname (3.4.0.2) statsmodels (0.6.1) supplement (0.5dev.dev202) sympy (0.7.6) tables (3.3.0) terminado (0.6) Theano (0.8.2) tornado (4.0.2) traitlets (4.3.0) traits (4.5.0) traits-enaml (0.2.1) traitsui (4.4.0) wcwidth (0.1.7) widgetsnbextension (1.2.6) wrapt (1.10.8) wxPython (2.8.10.1) zeromq (4.0.5)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/beOn/cili/issues/11#issuecomment-257482893, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC-ROOhmqxwsgRF5XyXb7Fnbr_eokPkks5q5rcpgaJpZM4KeFR3 .

beOn commented 8 years ago

Also - does this happen with every dataset you try? On Mon, Oct 31, 2016 at 10:52 PM Ben Acland benacland@gmail.com wrote:

Thank you. I'll take a look. On Mon, Oct 31, 2016 at 10:51 PM Egor Ananyev notifications@github.com wrote:

pip list

alabaster (0.7.9) altgraph (0.12) appinst (2.1.2) appnope (0.1.0) apptools (4.2.1) astroid (1.4.8) atom (0.3.9) Babel (2.3.4) backports.functools-lru-cache (1.3) backports.shutil-get-terminal-size (1.0.0) backports.ssl-match-hostname (3.2a3) bambi (0.0.3) blaze (0.7.0) Canopy (1.5.2.dev7471) canopydebugger (0.1.1.dev0) canopydebugger-addon (0.1.1.dev0) casuarius (1.1) certifi (2016.8.31) chaco (4.5.0) cili (0.5.3) cloud (2.4.6) codetools (4.2.0) CommonMark (0.5.4) configobj (5.0.6) configparser (3.5.0) coverage (3.7.1) DataShape (0.4.2) decorator (4.0.10) distribute (0.6.49) docutils (0.12) enable (4.4.1) enaml (0.9.8) enclosure (0.2) encore (0.6.0) enstaller (4.8.1) entrypoints (0.2.2) enum34 (1.1.6) envisage (4.4.0) esky (0.9.8.dev0) etsproxy (0.1.2) Examples (7.3) faulthandler (2.4) feedparser (5.1.3) flake8 (2.2.5) freetype (2.5.3) functools32 (3.2.3.post2) futures (2.2.0) gevent (1.1.2) greenlet (0.4.10) grits-client (0.1) hdf5 (1.8.14) idle (2.7.3) imagesize (0.7.1) into (0.1.3) ipykernel (4.5.0) ipython (5.1.0) ipython-genutils (0.1.0) ipywidgets (5.2.2) isort (4.2.5) jedi (0.9.0) Jinja2 (2.7.3) joblib (0.10.2) jsonpickle (0.4.0) jsonschema (2.5.1) jupyter (1.0.0) jupyter-client (4.4.0) jupyter-console (5.0.0) jupyter-core (4.2.0) jupyterthemes (0.12.3) kernmagic (0.2.0) keyring (4.0) kiwisolver (0.1.3) lazy-object-proxy (1.2.2) lesscpy (0.11.1) libjpeg (7.0) libpng (1.6.12) libxml2 (2.9.2) macholib (1.7) MarkupSafe (0.23) matplotlib (1.4.2) mccabe (0.5.2) memory-profiler (0.31.0) mistune (0.7.3) MKL (10.3) mock (1.0.1) modulegraph (0.12.1) msgpack-python (0.4.8) nbconvert (4.2.0) nbformat (4.1.0) nbsphinx (0.2.9) nose (1.3.4) notebook (4.2.3) numexpr (2.4.0) numpy (1.8.1) numpydoc (0.6.0) pandas (0.15.2) pathlib2 (2.1.0) patsy (0.4.1) pep8 (1.7.0) pexpect (4.2.1) pickleshare (0.7.4) PIL (1.1.7) pip (6.0.8) ply (3.4) prompt-toolkit (1.0.7) psutil (2.2.0) PsychoPy (1.84.1) ptyprocess (0.5.1) pyaudio (0.2.4) pycrypto (2.6.1) pyface (4.4.0) pyflakes (0.4.5.dev80) pyglet (1.2.4) Pygments (2.0.2) pylint (1.6.4) pymc3 (3.0rc1) pyobjc-core (3.1.1) pyobjc-framework-Cocoa (3.1.1) pyobjc-framework-Quartz (3.1.1) pyparsing (2.0.2) PySide (1.2.2) pytables (3.1.1) python-dateutil (2.2.0) PythonDoc (2.7.3) pytz (2014.9.0) PyYAML (3.12) pyzmq (14.5.0) Qt (4.8.6) QtAwesome (0.3.3) qtconsole (4.2.1) QtPy (1.1.2) readline (6.2.1) recommonmark (0.4.0) requests (2.5.1) rope (0.10.3) scipy (0.14.1rc1) seaborn (0.7.1) setuptools (27.3.0) shiboken (1.2.2) simplegeneric (0.8.1) six (1.8.0) snowballstemmer (1.2.1) Sphinx (1.4.8) spyder (3.0.0) ssl-match-hostname (3.4.0.2) statsmodels (0.6.1) supplement (0.5dev.dev202) sympy (0.7.6) tables (3.3.0) terminado (0.6) Theano (0.8.2) tornado (4.0.2) traitlets (4.3.0) traits (4.5.0) traits-enaml (0.2.1) traitsui (4.4.0) wcwidth (0.1.7) widgetsnbextension (1.2.6) wrapt (1.10.8) wxPython (2.8.10.1) zeromq (4.0.5)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/beOn/cili/issues/11#issuecomment-257482893, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC-ROOhmqxwsgRF5XyXb7Fnbr_eokPkks5q5rcpgaJpZM4KeFR3 .

egorananyev commented 8 years ago

Yes, it does.

beOn commented 8 years ago

Please see the method's documentation for that argument:

"""
...
events_dataframe (DataFrame object containing event timing info)
        Indices should be onset times, duration should be in a column named
        'duration'. Note that if you have an Events object evs, and it has,
        say, a set of events named "EBLINK", then you can pass Events.EBLINK
        for this argument.
...
"""

Hm. There's a typo there. Should be evs.EBLINK. This has been fixed. But the point is: the type of this argument is DataFrame, and you are passing in an instance of Events. Your call

extract_event_ranges(samps, events, end_offset=1000)

would, if the method were made to handle whole Events objects, extract a range for every event of every type - not a use case I anticipated. I'm able to repro your issue if I use the same line, but don't consider it a bug. So try using one of the specific event types, 'EBLINK', 'EFIX', 'END', 'ESACC', 'MSG', or 'START', like so:

ranges = extract_event_ranges(samps, events.EFIX, end_offset=1000)

Works for me. It's pretty fast, so if you must you can combine the data afterwards.

Also, you should be getting the following message:

UserWarning: extract_event_ranges will be removed in a future release!

And there's a note in the documentation of the method:

"""
...
See note at bottom - this method works, but has been replaced.
"""

The note at the bottom was actually deleted at the same time as this comment was added (d'oh!), so I have made a clarification there. And I've also added the following to the error message: use extract_events instead!