{"action":"created","comment":{"url":"https://api.github.com/repos/nipy/dipy/pulls/comments/49187080","id":49187080,"diff_hunk":"@@ -323,3 +327,117 @@ def orient_by_rois(streamlines, roi1, roi2, affine=None, copy=True):\n             new_sl[idx] = sl[::-1]\n \n     return new_sl\n+\n+\n+def _extract_vals(data, streamlines, affine=None, threedvec=False):\n+    \"\"\"\n+    Helper function for use with `values_from_volume`.\n+\n+    Parameters\n+    ----------\n+    data : 3D or 4D array\n+        Scalar (for 3D) and vector (for 4D) values to be extracted. For 4D\n+        data, interpolation will be done on the 3 spatial dimensions in each\n+        volume.\n+\n+    streamlines : ndarray or list\n+        If array, of shape (n_streamlines, n_nodes, 3)\n+        If list, len(n_streamlines) with (n_nodes, 3) array in\n+        each element of the list.\n+\n+    affine : ndarray, shape (4, 4)\n+        Affine transformation from voxels (image coordinates) to streamlines.\n+        Default: identity.\n+\n+    threedvec : bool\n+        Whether the last dimension has length 3. This is a special case in\n+        which we can use :func:`vfu.interpolate_vector_3d` for the\n+        interploation of 4D volumes without looping over the elements of the\n+        last dimension.\n+\n+    Return\n+    ------\n+    array or list (depending on the input) : values interpolate to each\n+        coordinate along the length of each streamline\n+    \"\"\"\n+    data = data.astype(np.float)\n+    if affine is not None:\n+        streamlines = ut.move_streamlines(streamlines,\n+                                          np.linalg.inv(affine))\n+\n+    if (isinstance(streamlines, list) or\n+            isinstance(streamlines, types.GeneratorType)):\n+        vals = []\n+        for sl in streamlines:\n+            if threedvec:\n+                vals.append(list(vfu.interpolate_vector_3d(data, sl)[0]))\n+            else:\n+                vals.append(list(vfu.interpolate_scalar_3d(data, sl)[0]))\n+\n+    elif isinstance(streamlines, np.ndarray):","path":"dipy/tracking/streamline.py","position":73,"original_position":73,"commit_id":"d13be258edb60bb377e585f9013008c59f8dff0e","original_commit_id":"d13be258edb60bb377e585f9013008c59f8dff0e","user":{"login":"samuelstjean","id":3030760,"avatar_url":"https://avatars.githubusercontent.com/u/3030760?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelstjean","html_url":"https://github.com/samuelstjean","followers_url":"https://api.github.com/users/samuelstjean/followers","following_url":"https://api.github.com/users/samuelstjean/following{/other_user}","gists_url":"https://api.github.com/users/samuelstjean/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelstjean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelstjean/subscriptions","organizations_url":"https://api.github.com/users/samuelstjean/orgs","repos_url":"https://api.github.com/users/samuelstjean/repos","events_url":"https://api.github.com/users/samuelstjean/events{/privacy}","received_events_url":"https://api.github.com/users/samuelstjean/received_events","type":"User","site_admin":false},"body":"So if I don't give it an array, a list of a streamline generator, won't it crash (or do weird stuff) on trying to return vals?","created_at":"2016-01-08T13:24:05Z","updated_at":"2016-01-08T13:24:05Z","html_url":"https://github.com/nipy/dipy/pull/811#discussion_r49187080","pull_request_url":"https://api.github.com/repos/nipy/dipy/pulls/811","_links":{"self":{"href":"https://api.github.com/repos/nipy/dipy/pulls/comments/49187080"},"html":{"href":"https://github.com/nipy/dipy/pull/811#discussion_r49187080"},"pull_request":{"href":"https://api.github.com/repos/nipy/dipy/pulls/811"}}},"pull_request":{"url":"https://api.github.com/repos/nipy/dipy/pulls/811","id":53885881,"html_url":"https://github.com/nipy/dipy/pull/811","diff_url":"https://github.com/nipy/dipy/pull/811.diff","patch_url":"https://github.com/nipy/dipy/pull/811.patch","issue_url":"https://api.github.com/repos/nipy/dipy/issues/811","number":811,"state":"open","locked":false,"title":"Extract values from an image based on streamline coordinates.","user":{"login":"arokem","id":118582,"avatar_url":"https://avatars.githubusercontent.com/u/118582?v=3","gravatar_id":"","url":"https://api.github.com/users/arokem","html_url":"https://github.com/arokem","followers_url":"https://api.github.com/users/arokem/followers","following_url":"https://api.github.com/users/arokem/following{/other_user}","gists_url":"https://api.github.com/users/arokem/gists{/gist_id}","starred_url":"https://api.github.com/users/arokem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arokem/subscriptions","organizations_url":"https://api.github.com/users/arokem/orgs","repos_url":"https://api.github.com/users/arokem/repos","events_url":"https://api.github.com/users/arokem/events{/privacy}","received_events_url":"https://api.github.com/users/arokem/received_events","type":"User","site_admin":false},"body":"Still need to test affine transformations","created_at":"2015-12-16T19:23:51Z","updated_at":"2016-01-08T13:24:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a2edc912fd9979ff1b3d5e7bf24915a21f794132","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nipy/dipy/pulls/811/commits","review_comments_url":"https://api.github.com/repos/nipy/dipy/pulls/811/comments","review_comment_url":"https://api.github.com/repos/nipy/dipy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nipy/dipy/issues/811/comments","statuses_url":"https://api.github.com/repos/nipy/dipy/statuses/d13be258edb60bb377e585f9013008c59f8dff0e","head":{"label":"arokem:vals_from_img","ref":"vals_from_img","sha":"d13be258edb60bb377e585f9013008c59f8dff0e","user":{"login":"arokem","id":118582,"avatar_url":"https://avatars.githubusercontent.com/u/118582?v=3","gravatar_id":"","url":"https://api.github.com/users/arokem","html_url":"https://github.com/arokem","followers_url":"https://api.github.com/users/arokem/followers","following_url":"https://api.github.com/users/arokem/following{/other_user}","gists_url":"https://api.github.com/users/arokem/gists{/gist_id}","starred_url":"https://api.github.com/users/arokem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arokem/subscriptions","organizations_url":"https://api.github.com/users/arokem/orgs","repos_url":"https://api.github.com/users/arokem/repos","events_url":"https://api.github.com/users/arokem/events{/privacy}","received_events_url":"https://api.github.com/users/arokem/received_events","type":"User","site_admin":false},"repo":{"id":2484790,"name":"dipy","full_name":"arokem/dipy","owner":{"login":"arokem","id":118582,"avatar_url":"https://avatars.githubusercontent.com/u/118582?v=3","gravatar_id":"","url":"https://api.github.com/users/arokem","html_url":"https://github.com/arokem","followers_url":"https://api.github.com/users/arokem/followers","following_url":"https://api.github.com/users/arokem/following{/other_user}","gists_url":"https://api.github.com/users/arokem/gists{/gist_id}","starred_url":"https://api.github.com/users/arokem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arokem/subscriptions","organizations_url":"https://api.github.com/users/arokem/orgs","repos_url":"https://api.github.com/users/arokem/repos","events_url":"https://api.github.com/users/arokem/events{/privacy}","received_events_url":"https://api.github.com/users/arokem/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/arokem/dipy","description":"Diffusion MR Imaging in Python","fork":true,"url":"https://api.github.com/repos/arokem/dipy","forks_url":"https://api.github.com/repos/arokem/dipy/forks","keys_url":"https://api.github.com/repos/arokem/dipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arokem/dipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arokem/dipy/teams","hooks_url":"https://api.github.com/repos/arokem/dipy/hooks","issue_events_url":"https://api.github.com/repos/arokem/dipy/issues/events{/number}","events_url":"https://api.github.com/repos/arokem/dipy/events","assignees_url":"https://api.github.com/repos/arokem/dipy/assignees{/user}","branches_url":"https://api.github.com/repos/arokem/dipy/branches{/branch}","tags_url":"https://api.github.com/repos/arokem/dipy/tags","blobs_url":"https://api.github.com/repos/arokem/dipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arokem/dipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arokem/dipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/arokem/dipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arokem/dipy/statuses/{sha}","languages_url":"https://api.github.com/repos/arokem/dipy/languages","stargazers_url":"https://api.github.com/repos/arokem/dipy/stargazers","contributors_url":"https://api.github.com/repos/arokem/dipy/contributors","subscribers_url":"https://api.github.com/repos/arokem/dipy/subscribers","subscription_url":"https://api.github.com/repos/arokem/dipy/subscription","commits_url":"https://api.github.com/repos/arokem/dipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/arokem/dipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/arokem/dipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/arokem/dipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/arokem/dipy/contents/{+path}","compare_url":"https://api.github.com/repos/arokem/dipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arokem/dipy/merges","archive_url":"https://api.github.com/repos/arokem/dipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arokem/dipy/downloads","issues_url":"https://api.github.com/repos/arokem/dipy/issues{/number}","pulls_url":"https://api.github.com/repos/arokem/dipy/pulls{/number}","milestones_url":"https://api.github.com/repos/arokem/dipy/milestones{/number}","notifications_url":"https://api.github.com/repos/arokem/dipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arokem/dipy/labels{/name}","releases_url":"https://api.github.com/repos/arokem/dipy/releases{/id}","created_at":"2011-09-29T20:43:30Z","updated_at":"2015-05-02T11:33:01Z","pushed_at":"2016-01-07T17:29:10Z","git_url":"git://github.com/arokem/dipy.git","ssh_url":"git@github.com:arokem/dipy.git","clone_url":"https://github.com/arokem/dipy.git","svn_url":"https://github.com/arokem/dipy","homepage":"http://dipy.org","size":27694,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"nipy:master","ref":"master","sha":"bef1c24c8d71a7e837ebffb4e3bdb5f7e2cdb022","user":{"login":"nipy","id":233707,"avatar_url":"https://avatars.githubusercontent.com/u/233707?v=3","gravatar_id":"","url":"https://api.github.com/users/nipy","html_url":"https://github.com/nipy","followers_url":"https://api.github.com/users/nipy/followers","following_url":"https://api.github.com/users/nipy/following{/other_user}","gists_url":"https://api.github.com/users/nipy/gists{/gist_id}","starred_url":"https://api.github.com/users/nipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nipy/subscriptions","organizations_url":"https://api.github.com/users/nipy/orgs","repos_url":"https://api.github.com/users/nipy/repos","events_url":"https://api.github.com/users/nipy/events{/privacy}","received_events_url":"https://api.github.com/users/nipy/received_events","type":"Organization","site_admin":false},"repo":{"id":505209,"name":"dipy","full_name":"nipy/dipy","owner":{"login":"nipy","id":233707,"avatar_url":"https://avatars.githubusercontent.com/u/233707?v=3","gravatar_id":"","url":"https://api.github.com/users/nipy","html_url":"https://github.com/nipy","followers_url":"https://api.github.com/users/nipy/followers","following_url":"https://api.github.com/users/nipy/following{/other_user}","gists_url":"https://api.github.com/users/nipy/gists{/gist_id}","starred_url":"https://api.github.com/users/nipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nipy/subscriptions","organizations_url":"https://api.github.com/users/nipy/orgs","repos_url":"https://api.github.com/users/nipy/repos","events_url":"https://api.github.com/users/nipy/events{/privacy}","received_events_url":"https://api.github.com/users/nipy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nipy/dipy","description":"Diffusion MR Imaging in Python","fork":false,"url":"https://api.github.com/repos/nipy/dipy","forks_url":"https://api.github.com/repos/nipy/dipy/forks","keys_url":"https://api.github.com/repos/nipy/dipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nipy/dipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nipy/dipy/teams","hooks_url":"https://api.github.com/repos/nipy/dipy/hooks","issue_events_url":"https://api.github.com/repos/nipy/dipy/issues/events{/number}","events_url":"https://api.github.com/repos/nipy/dipy/events","assignees_url":"https://api.github.com/repos/nipy/dipy/assignees{/user}","branches_url":"https://api.github.com/repos/nipy/dipy/branches{/branch}","tags_url":"https://api.github.com/repos/nipy/dipy/tags","blobs_url":"https://api.github.com/repos/nipy/dipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nipy/dipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nipy/dipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/nipy/dipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nipy/dipy/statuses/{sha}","languages_url":"https://api.github.com/repos/nipy/dipy/languages","stargazers_url":"https://api.github.com/repos/nipy/dipy/stargazers","contributors_url":"https://api.github.com/repos/nipy/dipy/contributors","subscribers_url":"https://api.github.com/repos/nipy/dipy/subscribers","subscription_url":"https://api.github.com/repos/nipy/dipy/subscription","commits_url":"https://api.github.com/repos/nipy/dipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/nipy/dipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/nipy/dipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/nipy/dipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/nipy/dipy/contents/{+path}","compare_url":"https://api.github.com/repos/nipy/dipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nipy/dipy/merges","archive_url":"https://api.github.com/repos/nipy/dipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nipy/dipy/downloads","issues_url":"https://api.github.com/repos/nipy/dipy/issues{/number}","pulls_url":"https://api.github.com/repos/nipy/dipy/pulls{/number}","milestones_url":"https://api.github.com/repos/nipy/dipy/milestones{/number}","notifications_url":"https://api.github.com/repos/nipy/dipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nipy/dipy/labels{/name}","releases_url":"https://api.github.com/repos/nipy/dipy/releases{/id}","created_at":"2010-02-06T11:43:08Z","updated_at":"2016-01-05T23:37:23Z","pushed_at":"2016-01-07T17:29:11Z","git_url":"git://github.com/nipy/dipy.git","ssh_url":"git@github.com:nipy/dipy.git","clone_url":"https://github.com/nipy/dipy.git","svn_url":"https://github.com/nipy/dipy","homepage":"http://dipy.org","size":28655,"stargazers_count":76,"watchers_count":76,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":114,"mirror_url":null,"open_issues_count":104,"forks":114,"open_issues":104,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nipy/dipy/pulls/811"},"html":{"href":"https://github.com/nipy/dipy/pull/811"},"issue":{"href":"https://api.github.com/repos/nipy/dipy/issues/811"},"comments":{"href":"https://api.github.com/repos/nipy/dipy/issues/811/comments"},"review_comments":{"href":"https://api.github.com/repos/nipy/dipy/pulls/811/comments"},"review_comment":{"href":"https://api.github.com/repos/nipy/dipy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nipy/dipy/pulls/811/commits"},"statuses":{"href":"https://api.github.com/repos/nipy/dipy/statuses/d13be258edb60bb377e585f9013008c59f8dff0e"}}}}