{"action":"created","comment":{"url":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/comments/67981872","id":67981872,"diff_hunk":"@@ -69,22 +69,87 @@ def segment(fdata, fbval, fbvec, streamlines, bundles=AFQ_BUNDLES,\n         mapping = reg.read_mapping(mapping, img, reg_template)\n \n     fiber_groups = {}\n-    for hemi in [\"R\", \"L\"]:\n-        for bundle in bundles:\n-            ROIs = [bundle + \"_roi%s_\" % (i + 1) + hemi for i in range(2)]\n-            select_sl = xform_sl\n-            for ROI in ROIs:\n-                data = templates[ROI].get_data()\n-                warped_ROI = patch_up_roi(mapping.transform_inverse(\n-                    data,\n-                    interpolation='nearest'))\n-\n-                select_sl = dts.select_by_rois(select_sl,\n-                                               [warped_ROI.astype(bool)],\n-                                               [True])\n-            if as_generator:\n-                fiber_groups[bundle + \"_\" + hemi] = select_sl\n-            else:\n-                fiber_groups[bundle + \"_\" + hemi] = list(select_sl)\n+    for bundle in bundles:\n+        select_sl = xform_sl\n+        for ROI, rule in zip(bundles[bundle]['ROIs'], bundles[bundle]['rules']):\n+            data = ROI.get_data()\n+            warped_ROI = patch_up_roi(mapping.transform_inverse(\n+                data,\n+                interpolation='nearest'))\n+            # This function requires lists as inputs:\n+            select_sl = dts.select_by_rois(select_sl,\n+                               [warped_ROI.astype(bool)],\n+                               [rule])\n+        # Next, we reorient each streamline according to an ARBITRARY, but\n+        # CONSISTENT order. To do this, we use the first ROI for which the rule\n+        # is True as the first one to pass through, and the last ROI for which\n+        # the rule is True as the last one to pass through:\n+\n+        # Indices where the 'rule' is True:\n+        idx = np.where(bundles[bundle]['rules'])\n+\n+        orient_ROIs = [bundles[bundle]['ROIs'][idx[0][0]],\n+                       bundles[bundle]['ROIs'][idx[0][-1]]]\n+\n+        select_sl = dts.orient_by_rois(select_sl,\n+                                       orient_ROIs[0].get_data(),\n+                                       orient_ROIs[1].get_data(),\n+                                       copy=False)\n+        if as_generator:\n+            fiber_groups[bundle] = select_sl\n+        else:\n+            fiber_groups[bundle] = list(select_sl)\n \n     return fiber_groups\n+\n+\n+def calculate_tract_profile(img, streamlines, affine=None, n_points=100,\n+                            weighting=None):\n+    \"\"\"\n+\n+    Parameters\n+    ----------\n+    img : 3D volume\n+\n+    streamlines : list of arrays, or array\n+\n+    weighting : 1D array or 2D array (optional)\n+\n+    \"\"\"\n+    if isinstance(streamlines, list):\n+        # Resample each streamline to the same number of points\n+        # list => array","path":"AFQ/segmentation.py","position":132,"original_position":132,"commit_id":"e36402da31045cdf9f1e43805364fa62d365d7f4","original_commit_id":"e36402da31045cdf9f1e43805364fa62d365d7f4","user":{"login":"bcipolli","id":4072455,"avatar_url":"https://avatars.githubusercontent.com/u/4072455?v=3","gravatar_id":"","url":"https://api.github.com/users/bcipolli","html_url":"https://github.com/bcipolli","followers_url":"https://api.github.com/users/bcipolli/followers","following_url":"https://api.github.com/users/bcipolli/following{/other_user}","gists_url":"https://api.github.com/users/bcipolli/gists{/gist_id}","starred_url":"https://api.github.com/users/bcipolli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcipolli/subscriptions","organizations_url":"https://api.github.com/users/bcipolli/orgs","repos_url":"https://api.github.com/users/bcipolli/repos","events_url":"https://api.github.com/users/bcipolli/events{/privacy}","received_events_url":"https://api.github.com/users/bcipolli/received_events","type":"User","site_admin":false},"body":"perhaps `np.array`? I didn't get this at first... but maybe the issue is, I'm not in Python/Numpy enough these days :)","created_at":"2016-06-22T01:32:27Z","updated_at":"2016-06-22T01:32:27Z","html_url":"https://github.com/yeatmanlab/pyAFQ/pull/30#discussion_r67981872","pull_request_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/comments/67981872"},"html":{"href":"https://github.com/yeatmanlab/pyAFQ/pull/30#discussion_r67981872"},"pull_request":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30","id":73994106,"html_url":"https://github.com/yeatmanlab/pyAFQ/pull/30","diff_url":"https://github.com/yeatmanlab/pyAFQ/pull/30.diff","patch_url":"https://github.com/yeatmanlab/pyAFQ/pull/30.patch","issue_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/issues/30","number":30,"state":"open","locked":false,"title":"Slightly more flexible segmentation API","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":"Also moved a bit of cruft into `api`, added a `yield` fix for `orient_by_rois` (and used it to orient the streamlines as they are segmented).","created_at":"2016-06-15T22:20:18Z","updated_at":"2016-06-22T01:32:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"41c2e60ce1795bf09b2381dfa6c2ef2a8a02f9c3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30/commits","review_comments_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30/comments","review_comment_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/issues/30/comments","statuses_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/statuses/e36402da31045cdf9f1e43805364fa62d365d7f4","head":{"label":"arokem:flex-segment","ref":"flex-segment","sha":"e36402da31045cdf9f1e43805364fa62d365d7f4","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":51022066,"name":"pyAFQ","full_name":"arokem/pyAFQ","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/pyAFQ","description":"Automated Fiber Quantification ... in Python","fork":true,"url":"https://api.github.com/repos/arokem/pyAFQ","forks_url":"https://api.github.com/repos/arokem/pyAFQ/forks","keys_url":"https://api.github.com/repos/arokem/pyAFQ/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arokem/pyAFQ/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arokem/pyAFQ/teams","hooks_url":"https://api.github.com/repos/arokem/pyAFQ/hooks","issue_events_url":"https://api.github.com/repos/arokem/pyAFQ/issues/events{/number}","events_url":"https://api.github.com/repos/arokem/pyAFQ/events","assignees_url":"https://api.github.com/repos/arokem/pyAFQ/assignees{/user}","branches_url":"https://api.github.com/repos/arokem/pyAFQ/branches{/branch}","tags_url":"https://api.github.com/repos/arokem/pyAFQ/tags","blobs_url":"https://api.github.com/repos/arokem/pyAFQ/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arokem/pyAFQ/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arokem/pyAFQ/git/refs{/sha}","trees_url":"https://api.github.com/repos/arokem/pyAFQ/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arokem/pyAFQ/statuses/{sha}","languages_url":"https://api.github.com/repos/arokem/pyAFQ/languages","stargazers_url":"https://api.github.com/repos/arokem/pyAFQ/stargazers","contributors_url":"https://api.github.com/repos/arokem/pyAFQ/contributors","subscribers_url":"https://api.github.com/repos/arokem/pyAFQ/subscribers","subscription_url":"https://api.github.com/repos/arokem/pyAFQ/subscription","commits_url":"https://api.github.com/repos/arokem/pyAFQ/commits{/sha}","git_commits_url":"https://api.github.com/repos/arokem/pyAFQ/git/commits{/sha}","comments_url":"https://api.github.com/repos/arokem/pyAFQ/comments{/number}","issue_comment_url":"https://api.github.com/repos/arokem/pyAFQ/issues/comments{/number}","contents_url":"https://api.github.com/repos/arokem/pyAFQ/contents/{+path}","compare_url":"https://api.github.com/repos/arokem/pyAFQ/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arokem/pyAFQ/merges","archive_url":"https://api.github.com/repos/arokem/pyAFQ/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arokem/pyAFQ/downloads","issues_url":"https://api.github.com/repos/arokem/pyAFQ/issues{/number}","pulls_url":"https://api.github.com/repos/arokem/pyAFQ/pulls{/number}","milestones_url":"https://api.github.com/repos/arokem/pyAFQ/milestones{/number}","notifications_url":"https://api.github.com/repos/arokem/pyAFQ/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arokem/pyAFQ/labels{/name}","releases_url":"https://api.github.com/repos/arokem/pyAFQ/releases{/id}","deployments_url":"https://api.github.com/repos/arokem/pyAFQ/deployments","created_at":"2016-02-03T18:47:22Z","updated_at":"2016-02-10T20:12:15Z","pushed_at":"2016-06-20T23:02:07Z","git_url":"git://github.com/arokem/pyAFQ.git","ssh_url":"git@github.com:arokem/pyAFQ.git","clone_url":"https://github.com/arokem/pyAFQ.git","svn_url":"https://github.com/arokem/pyAFQ","homepage":null,"size":1650,"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":"yeatmanlab:master","ref":"master","sha":"68f110f569670b4b93e38ce9f104212327ab03c5","user":{"login":"yeatmanlab","id":15619773,"avatar_url":"https://avatars.githubusercontent.com/u/15619773?v=3","gravatar_id":"","url":"https://api.github.com/users/yeatmanlab","html_url":"https://github.com/yeatmanlab","followers_url":"https://api.github.com/users/yeatmanlab/followers","following_url":"https://api.github.com/users/yeatmanlab/following{/other_user}","gists_url":"https://api.github.com/users/yeatmanlab/gists{/gist_id}","starred_url":"https://api.github.com/users/yeatmanlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yeatmanlab/subscriptions","organizations_url":"https://api.github.com/users/yeatmanlab/orgs","repos_url":"https://api.github.com/users/yeatmanlab/repos","events_url":"https://api.github.com/users/yeatmanlab/events{/privacy}","received_events_url":"https://api.github.com/users/yeatmanlab/received_events","type":"Organization","site_admin":false},"repo":{"id":51022036,"name":"pyAFQ","full_name":"yeatmanlab/pyAFQ","owner":{"login":"yeatmanlab","id":15619773,"avatar_url":"https://avatars.githubusercontent.com/u/15619773?v=3","gravatar_id":"","url":"https://api.github.com/users/yeatmanlab","html_url":"https://github.com/yeatmanlab","followers_url":"https://api.github.com/users/yeatmanlab/followers","following_url":"https://api.github.com/users/yeatmanlab/following{/other_user}","gists_url":"https://api.github.com/users/yeatmanlab/gists{/gist_id}","starred_url":"https://api.github.com/users/yeatmanlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yeatmanlab/subscriptions","organizations_url":"https://api.github.com/users/yeatmanlab/orgs","repos_url":"https://api.github.com/users/yeatmanlab/repos","events_url":"https://api.github.com/users/yeatmanlab/events{/privacy}","received_events_url":"https://api.github.com/users/yeatmanlab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yeatmanlab/pyAFQ","description":"Automated Fiber Quantification ... in Python","fork":false,"url":"https://api.github.com/repos/yeatmanlab/pyAFQ","forks_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/forks","keys_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/teams","hooks_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/hooks","issue_events_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/issues/events{/number}","events_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/events","assignees_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/assignees{/user}","branches_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/branches{/branch}","tags_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/tags","blobs_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/git/refs{/sha}","trees_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/statuses/{sha}","languages_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/languages","stargazers_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/stargazers","contributors_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/contributors","subscribers_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/subscribers","subscription_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/subscription","commits_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/commits{/sha}","git_commits_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/git/commits{/sha}","comments_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/comments{/number}","issue_comment_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/issues/comments{/number}","contents_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/contents/{+path}","compare_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/merges","archive_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/downloads","issues_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/issues{/number}","pulls_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls{/number}","milestones_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/milestones{/number}","notifications_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/labels{/name}","releases_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/releases{/id}","deployments_url":"https://api.github.com/repos/yeatmanlab/pyAFQ/deployments","created_at":"2016-02-03T18:46:46Z","updated_at":"2016-02-03T20:56:46Z","pushed_at":"2016-06-20T23:02:08Z","git_url":"git://github.com/yeatmanlab/pyAFQ.git","ssh_url":"git@github.com:yeatmanlab/pyAFQ.git","clone_url":"https://github.com/yeatmanlab/pyAFQ.git","svn_url":"https://github.com/yeatmanlab/pyAFQ","homepage":null,"size":1595,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30"},"html":{"href":"https://github.com/yeatmanlab/pyAFQ/pull/30"},"issue":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/issues/30"},"comments":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/yeatmanlab/pyAFQ/statuses/e36402da31045cdf9f1e43805364fa62d365d7f4"}}}}
{"actor":{"display_login":"bcipolli"}}