{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/83510144","pull_request_review_id":4352643,"id":83510144,"diff_hunk":"@@ -0,0 +1,112 @@\n+# -*- coding: utf-8 -*-\n+# Authors: Samu Taulu <staulu@uw.edu>\n+#          Eric Larson <larson.eric.d@gmail.com>\n+\n+# License: BSD (3-clause)\n+\n+import numpy as np\n+from scipy import linalg\n+\n+from ..cov import _check_scalings_user, _apply_scaling_array\n+from ..io.pick import pick_info, _picks_by_type, _pick_data_channels\n+from ..utils import logger, verbose\n+\n+\n+@verbose\n+def oversampled_temporal_projection(raw, duration=10., scalings=None,\n+                                    verbose=None):\n+    \"\"\"Denoise MEG channels using oversampled temporal projection\n+\n+    This algorithm uses a leave-one-out procedure with parallel\n+    temporal projection to remove individual sensor noise under the\n+    assumption that sampled fields (e.g., MEG and EEG) are oversampled\n+    by the sensor array [1]_.\n+\n+    .. note:: Bad channels are not used or modified by this procedure.\n+\n+    Parameters\n+    ----------\n+    raw : instance of Raw\n+        Raw data to denoise.\n+    duration : float\n+        The window duration (in seconds) to use (default: 10.).\n+    scalings : dict | None\n+        If None (default), use ``dict(mag=1e15, grad=1e13, eeg=1e6)``.\n+        These defaults will scale different channel types to approximately\n+        at the same unit.\n+    verbose : bool, str, int, or None\n+        If not None, override default verbose level (see mne.verbose)\n+\n+    Returns\n+    -------\n+    raw_clean : instance of Raw\n+        The cleaned data.\n+\n+    Notes\n+    -----\n+    This algorithm is computationally expensive, and can be several times\n+    slower than realtime for conventional M/EEG datasets.\n+\n+    This algorithm is covered by a provisional patent.\n+\n+    .. versionadded:: 0.14\n+\n+    References\n+    ----------\n+    .. [1] Taulu, S and Larson E (2016). \"Reducing noise in\n+           electromagnetic sensor arrays using oversampled temporal\n+           projection\", presented at the 2016 International Conference\n+           on Biomagnetism, Seoul, Korea 3 Oct 2016.\n+    \"\"\"\n+    # XXX eventually offer option to treat \"bads\" by projecting them onto\n+    # others, but not use them in bases for others?\n+    logger.info('Processing MEG data using oversampled temporal projection')\n+    scalings = _check_scalings_user(scalings)\n+    n_samp = int(round(float(duration) * raw.info['sfreq']))\n+    del duration\n+    if n_samp / raw.info['sfreq'] > raw.times[-1]:\n+        raise ValueError('Effective duration (%s) must be at most the '\n+                         'duration of the raw instance (%s)'\n+                         % (n_samp / raw.info['sfreq'], raw.times[-1]))\n+    raw = raw.copy().load_data()\n+    picks = list(_pick_data_channels(raw.info, exclude='bads'))\n+    read_lims = np.arange(0, len(raw.times) + 1, n_samp)  # include endpt\n+    if read_lims[-1] - read_lims[-2] != n_samp:\n+        read_lims[-1] = len(raw.times)\n+    min_samp = np.diff(read_lims).min()\n+    if (min_samp <= len(picks)).any():\n+        raise ValueError('duration (%s) yielded %s samples, which is fewer '\n+                         'than the number of channels (%s)'\n+                         % (n_samp / raw.info['sfreq'], min_samp, len(picks)))\n+    pl = 's' if len(read_lims) != 2 else ''\n+    logger.info('    Processing %s data chunk%s of (at least) %0.1f sec'\n+                % (len(read_lims) - 1, pl, n_samp / raw.info['sfreq']))\n+    apply_picks_list = _picks_by_type(pick_info(raw.info, picks))\n+    for start, stop in zip(read_lims[:-1], read_lims[1:]):\n+        logger.info('    Denoising % 8.2f - % 8.2f sec'\n+                    % tuple(raw.times[[start, stop - 1]]))\n+        data_full = raw._data[:, start:stop]  # view (for correct operation)\n+        data_picked = data_full[picks]  # not a view (for correct operation)\n+        if not np.isfinite(data_picked).all():\n+            raise RuntimeError('non-finite data (inf or nan) found in raw '\n+                               'instance')","path":"mne/preprocessing/otp.py","position":92,"original_position":92,"commit_id":"7f55d9cdc7772774a009430cfaaf580dbb0784bb","original_commit_id":"7f55d9cdc7772774a009430cfaaf580dbb0784bb","user":{"login":"kingjr","id":4881164,"avatar_url":"https://avatars.githubusercontent.com/u/4881164?v=3","gravatar_id":"","url":"https://api.github.com/users/kingjr","html_url":"https://github.com/kingjr","followers_url":"https://api.github.com/users/kingjr/followers","following_url":"https://api.github.com/users/kingjr/following{/other_user}","gists_url":"https://api.github.com/users/kingjr/gists{/gist_id}","starred_url":"https://api.github.com/users/kingjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingjr/subscriptions","organizations_url":"https://api.github.com/users/kingjr/orgs","repos_url":"https://api.github.com/users/kingjr/repos","events_url":"https://api.github.com/users/kingjr/events{/privacy}","received_events_url":"https://api.github.com/users/kingjr/received_events","type":"User","site_admin":false},"body":"this should be checked earlier, so that we don't need to start running the algorithm before we hit the error","created_at":"2016-10-14T22:10:00Z","updated_at":"2016-10-14T22:25:06Z","html_url":"https://github.com/mne-tools/mne-python/pull/3640#discussion_r83510144","pull_request_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3640","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/83510144"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/3640#discussion_r83510144"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/3640"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3640","id":88036035,"html_url":"https://github.com/mne-tools/mne-python/pull/3640","diff_url":"https://github.com/mne-tools/mne-python/pull/3640.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/3640.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/3640","number":3640,"state":"open","locked":false,"title":"WIP: Add oversampled temporal projection","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":"New sensor noise suppression algorithm. It should be usable if people want to test it. Proper peer-reviewed publication is still WIP :)","created_at":"2016-10-05T08:35:07Z","updated_at":"2016-10-14T22:25:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5731e0f617db8174e4965353982423bcec0660aa","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3640/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/3640/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/3640/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/7f55d9cdc7772774a009430cfaaf580dbb0784bb","head":{"label":"Eric89GXL:otp","ref":"otp","sha":"7f55d9cdc7772774a009430cfaaf580dbb0784bb","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":5848067,"name":"mne-python","full_name":"Eric89GXL/mne-python","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/mne-python","description":"MNE scripting with Python","fork":true,"url":"https://api.github.com/repos/Eric89GXL/mne-python","forks_url":"https://api.github.com/repos/Eric89GXL/mne-python/forks","keys_url":"https://api.github.com/repos/Eric89GXL/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Eric89GXL/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Eric89GXL/mne-python/teams","hooks_url":"https://api.github.com/repos/Eric89GXL/mne-python/hooks","issue_events_url":"https://api.github.com/repos/Eric89GXL/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/Eric89GXL/mne-python/events","assignees_url":"https://api.github.com/repos/Eric89GXL/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/Eric89GXL/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/Eric89GXL/mne-python/tags","blobs_url":"https://api.github.com/repos/Eric89GXL/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Eric89GXL/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Eric89GXL/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/Eric89GXL/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Eric89GXL/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/Eric89GXL/mne-python/languages","stargazers_url":"https://api.github.com/repos/Eric89GXL/mne-python/stargazers","contributors_url":"https://api.github.com/repos/Eric89GXL/mne-python/contributors","subscribers_url":"https://api.github.com/repos/Eric89GXL/mne-python/subscribers","subscription_url":"https://api.github.com/repos/Eric89GXL/mne-python/subscription","commits_url":"https://api.github.com/repos/Eric89GXL/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/Eric89GXL/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/Eric89GXL/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/Eric89GXL/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/Eric89GXL/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/Eric89GXL/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Eric89GXL/mne-python/merges","archive_url":"https://api.github.com/repos/Eric89GXL/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Eric89GXL/mne-python/downloads","issues_url":"https://api.github.com/repos/Eric89GXL/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/Eric89GXL/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/Eric89GXL/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/Eric89GXL/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Eric89GXL/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/Eric89GXL/mne-python/releases{/id}","deployments_url":"https://api.github.com/repos/Eric89GXL/mne-python/deployments","created_at":"2012-09-17T22:08:11Z","updated_at":"2015-05-07T15:05:01Z","pushed_at":"2016-10-13T19:57:42Z","git_url":"git://github.com/Eric89GXL/mne-python.git","ssh_url":"git@github.com:Eric89GXL/mne-python.git","clone_url":"https://github.com/Eric89GXL/mne-python.git","svn_url":"https://github.com/Eric89GXL/mne-python","homepage":"http://martinos.org/mne/","size":89760,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"mne-tools:master","ref":"master","sha":"4b6a1744e8be9e8ff6e1e238953f5b6667062673","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-10-12T03:12:51Z","pushed_at":"2016-10-14T17:41:55Z","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":182435,"stargazers_count":233,"watchers_count":233,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":222,"mirror_url":null,"open_issues_count":198,"forks":222,"open_issues":198,"watchers":233,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/3640"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/3640"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/3640"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/3640/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/3640/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/3640/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-python/statuses/7f55d9cdc7772774a009430cfaaf580dbb0784bb"}}}}
{"actor":{"display_login":"kingjr"}}