beOn / cili

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

KeyError: 'onset' #1

Closed dschreij closed 9 years ago

dschreij commented 10 years ago

Hi! To begin with: great project! I only have trouble reading in in ascii files because it crashes with KeyError: "onset" in the process. Here's a traceback

Traceback (most recent call last):

  File "C:/Users/Daniel/Dropbox/VU/EPOS/EyeTrackerCourse/eposetcourse.py", line 8, in <module>
    samples, events = cili.load_eyelink_dataset("01RB.asc")

  File "build\bdist.win32\egg\cili\util.py", line 156, in load_eyelink_dataset
    s, e = pandas_dfs_from_asc(file_name)

  File "build\bdist.win32\egg\cili\util.py", line 210, in pandas_dfs_from_asc
    samp_df = pandas_df_from_lines(s_lines, samp_dtypes, ASC_SFIELDS_IGNORE)

  File "build\bdist.win32\egg\cili\util.py", line 241, in pandas_df_from_lines
    warn_bad_lines=False,)

  File "C:\Python27\lib\site-packages\pandas\io\parsers.py", line 463, in parser_f
    return _read(filepath_or_buffer, kwds)

  File "C:\Python27\lib\site-packages\pandas\io\parsers.py", line 249, in _read
    return parser.read()

  File "C:\Python27\lib\site-packages\pandas\io\parsers.py", line 706, in read
    ret = self._engine.read(nrows)

  File "C:\Python27\lib\site-packages\pandas\io\parsers.py", line 1170, in read
    values = data.pop(self.index_col[i])

KeyError: 'onset'

If you want, I can send you one of the .asc files to reproduce the error. There are no variables in my ascii files named "onset" (nor does it occur in any other form in there). I dove into the util.py folder and saw that you pass "onset" as the argument of index_col for pandas' read_csv function, but is this variable also created in the pandas_dfs_from_asc() function? I see you explicitly assigning "onset" as the index name in pandas_df_from_txt() (line 183), but not in the former function.

nccanderson commented 10 years ago

Try unchecking Output Input Values in the EDF Converter when you convert your .edf to .asc.

beOn commented 10 years ago

So sorry for the slow response! Did nccanderson's suggestion help? If so, I'll add it to the documentation.

beOn commented 9 years ago

Closing for now... please hit me up again if the issue persists!

fusaroli commented 9 years ago

Opening this up again. I have been playing with this great project and I am having the same problem as dschreij and my file never had output input values checked. I also tried checking it but no luck. The files are here:

And here the error messages:


KeyError Traceback (most recent call last)

in () 8 # Load the files and clean up the clutter 9 ---> 10 samps, events = load_eyelink_dataset("/Users/semrf/Dropbox/Stuff we share/101.asc") /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cili/util.pyc in load_eyelink_dataset(file_name) 154 root, ext = os.path.splitext(file_name) 155 if ext == '.asc': --> 156 s, e = pandas_dfs_from_asc(file_name) 157 elif ext in ['.txt']: 158 s = load_tdf(file_name) /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cili/util.pyc in pandas_dfs_from_asc(file_path) 208 ev_dtypes = dict([(ev_name, build_asc_ev_dtypes(ev_name, side, has_vel, has_res)) for ev_name in ev_names]) 209 # get a df for the samples --> 210 samp_df = pandas_df_from_lines(s_lines, samp_dtypes, ASC_SFIELDS_IGNORE) 211 # handle event types that need to have their lines preprocessed... 212 for ev_name in ASC_IRREG_EVENTS: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cili/util.pyc in pandas_df_from_lines(csv_lines, dtypes, ignore) 239 error_bad_lines=False, 240 # usecols=use_names, --> 241 warn_bad_lines=False,) 242 nums = [d[0] for d in dtypes if d[1] not in [object] and d[0] not in ['onset']] 243 ints = [d[0] for d in dtypes if d[1] in ASC_INT_TYPES and d[0] not in ['onset']] /Users/semrf/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, dialect, compression, doublequote, escapechar, quotechar, quoting, skipinitialspace, lineterminator, header, index_col, names, prefix, skiprows, skipfooter, skip_footer, na_values, na_fvalues, true_values, false_values, delimiter, converters, dtype, usecols, engine, delim_whitespace, as_recarray, na_filter, compact_ints, use_unsigned, low_memory, buffer_lines, warn_bad_lines, error_bad_lines, keep_default_na, thousands, comment, decimal, parse_dates, keep_date_col, dayfirst, date_parser, memory_map, float_precision, nrows, iterator, chunksize, verbose, encoding, squeeze, mangle_dupe_cols, tupleize_cols, infer_datetime_format, skip_blank_lines) 468 skip_blank_lines=skip_blank_lines) 469 --> 470 return _read(filepath_or_buffer, kwds) 471 472 parser_f.__name__ = name /Users/semrf/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds) 254 return parser 255 --> 256 return parser.read() 257 258 _parser_defaults = { /Users/semrf/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.py in read(self, nrows) 713 raise ValueError('skip_footer not supported for iteration') 714 --> 715 ret = self._engine.read(nrows) 716 717 if self.options.get('as_recarray'): /Users/semrf/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.py in read(self, nrows) 1182 values = data.pop(i) 1183 else: -> 1184 values = data.pop(self.index_col[i]) 1185 1186 values = self._maybe_parse_dates(values, i, KeyError: 'onset'
beOn commented 9 years ago

re-opening

beOn commented 9 years ago

@fusaroli @dschreij Closed. Sorry for the delay dschreij - I wasn't sure whether nccanderson's suggestion addressed your issue.

For the record, two things were going on. First, we weren't looking for the input column. Second, we weren't looking for several columns that only show up in remote recording .asc files. Both issues have been addressed, and I'm able to parse your file.

fusaroli commented 9 years ago

Now it works. Thanks

beOn commented 9 years ago

Great!

On Jul 8, 2015, at 4:25 AM, Riccardo Fusaroli notifications@github.com wrote:

Now it works. Thanks

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