{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/55087461","id":55087461,"diff_hunk":"@@ -443,3 +535,62 @@ def __init__(self, input_fname, events=None, event_id=None, tmin=0,\n             reject=reject, flat=flat, reject_tmin=reject_tmin,\n             reject_tmax=reject_tmax, add_eeg_ref=False, verbose=verbose)\n         logger.info('Ready.')\n+\n+\n+def _read_eeglab_events(eeg, event_id=None, event_id_func=None):\n+    \"\"\"Create events array from EEGLAB structure\n+\n+    An event array is constructed by looking up events in the\n+    event_id, trying to reduce them to their integer part otherwise, and\n+    entirely dropping them (with a warning) if this is impossible.\n+    Returns a 1x3 array of zeros if no events are found.\"\"\"\n+    if event_id_func is None:\n+        event_id_func = _strip_to_integer\n+    if event_id is None:\n+        event_id = dict()\n+\n+    types = [event.type for event in eeg.event]\n+    latencies = [event.latency for event in eeg.event]\n+\n+    not_in_event_id = set([x for x in types if x not in event_id])\n+    not_purely_numeric = set([x for x in not_in_event_id if not x.isdigit()])\n+    no_numbers = set([x for x in not_purely_numeric\n+                      if not any([d.isdigit() for d in x])])\n+    have_integers = set([x for x in not_purely_numeric\n+                         if x not in no_numbers])\n+    if len(not_purely_numeric) > 0:\n+        basewarn = \"Events like the following will be dropped\"\n+        n_no_numbers, n_have_integers = len(no_numbers), len(have_integers)\n+        if n_no_numbers > 0:\n+            no_num_warm = \" entirely: {}, {} in total\"\n+            warn(basewarn + no_num_warm.format(list(no_numbers)[:5],\n+                                               n_no_numbers))\n+        if n_have_integers > 0 and event_id_func is None:\n+            intwarn = (\", but could be reduced to their integer part \"\n+                       \"instead with the default `event_id_func`: \"\n+                       \"{}, {} in total\")\n+            warn(basewarn + intwarn.format(list(have_integers)[:5],\n+                                           n_have_integers))\n+\n+    events = list()\n+    for t, latency in zip(types, latencies):\n+        try:\n+            event_code = event_id[t] if t in event_id else event_id_func(t)\n+            events.append([int(latency), 1, event_code])\n+        except ValueError:\n+            pass  # We're already raising warnings above\n+\n+    if len(events) < len(types):\n+        warn(\"Some event codes could not be mapped to integers. Use the \"\n+             \"`event_id` parameter to map such events to integers manually.\")\n+    if len(events) < 3:","path":"mne/io/eeglab/eeglab.py","position":391,"original_position":391,"commit_id":"711b71ec5b705597f4e561770b82cf260f6d57b7","original_commit_id":"711b71ec5b705597f4e561770b82cf260f6d57b7","user":{"login":"agramfort","id":161052,"avatar_url":"https://avatars.githubusercontent.com/u/161052?v=3","gravatar_id":"","url":"https://api.github.com/users/agramfort","html_url":"https://github.com/agramfort","followers_url":"https://api.github.com/users/agramfort/followers","following_url":"https://api.github.com/users/agramfort/following{/other_user}","gists_url":"https://api.github.com/users/agramfort/gists{/gist_id}","starred_url":"https://api.github.com/users/agramfort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agramfort/subscriptions","organizations_url":"https://api.github.com/users/agramfort/orgs","repos_url":"https://api.github.com/users/agramfort/repos","events_url":"https://api.github.com/users/agramfort/events{/privacy}","received_events_url":"https://api.github.com/users/agramfort/received_events","type":"User","site_admin":false},"body":"why the < 3 and not < 1 ?","created_at":"2016-03-04T20:55:29Z","updated_at":"2016-03-04T20:55:29Z","html_url":"https://github.com/mne-tools/mne-python/pull/2975#discussion_r55087461","pull_request_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/55087461"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2975#discussion_r55087461"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975","id":61338017,"html_url":"https://github.com/mne-tools/mne-python/pull/2975","diff_url":"https://github.com/mne-tools/mne-python/pull/2975.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/2975.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2975","number":2975,"state":"open","locked":false,"title":"Add eeglab event reader, 3rd try","user":{"login":"jona-sassenhagen","id":4321826,"avatar_url":"https://avatars.githubusercontent.com/u/4321826?v=3","gravatar_id":"","url":"https://api.github.com/users/jona-sassenhagen","html_url":"https://github.com/jona-sassenhagen","followers_url":"https://api.github.com/users/jona-sassenhagen/followers","following_url":"https://api.github.com/users/jona-sassenhagen/following{/other_user}","gists_url":"https://api.github.com/users/jona-sassenhagen/gists{/gist_id}","starred_url":"https://api.github.com/users/jona-sassenhagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jona-sassenhagen/subscriptions","organizations_url":"https://api.github.com/users/jona-sassenhagen/orgs","repos_url":"https://api.github.com/users/jona-sassenhagen/repos","events_url":"https://api.github.com/users/jona-sassenhagen/events{/privacy}","received_events_url":"https://api.github.com/users/jona-sassenhagen/received_events","type":"User","site_admin":false},"body":"EEGLAB reader is missing the ability to read events, making it basically worthless as is. This adds the ability to read events (with a syntax for handling non-ints previously discussed with @agramfort , @teonlamont and @jasmainak).\r\n\r\n~~WIP. It doesn't crash and it returns *something*, that's it for now.~~\r\n\r\nSorry for taking so long, I just really don't get file IO.\r\n\r\nThanks @jaeilepp for tips.\r\n\r\n~~No test yet. Do we even have raw data with events?~~ ","created_at":"2016-03-02T01:28:38Z","updated_at":"2016-03-04T20:55:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"53ab7ff988a9c6e3636b7895c13bbe6e76b9098a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975/comments","review_comment_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2975/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/711b71ec5b705597f4e561770b82cf260f6d57b7","head":{"label":"jona-sassenhagen:eeglab-events","ref":"eeglab-events","sha":"711b71ec5b705597f4e561770b82cf260f6d57b7","user":{"login":"jona-sassenhagen","id":4321826,"avatar_url":"https://avatars.githubusercontent.com/u/4321826?v=3","gravatar_id":"","url":"https://api.github.com/users/jona-sassenhagen","html_url":"https://github.com/jona-sassenhagen","followers_url":"https://api.github.com/users/jona-sassenhagen/followers","following_url":"https://api.github.com/users/jona-sassenhagen/following{/other_user}","gists_url":"https://api.github.com/users/jona-sassenhagen/gists{/gist_id}","starred_url":"https://api.github.com/users/jona-sassenhagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jona-sassenhagen/subscriptions","organizations_url":"https://api.github.com/users/jona-sassenhagen/orgs","repos_url":"https://api.github.com/users/jona-sassenhagen/repos","events_url":"https://api.github.com/users/jona-sassenhagen/events{/privacy}","received_events_url":"https://api.github.com/users/jona-sassenhagen/received_events","type":"User","site_admin":false},"repo":{"id":26366770,"name":"mne-python","full_name":"jona-sassenhagen/mne-python","owner":{"login":"jona-sassenhagen","id":4321826,"avatar_url":"https://avatars.githubusercontent.com/u/4321826?v=3","gravatar_id":"","url":"https://api.github.com/users/jona-sassenhagen","html_url":"https://github.com/jona-sassenhagen","followers_url":"https://api.github.com/users/jona-sassenhagen/followers","following_url":"https://api.github.com/users/jona-sassenhagen/following{/other_user}","gists_url":"https://api.github.com/users/jona-sassenhagen/gists{/gist_id}","starred_url":"https://api.github.com/users/jona-sassenhagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jona-sassenhagen/subscriptions","organizations_url":"https://api.github.com/users/jona-sassenhagen/orgs","repos_url":"https://api.github.com/users/jona-sassenhagen/repos","events_url":"https://api.github.com/users/jona-sassenhagen/events{/privacy}","received_events_url":"https://api.github.com/users/jona-sassenhagen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jona-sassenhagen/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":true,"url":"https://api.github.com/repos/jona-sassenhagen/mne-python","forks_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/forks","keys_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/teams","hooks_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/hooks","issue_events_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/events","assignees_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/tags","blobs_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/languages","stargazers_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/stargazers","contributors_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/contributors","subscribers_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/subscribers","subscription_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/subscription","commits_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/merges","archive_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/downloads","issues_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/releases{/id}","deployments_url":"https://api.github.com/repos/jona-sassenhagen/mne-python/deployments","created_at":"2014-11-08T16:37:16Z","updated_at":"2015-03-21T16:54:38Z","pushed_at":"2016-03-04T14:09:35Z","git_url":"git://github.com/jona-sassenhagen/mne-python.git","ssh_url":"git@github.com:jona-sassenhagen/mne-python.git","clone_url":"https://github.com/jona-sassenhagen/mne-python.git","svn_url":"https://github.com/jona-sassenhagen/mne-python","homepage":"http://martinos.org/mne/","size":82473,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mne-tools:master","ref":"master","sha":"e1b90ef13a421fdd06b02f22c8e352417b588b04","user":{"login":"mne-tools","id":583875,"avatar_url":"https://avatars.githubusercontent.com/u/583875?v=3","gravatar_id":"","url":"https://api.github.com/users/mne-tools","html_url":"https://github.com/mne-tools","followers_url":"https://api.github.com/users/mne-tools/followers","following_url":"https://api.github.com/users/mne-tools/following{/other_user}","gists_url":"https://api.github.com/users/mne-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/mne-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mne-tools/subscriptions","organizations_url":"https://api.github.com/users/mne-tools/orgs","repos_url":"https://api.github.com/users/mne-tools/repos","events_url":"https://api.github.com/users/mne-tools/events{/privacy}","received_events_url":"https://api.github.com/users/mne-tools/received_events","type":"Organization","site_admin":false},"repo":{"id":1301584,"name":"mne-python","full_name":"mne-tools/mne-python","owner":{"login":"mne-tools","id":583875,"avatar_url":"https://avatars.githubusercontent.com/u/583875?v=3","gravatar_id":"","url":"https://api.github.com/users/mne-tools","html_url":"https://github.com/mne-tools","followers_url":"https://api.github.com/users/mne-tools/followers","following_url":"https://api.github.com/users/mne-tools/following{/other_user}","gists_url":"https://api.github.com/users/mne-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/mne-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mne-tools/subscriptions","organizations_url":"https://api.github.com/users/mne-tools/orgs","repos_url":"https://api.github.com/users/mne-tools/repos","events_url":"https://api.github.com/users/mne-tools/events{/privacy}","received_events_url":"https://api.github.com/users/mne-tools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mne-tools/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":false,"url":"https://api.github.com/repos/mne-tools/mne-python","forks_url":"https://api.github.com/repos/mne-tools/mne-python/forks","keys_url":"https://api.github.com/repos/mne-tools/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mne-tools/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mne-tools/mne-python/teams","hooks_url":"https://api.github.com/repos/mne-tools/mne-python/hooks","issue_events_url":"https://api.github.com/repos/mne-tools/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/mne-tools/mne-python/events","assignees_url":"https://api.github.com/repos/mne-tools/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/mne-tools/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/mne-tools/mne-python/tags","blobs_url":"https://api.github.com/repos/mne-tools/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mne-tools/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mne-tools/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/mne-tools/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/mne-tools/mne-python/languages","stargazers_url":"https://api.github.com/repos/mne-tools/mne-python/stargazers","contributors_url":"https://api.github.com/repos/mne-tools/mne-python/contributors","subscribers_url":"https://api.github.com/repos/mne-tools/mne-python/subscribers","subscription_url":"https://api.github.com/repos/mne-tools/mne-python/subscription","commits_url":"https://api.github.com/repos/mne-tools/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/mne-tools/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/mne-tools/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/mne-tools/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/mne-tools/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/mne-tools/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mne-tools/mne-python/merges","archive_url":"https://api.github.com/repos/mne-tools/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mne-tools/mne-python/downloads","issues_url":"https://api.github.com/repos/mne-tools/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/mne-tools/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/mne-tools/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/mne-tools/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mne-tools/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/mne-tools/mne-python/releases{/id}","deployments_url":"https://api.github.com/repos/mne-tools/mne-python/deployments","created_at":"2011-01-28T03:31:13Z","updated_at":"2016-02-29T17:06:38Z","pushed_at":"2016-03-04T16:10:49Z","git_url":"git://github.com/mne-tools/mne-python.git","ssh_url":"git@github.com:mne-tools/mne-python.git","clone_url":"https://github.com/mne-tools/mne-python.git","svn_url":"https://github.com/mne-tools/mne-python","homepage":"http://martinos.org/mne/","size":171493,"stargazers_count":183,"watchers_count":183,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":171,"mirror_url":null,"open_issues_count":176,"forks":171,"open_issues":176,"watchers":183,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2975"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2975"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2975/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975/comments"},"review_comment":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2975/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-python/statuses/711b71ec5b705597f4e561770b82cf260f6d57b7"}}}}