{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/53436246","id":53436246,"diff_hunk":"@@ -791,43 +791,78 @@ def make_sphere_model(r0=(0., 0., 0.04), head_radius=0.09, info=None,\n # #############################################################################\n # Helpers\n \n+_dig_kind_dict = {\n+    'cardinal': FIFF.FIFFV_POINT_CARDINAL,\n+    'hpi': FIFF.FIFFV_POINT_HPI,\n+    'eeg': FIFF.FIFFV_POINT_EEG,\n+    'extra': FIFF.FIFFV_POINT_EXTRA,\n+}\n+_dig_kind_rev = dict((val, key) for key, val in _dig_kind_dict.items())\n+_dig_kind_ints = tuple(_dig_kind_dict.values())\n+\n+\n @verbose\n-def fit_sphere_to_headshape(info, dig_kinds=(FIFF.FIFFV_POINT_EXTRA,),\n-                            verbose=None):\n+def fit_sphere_to_headshape(info, dig_kinds='auto', units=None, verbose=None):\n     \"\"\"Fit a sphere to the headshape points to determine head center\n \n     Parameters\n     ----------\n     info : instance of mne.io.meas_info.Info\n         Measurement info.\n-    dig_kinds : tuple of int\n-        Kind of digitization points to use in the fitting. These can be\n-        any kind defined in io.constants.FIFF::\n+    dig_kinds : list of str | str\n+        Kind of digitization points to use in the fitting. These can be any\n+        combination of ('cardinal', 'hpi', 'eeg', 'extra'). Can also\n+        be 'auto' (default), which will use only the 'extra' points if\n+        enough are available, and if not, uses 'extra' and 'eeg' points.\n+    units : str\n+        Can be \"m\" or \"mm\". The default in 0.12 is \"mm\" but will be changed\n+        to \"m\" in 0.13.\n \n-            FIFFV_POINT_CARDINAL\n-            FIFFV_POINT_HPI\n-            FIFFV_POINT_EEG\n-            FIFFV_POINT_EXTRA\n+        .. versionadded:: 0.12\n \n-        Defaults to (FIFFV_POINT_EXTRA,).\n     verbose : bool, str, int, or None\n         If not None, override default verbose level (see mne.verbose).\n \n     Returns\n     -------\n     radius : float\n-        Sphere radius in mm.\n+        Sphere radius.\n     origin_head: ndarray, shape (3,)\n-        Head center in head coordinates (mm).\n+        Head center in head coordinates.\n     origin_device: ndarray, shape (3,)\n-        Head center in device coordinates (mm).\n+        Head center in device coordinates.\n \n     Notes\n     -----\n     This function excludes any points that are low and frontal\n     (``z < 0 and y > 0``) to improve the fit.\n     \"\"\"\n-    # get head digization points of the specified kind\n+    if units is None:\n+        warn('Please explicitly set the units. In 0.12 units=\"mm\" will '\n+             'be used, but this will change to units=\"m\" in 0.13.',\n+             DeprecationWarning)\n+        units = 'mm'\n+    if not isinstance(units, string_types) or units not in ('m', 'mm'):\n+        raise ValueError('units must be a \"m\" or \"mm\"')\n+    if isinstance(dig_kinds, string_types):\n+        if dig_kinds == 'auto':\n+            # try \"extra\" first\n+            try:\n+                return fit_sphere_to_headshape(info, 'extra', units=units)\n+            except ValueError:\n+                pass\n+            return fit_sphere_to_headshape(info, ('extra', 'eeg'), units=units)\n+        else:\n+            dig_kinds = (dig_kinds,)\n+    # convert string args to ints\n+    dig_kinds = list(dig_kinds)","path":"mne/bem.py","position":97,"original_position":97,"commit_id":"6be43a8fded7a0cd462252e8e579c685b33ffe85","original_commit_id":"6be43a8fded7a0cd462252e8e579c685b33ffe85","user":{"login":"jaeilepp","id":3456414,"avatar_url":"https://avatars.githubusercontent.com/u/3456414?v=3","gravatar_id":"","url":"https://api.github.com/users/jaeilepp","html_url":"https://github.com/jaeilepp","followers_url":"https://api.github.com/users/jaeilepp/followers","following_url":"https://api.github.com/users/jaeilepp/following{/other_user}","gists_url":"https://api.github.com/users/jaeilepp/gists{/gist_id}","starred_url":"https://api.github.com/users/jaeilepp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaeilepp/subscriptions","organizations_url":"https://api.github.com/users/jaeilepp/orgs","repos_url":"https://api.github.com/users/jaeilepp/repos","events_url":"https://api.github.com/users/jaeilepp/events{/privacy}","received_events_url":"https://api.github.com/users/jaeilepp/received_events","type":"User","site_admin":false},"body":"Is this needed? Shouldn't this already be a list, if you change L856 to ``[dig_kinds]``?","created_at":"2016-02-19T08:59:28Z","updated_at":"2016-02-19T08:59:28Z","html_url":"https://github.com/mne-tools/mne-python/pull/2910#discussion_r53436246","pull_request_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2910","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/53436246"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2910#discussion_r53436246"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2910"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2910","id":59814851,"html_url":"https://github.com/mne-tools/mne-python/pull/2910","diff_url":"https://github.com/mne-tools/mne-python/pull/2910.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/2910.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2910","number":2910,"state":"open","locked":false,"title":"MRG: Allow fitting \"auto\" mode and units","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":"Ready for review/merge from my end @dengemann.","created_at":"2016-02-18T15:28:53Z","updated_at":"2016-02-19T08:59:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0bb93adf357321f202c36c7cce73a82c50bf310a","assignee":null,"milestone":{"url":"https://api.github.com/repos/mne-tools/mne-python/milestones/8","html_url":"https://github.com/mne-tools/mne-python/milestones/0.12","labels_url":"https://api.github.com/repos/mne-tools/mne-python/milestones/8/labels","id":1429321,"number":8,"title":"0.12","description":"","creator":{"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},"open_issues":35,"closed_issues":42,"state":"open","created_at":"2015-11-25T13:36:18Z","updated_at":"2016-02-19T02:16:32Z","due_on":"2016-04-29T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2910/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2910/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/2910/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/6be43a8fded7a0cd462252e8e579c685b33ffe85","head":{"label":"Eric89GXL:better-fitting","ref":"better-fitting","sha":"6be43a8fded7a0cd462252e8e579c685b33ffe85","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-02-19T02:16:33Z","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":81248,"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":"9f749ebaf41f9e1a3a6082e5cbf0f7bc3a30ede8","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-16T10:56:53Z","pushed_at":"2016-02-19T02:16:32Z","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":170760,"stargazers_count":178,"watchers_count":178,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":164,"mirror_url":null,"open_issues_count":190,"forks":164,"open_issues":190,"watchers":178,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2910"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2910"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2910"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2910/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2910/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/2910/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-python/statuses/6be43a8fded7a0cd462252e8e579c685b33ffe85"}}}}