{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/65182261","id":65182261,"diff_hunk":"@@ -827,3 +828,289 @@ def concatenate_events(events, first_samps, last_samps):\n         events_out = np.concatenate((events_out, e2), axis=0)\n \n     return events_out\n+\n+\n+class Elekta_event(object):\n+    \"\"\" Represents a trigger event in Elekta/Neuromag system.  \"\"\"\n+    # original DACQ variable names\n+    vars = ['Name', 'Channel', 'NewBits', 'OldBits', 'NewMask',\n+            'OldMask', 'Delay', 'Comment']\n+\n+    def __init__(self, name, channel, newbits, oldbits, newmask,\n+                 oldmask, delay, comment):\n+        self.name = name  # short name for the event\n+        self.channel = channel  # stimulus channel, e.g. STI101\n+        self.newbits = int(newbits)  # state after trigger transition\n+        self.oldbits = int(oldbits)  # state before trigger transition\n+        self.newmask = int(newmask)  # bitmask for post-transition state\n+        self.oldmask = int(oldmask)  # bitmask for pre-transition state\n+        self.delay = float(delay)  # delay to stimulus (s)\n+        self.comment = comment  # verbose comment for the event\n+        # non-DACQ vars\n+        self.index = None  # index of event in DACQ list\n+        self.in_use = False  # whether event is referred to by a category\n+\n+    def __repr__(self):\n+        s = '<Elekta_event | '\n+        s += 'index: %d ' % self.index\n+        s += 'name: \"%s\", ' % self.name\n+        s += 'comment: \"%s\", ' % self.comment\n+        s += 'pre-state: %d, ' % self.oldbits\n+        s += 'pre-mask: %d, ' % self.oldmask\n+        s += 'post-state: %d, ' % self.newbits\n+        s += 'post-mask: %d, ' % self.newmask\n+        s += 'delay: %.3f (s)>' % self.delay\n+        return s\n+\n+\n+class Elekta_category(object):\n+    \"\"\" Represents an averaging category in Elekta/Neuromag system. \"\"\"\n+\n+    # original DACQ variable names\n+    vars = ['Comment', 'Display', 'Start', 'State', 'End', 'Event',\n+            'Nave', 'ReqEvent', 'ReqWhen', 'ReqWithin',  'SubAve']\n+\n+    def __init__(self, comment, display, start, state, end, event, nave,\n+                 reqevent, reqwhen, reqwithin, subave):\n+        self.comment = comment\n+        self.display = True if display == u'1' else False  # show online\n+        self.state = True if state == u'1' else False  # enabled or not\n+        self.start = float(start)  # epoch start\n+        self.end = float(end)  # epoch end\n+        self.nave = int(nave)  # desired n of averages\n+        self.event = int(event)  # the reference event (index to event list)\n+        self.reqevent = int(reqevent)  # required event (index to event list)\n+        self.reqwhen = int(reqwhen)  # 1=before, 2=after ref. event\n+        # time window before or after ref. event (s)\n+        self.reqwithin = float(reqwithin)\n+        self.subave = int(subave)  # subaverage size\n+        # non-DACQ vars\n+        # list of t=0 times (in samples) for corresponding epochs\n+        self.times = None\n+        # index of category in DACQ list\n+        self.index = None\n+\n+    def __repr__(self):\n+        s = '<Elekta_category | '\n+        s += '\"%s\", ' % self.comment\n+        s += 'ref. event: %d, ' % self.event\n+        if self.reqevent:\n+            s += 'req. event: %d ' % self.reqevent\n+            s += 'within: %.3f (s) ' % self.reqwithin\n+            s += 'before ' if self.reqwhen == 1 else 'after '\n+            s += 'ref. event, '\n+        s += 'start: %.3f (s), ' % self.start\n+        s += 'end: %.3f (s)>' % self.end\n+        return s\n+\n+    def epochs(self, raw, picks=None, reject=None,\n+               baseline=(None, 0), stim_channel=None, mask=0):\n+        \"\"\" Get mne.Epochs instance corresponding to the category. \"\"\"\n+        return self._parent._get_epochs(raw, self, picks=picks,\n+                                        reject=reject, baseline=baseline,\n+                                        stim_channel=stim_channel,\n+                                        mask=mask)\n+\n+\n+class Elekta_averager(object):\n+    \"\"\" Represents averager settings of Elekta TRIUX/Vectorview systems.\n+    \"\"\"\n+\n+    # these are DACQ averager related variable names without preceding 'ERF'\n+    vars = ['magMax', 'magMin', 'magNoise', 'magSlope', 'magSpike', 'megMax',\n+            'megMin', 'megNoise', 'megSlope', 'megSpike', 'eegMax', 'eegMin',\n+            'eegNoise', 'eegSlope', 'eegSpike', 'eogMax', 'ecgMax', 'ncateg',\n+            'nevent', 'stimSource', 'triggerMap', 'update', 'version',\n+            'artefIgnore', 'averUpdate']\n+\n+    # DACQ variable names start with one of these\n+    acq_var_magic = ['ERF', 'DEF', 'ACQ', 'TCP']\n+\n+    def __init__(self, acq_pars):","path":"mne/event.py","position":110,"original_position":110,"commit_id":"d3fb8cf154e547750e096662394cce3d11e212f7","original_commit_id":"d3fb8cf154e547750e096662394cce3d11e212f7","user":{"login":"Eric89GXL","id":2365790,"avatar_url":"https://avatars.githubusercontent.com/u/2365790?v=3","gravatar_id":"","url":"https://api.github.com/users/Eric89GXL","html_url":"https://github.com/Eric89GXL","followers_url":"https://api.github.com/users/Eric89GXL/followers","following_url":"https://api.github.com/users/Eric89GXL/following{/other_user}","gists_url":"https://api.github.com/users/Eric89GXL/gists{/gist_id}","starred_url":"https://api.github.com/users/Eric89GXL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eric89GXL/subscriptions","organizations_url":"https://api.github.com/users/Eric89GXL/orgs","repos_url":"https://api.github.com/users/Eric89GXL/repos","events_url":"https://api.github.com/users/Eric89GXL/events{/privacy}","received_events_url":"https://api.github.com/users/Eric89GXL/received_events","type":"User","site_admin":false},"body":"`ElektaAverager(evoked.info)`","created_at":"2016-05-31T13:39:03Z","updated_at":"2016-05-31T13:39:03Z","html_url":"https://github.com/mne-tools/mne-python/pull/3205#discussion_r65182261","pull_request_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3205","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/65182261"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/3205#discussion_r65182261"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/3205"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3205","id":68703940,"html_url":"https://github.com/mne-tools/mne-python/pull/3205","diff_url":"https://github.com/mne-tools/mne-python/pull/3205.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/3205.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/3205","number":3205,"state":"open","locked":false,"title":"WIP: Elekta averager ","user":{"login":"jjnurminen","id":8491321,"avatar_url":"https://avatars.githubusercontent.com/u/8491321?v=3","gravatar_id":"","url":"https://api.github.com/users/jjnurminen","html_url":"https://github.com/jjnurminen","followers_url":"https://api.github.com/users/jjnurminen/followers","following_url":"https://api.github.com/users/jjnurminen/following{/other_user}","gists_url":"https://api.github.com/users/jjnurminen/gists{/gist_id}","starred_url":"https://api.github.com/users/jjnurminen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjnurminen/subscriptions","organizations_url":"https://api.github.com/users/jjnurminen/orgs","repos_url":"https://api.github.com/users/jjnurminen/repos","events_url":"https://api.github.com/users/jjnurminen/events{/privacy}","received_events_url":"https://api.github.com/users/jjnurminen/received_events","type":"User","site_admin":false},"body":"Discussed in #3097 \r\n\r\nSummary: Elekta/Neuromag DACQ (data acquisition) supports rather flexible event and \r\naveraging logic that is currently not implemented in mne-python. It also stores all averaging \r\nparameters in the fiff file, so raw data can be easily reaveraged in postprocessing.\r\nThe purpose of this PR is \r\n1) extract the relevant info from the fiff file \r\n2) implement support for averaging according to Elekta categories.\r\n\r\nImplementation: an Elekta_averager class that takes all the relevant info from \r\n`raw.info['acq_pars']`. Also classes for events and categories.\r\n\r\nAPI methods:\r\n\r\nget_epochs() gives mne.Epochs corresponding to a given DACQ category. \r\n\r\nrejection_dict() translates DACQ params to a reject dict that can be used with mne.Epochs\r\n\r\nTechnical details: DACQ supports defining 32 different events which correspond to trigger \r\ntransitions. Events support pre- and post-transition bit masking. Based on the events, 32 averaging categories can be defined. Each category defines a reference event that is the zero-time point for collecting the corresponding epochs. Epoch length is defined by the start and end times (given relative to the reference event). A conditional ('required') event is also supported; if defined, it must appear in a specified time window (before or after the reference event) for the epoch to be valid.\r\n\r\nTODO:\r\n\r\n- examples\r\n- unit test\r\n- support for DACQ < 3.4?\r\n","created_at":"2016-05-03T13:18:42Z","updated_at":"2016-05-31T13:39:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d19f6e208bcf91938a1cfd1b50b77815b5dfcaa9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3205/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3205/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/3205/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/d3fb8cf154e547750e096662394cce3d11e212f7","head":{"label":"jjnurminen:elekta_avg","ref":"elekta_avg","sha":"d3fb8cf154e547750e096662394cce3d11e212f7","user":{"login":"jjnurminen","id":8491321,"avatar_url":"https://avatars.githubusercontent.com/u/8491321?v=3","gravatar_id":"","url":"https://api.github.com/users/jjnurminen","html_url":"https://github.com/jjnurminen","followers_url":"https://api.github.com/users/jjnurminen/followers","following_url":"https://api.github.com/users/jjnurminen/following{/other_user}","gists_url":"https://api.github.com/users/jjnurminen/gists{/gist_id}","starred_url":"https://api.github.com/users/jjnurminen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjnurminen/subscriptions","organizations_url":"https://api.github.com/users/jjnurminen/orgs","repos_url":"https://api.github.com/users/jjnurminen/repos","events_url":"https://api.github.com/users/jjnurminen/events{/privacy}","received_events_url":"https://api.github.com/users/jjnurminen/received_events","type":"User","site_admin":false},"repo":{"id":55834470,"name":"mne-python","full_name":"jjnurminen/mne-python","owner":{"login":"jjnurminen","id":8491321,"avatar_url":"https://avatars.githubusercontent.com/u/8491321?v=3","gravatar_id":"","url":"https://api.github.com/users/jjnurminen","html_url":"https://github.com/jjnurminen","followers_url":"https://api.github.com/users/jjnurminen/followers","following_url":"https://api.github.com/users/jjnurminen/following{/other_user}","gists_url":"https://api.github.com/users/jjnurminen/gists{/gist_id}","starred_url":"https://api.github.com/users/jjnurminen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjnurminen/subscriptions","organizations_url":"https://api.github.com/users/jjnurminen/orgs","repos_url":"https://api.github.com/users/jjnurminen/repos","events_url":"https://api.github.com/users/jjnurminen/events{/privacy}","received_events_url":"https://api.github.com/users/jjnurminen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jjnurminen/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":true,"url":"https://api.github.com/repos/jjnurminen/mne-python","forks_url":"https://api.github.com/repos/jjnurminen/mne-python/forks","keys_url":"https://api.github.com/repos/jjnurminen/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jjnurminen/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jjnurminen/mne-python/teams","hooks_url":"https://api.github.com/repos/jjnurminen/mne-python/hooks","issue_events_url":"https://api.github.com/repos/jjnurminen/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/jjnurminen/mne-python/events","assignees_url":"https://api.github.com/repos/jjnurminen/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/jjnurminen/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/jjnurminen/mne-python/tags","blobs_url":"https://api.github.com/repos/jjnurminen/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jjnurminen/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jjnurminen/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/jjnurminen/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jjnurminen/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/jjnurminen/mne-python/languages","stargazers_url":"https://api.github.com/repos/jjnurminen/mne-python/stargazers","contributors_url":"https://api.github.com/repos/jjnurminen/mne-python/contributors","subscribers_url":"https://api.github.com/repos/jjnurminen/mne-python/subscribers","subscription_url":"https://api.github.com/repos/jjnurminen/mne-python/subscription","commits_url":"https://api.github.com/repos/jjnurminen/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/jjnurminen/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/jjnurminen/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/jjnurminen/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/jjnurminen/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/jjnurminen/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jjnurminen/mne-python/merges","archive_url":"https://api.github.com/repos/jjnurminen/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jjnurminen/mne-python/downloads","issues_url":"https://api.github.com/repos/jjnurminen/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/jjnurminen/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/jjnurminen/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/jjnurminen/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jjnurminen/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/jjnurminen/mne-python/releases{/id}","deployments_url":"https://api.github.com/repos/jjnurminen/mne-python/deployments","created_at":"2016-04-09T08:48:30Z","updated_at":"2016-04-09T08:48:34Z","pushed_at":"2016-05-30T14:58:10Z","git_url":"git://github.com/jjnurminen/mne-python.git","ssh_url":"git@github.com:jjnurminen/mne-python.git","clone_url":"https://github.com/jjnurminen/mne-python.git","svn_url":"https://github.com/jjnurminen/mne-python","homepage":"http://martinos.org/mne/","size":85879,"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":"f932004db951abaf7d0522f961ca9a3be6e72167","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-05-29T00:38:38Z","pushed_at":"2016-05-31T12:14:34Z","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":177940,"stargazers_count":202,"watchers_count":202,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":190,"mirror_url":null,"open_issues_count":193,"forks":190,"open_issues":193,"watchers":202,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/3205"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/3205"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/3205"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/3205/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/3205/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/3205/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-python/statuses/d3fb8cf154e547750e096662394cce3d11e212f7"}}}}
{"actor":{"display_login":"Eric89GXL"}}