{"action":"created","comment":{"url":"https://api.github.com/repos/scitran/data/pulls/comments/37453863","id":37453863,"diff_hunk":"@@ -0,0 +1,190 @@\n+\"\"\"\n+scitran.data.meeg\n+=================\n+\n+Data format for M/EEG data using mne-python.\n+\n+\"\"\"\n+\n+import logging\n+import tempfile\n+import zipfile\n+import json\n+import warnings\n+import os\n+from os import path as op\n+import shutil\n+\n+from mne.io import read_raw_fif\n+\n+from .. import data, util\n+\n+log = logging.getLogger(__name__)  # root logger already configured\n+\n+# see data.py for expected project properties\n+project_properties = data.project_properties\n+\n+_session_properties = {  # add additional session properties\n+    'subject': {\n+        'type': 'object',\n+        'properties': {\n+            'firstname': {\n+                'field': 'subj_firstname',\n+                'title': 'First Name',\n+                'type': 'string',\n+            },\n+            'lastname': {\n+                'field': 'subj_lastname',\n+                'title': 'Last Name',\n+                'type': 'string',\n+            },\n+            'dob': {\n+                'field': 'subj_dob',\n+                'title': 'Date of Birth',\n+                'type': 'string',\n+                'format': 'date',\n+            },\n+        },\n+    },\n+}\n+session_properties = data.dict_merge(data.session_properties,\n+                                     _session_properties)\n+\n+_acquisition_properties = {  # add custom acquisition properties\n+}\n+acquisition_properties = data.dict_merge(data.acquisition_properties,\n+                                         _acquisition_properties)\n+\n+\n+class MEEGError(data.DataError):\n+    pass\n+\n+\n+class MEEGReader(data.Reader):\n+\n+    \"\"\"\n+    Parameters\n+    ----------\n+    path : str\n+        Path to input file.\n+    load_data : boolean\n+        Indicate if a reader should attempt to immediately load all data.\n+        Default False.\n+    \"\"\"\n+    project_properties = project_properties\n+    session_properties = session_properties\n+    acquisition_properties = acquisition_properties\n+\n+    domain = u'meeg'\n+    filetype = u'meeg'\n+    state = ['orig']\n+\n+    def __init__(self, path, load_data=False, timezone=None):\n+        super(MEEGReader, self).__init__(path, load_data, timezone)\n+        self._temp_dir = tempfile.mkdtemp()\n+        os.mkdir(op.join(self._temp_dir, 'reap'))\n+        try:\n+            with zipfile.ZipFile(self.filepath, 'r') as zip_file:\n+                hdr = json.loads(zip_file.comment,\n+                                 object_hook=util.datetime_decoder)['header']\n+                self.project_name = hdr['project']\n+                zip_fnames = [op.join('reap', op.basename(fname))\n+                              for fname in zip_file.namelist()]\n+                fnames = []\n+                for fname in zip_fnames:\n+                    if fname.endswith('.fif'):\n+                        fnames.append(zip_file.extract(fname, self._temp_dir))\n+                # load raw files\n+                with warnings.catch_warnings(record=True):\n+                    self._raws = [read_raw_fif(fname, allow_maxshield=True,\n+                                               preload=load_data)\n+                                  for fname in fnames]\n+        except Exception as e:\n+            raise MEEGError(e)\n+\n+    def __del__(self):\n+        shutil.rmtree(self._temp_dir)\n+\n+    def load_data(self):\n+        super(MEEGReader, self).load_data()\n+        for raw in self._raws:\n+            raw.preload_data()\n+\n+    @property\n+    def nims_project(self):\n+        return self.project_name\n+\n+    @property\n+    def nims_group_id(self):\n+        # XXX\n+        return 'group_id'\n+\n+    @property\n+    def nims_session_id(self):\n+        # XXX\n+        return 'session_id'\n+\n+    @property\n+    def nims_session_label(self):\n+        # XXX\n+        return 'session_label'\n+\n+    @property\n+    def nims_session_subject(self):\n+        # XXX\n+        return 'subj_code'\n+\n+    @property\n+    def nims_acquisition_label(self):\n+        # XXX\n+        return 'series_no'\n+\n+    @property\n+    def nims_acquisition_description(self):\n+        # XXX get from info\n+        return 'foobar'\n+\n+    @property\n+    def nims_file_name(self):\n+        # XXX what are the constraints on this?\n+        return 'foo'\n+\n+    @property\n+    def nims_file_kinds(self):\n+        # XXX\n+        return ['FIF']\n+\n+    @property\n+    def nims_acquisition_id(self):\n+        # XXX\n+        return 'nims_acquisition_id'\n+\n+    # XXX why are these not implemented at the data.Reader level?","path":"scitran/data/meeg/meeg.py","position":162,"original_position":162,"commit_id":"1884ebbdfb7827e01169bb5448207fdc5be969a7","original_commit_id":"1884ebbdfb7827e01169bb5448207fdc5be969a7","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":"@gsfr any reason not to have the following as part of the super `reader.Reader` class? It would make the code more DRY to have these as defaults in that class. But if you want `Reader` to be an ABC I guess it makes sense.","created_at":"2015-08-19T19:00:06Z","updated_at":"2015-08-19T19:00:06Z","html_url":"https://github.com/scitran/data/pull/27#discussion_r37453863","pull_request_url":"https://api.github.com/repos/scitran/data/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/scitran/data/pulls/comments/37453863"},"html":{"href":"https://github.com/scitran/data/pull/27#discussion_r37453863"},"pull_request":{"href":"https://api.github.com/repos/scitran/data/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/scitran/data/pulls/27","id":42755128,"html_url":"https://github.com/scitran/data/pull/27","diff_url":"https://github.com/scitran/data/pull/27.diff","patch_url":"https://github.com/scitran/data/pull/27.patch","issue_url":"https://api.github.com/repos/scitran/data/issues/27","number":27,"state":"open","locked":false,"title":"WIP: MEEG data","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":"Currently in the state that it will store the data in `persistent/data/` when used with https://github.com/scitran/reaper/pull/12 and https://github.com/scitran/scitran/pull/57.\r\n\r\nCloses #4.","created_at":"2015-08-18T22:09:21Z","updated_at":"2015-08-19T19:00:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cec2c03c33438167af06ff013e1211fef76dd568","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scitran/data/pulls/27/commits","review_comments_url":"https://api.github.com/repos/scitran/data/pulls/27/comments","review_comment_url":"https://api.github.com/repos/scitran/data/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scitran/data/issues/27/comments","statuses_url":"https://api.github.com/repos/scitran/data/statuses/1884ebbdfb7827e01169bb5448207fdc5be969a7","head":{"label":"Eric89GXL:meeg","ref":"meeg","sha":"1884ebbdfb7827e01169bb5448207fdc5be969a7","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},"repo":{"id":32597777,"name":"data","full_name":"Eric89GXL/data","owner":{"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},"private":false,"html_url":"https://github.com/Eric89GXL/data","description":"Data Readers and Writers","fork":true,"url":"https://api.github.com/repos/Eric89GXL/data","forks_url":"https://api.github.com/repos/Eric89GXL/data/forks","keys_url":"https://api.github.com/repos/Eric89GXL/data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Eric89GXL/data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Eric89GXL/data/teams","hooks_url":"https://api.github.com/repos/Eric89GXL/data/hooks","issue_events_url":"https://api.github.com/repos/Eric89GXL/data/issues/events{/number}","events_url":"https://api.github.com/repos/Eric89GXL/data/events","assignees_url":"https://api.github.com/repos/Eric89GXL/data/assignees{/user}","branches_url":"https://api.github.com/repos/Eric89GXL/data/branches{/branch}","tags_url":"https://api.github.com/repos/Eric89GXL/data/tags","blobs_url":"https://api.github.com/repos/Eric89GXL/data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Eric89GXL/data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Eric89GXL/data/git/refs{/sha}","trees_url":"https://api.github.com/repos/Eric89GXL/data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Eric89GXL/data/statuses/{sha}","languages_url":"https://api.github.com/repos/Eric89GXL/data/languages","stargazers_url":"https://api.github.com/repos/Eric89GXL/data/stargazers","contributors_url":"https://api.github.com/repos/Eric89GXL/data/contributors","subscribers_url":"https://api.github.com/repos/Eric89GXL/data/subscribers","subscription_url":"https://api.github.com/repos/Eric89GXL/data/subscription","commits_url":"https://api.github.com/repos/Eric89GXL/data/commits{/sha}","git_commits_url":"https://api.github.com/repos/Eric89GXL/data/git/commits{/sha}","comments_url":"https://api.github.com/repos/Eric89GXL/data/comments{/number}","issue_comment_url":"https://api.github.com/repos/Eric89GXL/data/issues/comments{/number}","contents_url":"https://api.github.com/repos/Eric89GXL/data/contents/{+path}","compare_url":"https://api.github.com/repos/Eric89GXL/data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Eric89GXL/data/merges","archive_url":"https://api.github.com/repos/Eric89GXL/data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Eric89GXL/data/downloads","issues_url":"https://api.github.com/repos/Eric89GXL/data/issues{/number}","pulls_url":"https://api.github.com/repos/Eric89GXL/data/pulls{/number}","milestones_url":"https://api.github.com/repos/Eric89GXL/data/milestones{/number}","notifications_url":"https://api.github.com/repos/Eric89GXL/data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Eric89GXL/data/labels{/name}","releases_url":"https://api.github.com/repos/Eric89GXL/data/releases{/id}","created_at":"2015-03-20T17:34:46Z","updated_at":"2015-03-20T17:34:47Z","pushed_at":"2015-08-19T18:56:09Z","git_url":"git://github.com/Eric89GXL/data.git","ssh_url":"git@github.com:Eric89GXL/data.git","clone_url":"https://github.com/Eric89GXL/data.git","svn_url":"https://github.com/Eric89GXL/data","homepage":"","size":506,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"scitran:zip_parse","ref":"zip_parse","sha":"3db375057851f0063f6d1a434b3b4205f07a0fa2","user":{"login":"scitran","id":7379762,"avatar_url":"https://avatars.githubusercontent.com/u/7379762?v=3","gravatar_id":"","url":"https://api.github.com/users/scitran","html_url":"https://github.com/scitran","followers_url":"https://api.github.com/users/scitran/followers","following_url":"https://api.github.com/users/scitran/following{/other_user}","gists_url":"https://api.github.com/users/scitran/gists{/gist_id}","starred_url":"https://api.github.com/users/scitran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scitran/subscriptions","organizations_url":"https://api.github.com/users/scitran/orgs","repos_url":"https://api.github.com/users/scitran/repos","events_url":"https://api.github.com/users/scitran/events{/privacy}","received_events_url":"https://api.github.com/users/scitran/received_events","type":"Organization","site_admin":false},"repo":{"id":16557964,"name":"data","full_name":"scitran/data","owner":{"login":"scitran","id":7379762,"avatar_url":"https://avatars.githubusercontent.com/u/7379762?v=3","gravatar_id":"","url":"https://api.github.com/users/scitran","html_url":"https://github.com/scitran","followers_url":"https://api.github.com/users/scitran/followers","following_url":"https://api.github.com/users/scitran/following{/other_user}","gists_url":"https://api.github.com/users/scitran/gists{/gist_id}","starred_url":"https://api.github.com/users/scitran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scitran/subscriptions","organizations_url":"https://api.github.com/users/scitran/orgs","repos_url":"https://api.github.com/users/scitran/repos","events_url":"https://api.github.com/users/scitran/events{/privacy}","received_events_url":"https://api.github.com/users/scitran/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scitran/data","description":"Data Readers and Writers","fork":false,"url":"https://api.github.com/repos/scitran/data","forks_url":"https://api.github.com/repos/scitran/data/forks","keys_url":"https://api.github.com/repos/scitran/data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scitran/data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scitran/data/teams","hooks_url":"https://api.github.com/repos/scitran/data/hooks","issue_events_url":"https://api.github.com/repos/scitran/data/issues/events{/number}","events_url":"https://api.github.com/repos/scitran/data/events","assignees_url":"https://api.github.com/repos/scitran/data/assignees{/user}","branches_url":"https://api.github.com/repos/scitran/data/branches{/branch}","tags_url":"https://api.github.com/repos/scitran/data/tags","blobs_url":"https://api.github.com/repos/scitran/data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scitran/data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scitran/data/git/refs{/sha}","trees_url":"https://api.github.com/repos/scitran/data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scitran/data/statuses/{sha}","languages_url":"https://api.github.com/repos/scitran/data/languages","stargazers_url":"https://api.github.com/repos/scitran/data/stargazers","contributors_url":"https://api.github.com/repos/scitran/data/contributors","subscribers_url":"https://api.github.com/repos/scitran/data/subscribers","subscription_url":"https://api.github.com/repos/scitran/data/subscription","commits_url":"https://api.github.com/repos/scitran/data/commits{/sha}","git_commits_url":"https://api.github.com/repos/scitran/data/git/commits{/sha}","comments_url":"https://api.github.com/repos/scitran/data/comments{/number}","issue_comment_url":"https://api.github.com/repos/scitran/data/issues/comments{/number}","contents_url":"https://api.github.com/repos/scitran/data/contents/{+path}","compare_url":"https://api.github.com/repos/scitran/data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scitran/data/merges","archive_url":"https://api.github.com/repos/scitran/data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scitran/data/downloads","issues_url":"https://api.github.com/repos/scitran/data/issues{/number}","pulls_url":"https://api.github.com/repos/scitran/data/pulls{/number}","milestones_url":"https://api.github.com/repos/scitran/data/milestones{/number}","notifications_url":"https://api.github.com/repos/scitran/data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scitran/data/labels{/name}","releases_url":"https://api.github.com/repos/scitran/data/releases{/id}","created_at":"2014-02-05T20:53:19Z","updated_at":"2015-04-22T23:02:31Z","pushed_at":"2015-08-19T18:56:10Z","git_url":"git://github.com/scitran/data.git","ssh_url":"git@github.com:scitran/data.git","clone_url":"https://github.com/scitran/data.git","svn_url":"https://github.com/scitran/data","homepage":"","size":1988,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":8,"forks":7,"open_issues":8,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scitran/data/pulls/27"},"html":{"href":"https://github.com/scitran/data/pull/27"},"issue":{"href":"https://api.github.com/repos/scitran/data/issues/27"},"comments":{"href":"https://api.github.com/repos/scitran/data/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/scitran/data/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/scitran/data/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scitran/data/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/scitran/data/statuses/1884ebbdfb7827e01169bb5448207fdc5be969a7"}}}}