{"action":"created","comment":{"url":"https://api.github.com/repos/freeman-lab/thunder/pulls/comments/22991834","id":22991834,"diff_hunk":"@@ -0,0 +1,58 @@\n+\"\"\" Transformations produced by registration methods \"\"\"\n+\n+\n+class Transformation(object):\n+    \"\"\" Base class for transformations \"\"\"\n+\n+    def apply(self, im):\n+        raise NotImplementedError\n+\n+\n+class Displacement(Transformation):\n+\n+    def __init__(self, delta=None):\n+        self.delta = delta\n+\n+    def apply(self, im):\n+        \"\"\"\n+        Apply an n-dimensional displacement by shifting an image or volume.\n+\n+        Parameters\n+        ----------\n+        im : ndarray\n+            The image or volume to shift\n+        \"\"\"\n+        from scipy.ndimage.interpolation import shift\n+\n+        return shift(im, map(lambda x: -x, self.delta), mode='nearest')\n+\n+    def __repr__(self):\n+        return \"Displacement(delta=%s)\" % str(self.delta)\n+\n+\n+class PlanarDisplacement(Transformation):\n+\n+    def __init__(self, delta=None):","path":"python/thunder/imgprocessing/transformation.py","position":35,"original_position":35,"commit_id":"ac27bac08e6c1808b05893f1634ec813aa037f77","original_commit_id":"ac27bac08e6c1808b05893f1634ec813aa037f77","user":{"login":"poolio","id":718528,"avatar_url":"https://avatars.githubusercontent.com/u/718528?v=3","gravatar_id":"","url":"https://api.github.com/users/poolio","html_url":"https://github.com/poolio","followers_url":"https://api.github.com/users/poolio/followers","following_url":"https://api.github.com/users/poolio/following{/other_user}","gists_url":"https://api.github.com/users/poolio/gists{/gist_id}","starred_url":"https://api.github.com/users/poolio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poolio/subscriptions","organizations_url":"https://api.github.com/users/poolio/orgs","repos_url":"https://api.github.com/users/poolio/repos","events_url":"https://api.github.com/users/poolio/events{/privacy}","received_events_url":"https://api.github.com/users/poolio/received_events","type":"User","site_admin":false},"body":"How is delta structured? Would be nice to document it here so you don't have to cross-reference the registration method to figure it out.","created_at":"2015-01-15T05:51:35Z","updated_at":"2015-01-15T05:51:35Z","html_url":"https://github.com/freeman-lab/thunder/pull/74#discussion_r22991834","pull_request_url":"https://api.github.com/repos/freeman-lab/thunder/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/freeman-lab/thunder/pulls/comments/22991834"},"html":{"href":"https://github.com/freeman-lab/thunder/pull/74#discussion_r22991834"},"pull_request":{"href":"https://api.github.com/repos/freeman-lab/thunder/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/freeman-lab/thunder/pulls/74","id":26433643,"html_url":"https://github.com/freeman-lab/thunder/pull/74","diff_url":"https://github.com/freeman-lab/thunder/pull/74.diff","patch_url":"https://github.com/freeman-lab/thunder/pull/74.patch","issue_url":"https://api.github.com/repos/freeman-lab/thunder/issues/74","number":74,"state":"open","locked":false,"title":"Refactored registration","user":{"login":"freeman-lab","id":3387500,"avatar_url":"https://avatars.githubusercontent.com/u/3387500?v=3","gravatar_id":"","url":"https://api.github.com/users/freeman-lab","html_url":"https://github.com/freeman-lab","followers_url":"https://api.github.com/users/freeman-lab/followers","following_url":"https://api.github.com/users/freeman-lab/following{/other_user}","gists_url":"https://api.github.com/users/freeman-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/freeman-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeman-lab/subscriptions","organizations_url":"https://api.github.com/users/freeman-lab/orgs","repos_url":"https://api.github.com/users/freeman-lab/repos","events_url":"https://api.github.com/users/freeman-lab/events{/privacy}","received_events_url":"https://api.github.com/users/freeman-lab/received_events","type":"User","site_admin":false},"body":"Significant refactoring of registration methods based on offline discussions with @broxtronix and @poolio and Noah (@d-v-b might be interested as well).\r\n\r\nThe key change is to separate the application and estimation of registration parameters through a new `RegisterModel` class. Performing registration will return an instantiation of this class, and it has a `transform` method for applying the transformations to an `Images` object. This makes it simple to compute parameters on one data set and apply them to another, which was previously difficult.\r\n\r\nOther features for improved modularity and extensibility\r\n- Support simple saving / loading of registration models to / from JSON\r\n- Separate particular registration implementations into modules within an `imgprocessing.regmethods` package\r\n- Provide simpler constructor interface through a `Register` class that is separate from the base class `RegisterMethod`\r\n- A new `run` method on registration methods combines the `fit` and `transform` into a single step, which can be more efficient, and matches the old behavior, but does not expose the transformation parameters directly\r\n\r\nExample usage\r\n- Compute parameters on one data set and apply to another\r\n```\r\nfrom thunder import Register\r\n\r\nimages1 = tsc.loadExample('fish-images')\r\nimages2 = images1.medianFilter(2)\r\nref = images2.first()[1]\r\n\r\nmodel = Register('crosscorr').fit(images2, ref)\r\nalginedimages = model.transform(images1)\r\n```\r\n- Perform registration in one step\r\n```\r\nfrom thunder import Register\r\n\r\nimages1 = tsc.loadExample('fish-images')\r\nref = images1.first()[1]\r\n\r\nalignedimages = Register('crosscorr').run(images1, ref)\r\n```\r\n- Save registration model to JSON\r\n```\r\nfrom thunder import Register\r\n\r\nimages1 = tsc.loadExample('fish-images')\r\nref = images1.first()[1]\r\n\r\nmodel = Register('crosscorr').fit(images1, ref)\r\nmodel.save('/tmp/file.json')\r\n\r\nmodel = Register.load('/tmp/file.json')\r\n```","created_at":"2014-12-21T23:21:53Z","updated_at":"2015-01-15T05:51:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d5ec766bb1c5113f5b54a40ad75b04ebaec9a88","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/freeman-lab/thunder/pulls/74/commits","review_comments_url":"https://api.github.com/repos/freeman-lab/thunder/pulls/74/comments","review_comment_url":"https://api.github.com/repos/freeman-lab/thunder/pulls/comments/{number}","comments_url":"https://api.github.com/repos/freeman-lab/thunder/issues/74/comments","statuses_url":"https://api.github.com/repos/freeman-lab/thunder/statuses/ac27bac08e6c1808b05893f1634ec813aa037f77","head":{"label":"freeman-lab:refactored-registration","ref":"refactored-registration","sha":"ac27bac08e6c1808b05893f1634ec813aa037f77","user":{"login":"freeman-lab","id":3387500,"avatar_url":"https://avatars.githubusercontent.com/u/3387500?v=3","gravatar_id":"","url":"https://api.github.com/users/freeman-lab","html_url":"https://github.com/freeman-lab","followers_url":"https://api.github.com/users/freeman-lab/followers","following_url":"https://api.github.com/users/freeman-lab/following{/other_user}","gists_url":"https://api.github.com/users/freeman-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/freeman-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeman-lab/subscriptions","organizations_url":"https://api.github.com/users/freeman-lab/orgs","repos_url":"https://api.github.com/users/freeman-lab/repos","events_url":"https://api.github.com/users/freeman-lab/events{/privacy}","received_events_url":"https://api.github.com/users/freeman-lab/received_events","type":"User","site_admin":false},"repo":{"id":10616272,"name":"thunder","full_name":"freeman-lab/thunder","owner":{"login":"freeman-lab","id":3387500,"avatar_url":"https://avatars.githubusercontent.com/u/3387500?v=3","gravatar_id":"","url":"https://api.github.com/users/freeman-lab","html_url":"https://github.com/freeman-lab","followers_url":"https://api.github.com/users/freeman-lab/followers","following_url":"https://api.github.com/users/freeman-lab/following{/other_user}","gists_url":"https://api.github.com/users/freeman-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/freeman-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeman-lab/subscriptions","organizations_url":"https://api.github.com/users/freeman-lab/orgs","repos_url":"https://api.github.com/users/freeman-lab/repos","events_url":"https://api.github.com/users/freeman-lab/events{/privacy}","received_events_url":"https://api.github.com/users/freeman-lab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/freeman-lab/thunder","description":"Large-scale neural data analysis with Spark","fork":false,"url":"https://api.github.com/repos/freeman-lab/thunder","forks_url":"https://api.github.com/repos/freeman-lab/thunder/forks","keys_url":"https://api.github.com/repos/freeman-lab/thunder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freeman-lab/thunder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freeman-lab/thunder/teams","hooks_url":"https://api.github.com/repos/freeman-lab/thunder/hooks","issue_events_url":"https://api.github.com/repos/freeman-lab/thunder/issues/events{/number}","events_url":"https://api.github.com/repos/freeman-lab/thunder/events","assignees_url":"https://api.github.com/repos/freeman-lab/thunder/assignees{/user}","branches_url":"https://api.github.com/repos/freeman-lab/thunder/branches{/branch}","tags_url":"https://api.github.com/repos/freeman-lab/thunder/tags","blobs_url":"https://api.github.com/repos/freeman-lab/thunder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freeman-lab/thunder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freeman-lab/thunder/git/refs{/sha}","trees_url":"https://api.github.com/repos/freeman-lab/thunder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freeman-lab/thunder/statuses/{sha}","languages_url":"https://api.github.com/repos/freeman-lab/thunder/languages","stargazers_url":"https://api.github.com/repos/freeman-lab/thunder/stargazers","contributors_url":"https://api.github.com/repos/freeman-lab/thunder/contributors","subscribers_url":"https://api.github.com/repos/freeman-lab/thunder/subscribers","subscription_url":"https://api.github.com/repos/freeman-lab/thunder/subscription","commits_url":"https://api.github.com/repos/freeman-lab/thunder/commits{/sha}","git_commits_url":"https://api.github.com/repos/freeman-lab/thunder/git/commits{/sha}","comments_url":"https://api.github.com/repos/freeman-lab/thunder/comments{/number}","issue_comment_url":"https://api.github.com/repos/freeman-lab/thunder/issues/comments/{number}","contents_url":"https://api.github.com/repos/freeman-lab/thunder/contents/{+path}","compare_url":"https://api.github.com/repos/freeman-lab/thunder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freeman-lab/thunder/merges","archive_url":"https://api.github.com/repos/freeman-lab/thunder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freeman-lab/thunder/downloads","issues_url":"https://api.github.com/repos/freeman-lab/thunder/issues{/number}","pulls_url":"https://api.github.com/repos/freeman-lab/thunder/pulls{/number}","milestones_url":"https://api.github.com/repos/freeman-lab/thunder/milestones{/number}","notifications_url":"https://api.github.com/repos/freeman-lab/thunder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freeman-lab/thunder/labels{/name}","releases_url":"https://api.github.com/repos/freeman-lab/thunder/releases{/id}","created_at":"2013-06-11T07:00:47Z","updated_at":"2015-01-14T23:41:02Z","pushed_at":"2015-01-14T23:41:01Z","git_url":"git://github.com/freeman-lab/thunder.git","ssh_url":"git@github.com:freeman-lab/thunder.git","clone_url":"https://github.com/freeman-lab/thunder.git","svn_url":"https://github.com/freeman-lab/thunder","homepage":"","size":43407,"stargazers_count":236,"watchers_count":236,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":54,"mirror_url":null,"open_issues_count":8,"forks":54,"open_issues":8,"watchers":236,"default_branch":"master"}},"base":{"label":"freeman-lab:master","ref":"master","sha":"4ae4c94417ae9108b01023cecd4ca4f38f4d89e1","user":{"login":"freeman-lab","id":3387500,"avatar_url":"https://avatars.githubusercontent.com/u/3387500?v=3","gravatar_id":"","url":"https://api.github.com/users/freeman-lab","html_url":"https://github.com/freeman-lab","followers_url":"https://api.github.com/users/freeman-lab/followers","following_url":"https://api.github.com/users/freeman-lab/following{/other_user}","gists_url":"https://api.github.com/users/freeman-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/freeman-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeman-lab/subscriptions","organizations_url":"https://api.github.com/users/freeman-lab/orgs","repos_url":"https://api.github.com/users/freeman-lab/repos","events_url":"https://api.github.com/users/freeman-lab/events{/privacy}","received_events_url":"https://api.github.com/users/freeman-lab/received_events","type":"User","site_admin":false},"repo":{"id":10616272,"name":"thunder","full_name":"freeman-lab/thunder","owner":{"login":"freeman-lab","id":3387500,"avatar_url":"https://avatars.githubusercontent.com/u/3387500?v=3","gravatar_id":"","url":"https://api.github.com/users/freeman-lab","html_url":"https://github.com/freeman-lab","followers_url":"https://api.github.com/users/freeman-lab/followers","following_url":"https://api.github.com/users/freeman-lab/following{/other_user}","gists_url":"https://api.github.com/users/freeman-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/freeman-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeman-lab/subscriptions","organizations_url":"https://api.github.com/users/freeman-lab/orgs","repos_url":"https://api.github.com/users/freeman-lab/repos","events_url":"https://api.github.com/users/freeman-lab/events{/privacy}","received_events_url":"https://api.github.com/users/freeman-lab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/freeman-lab/thunder","description":"Large-scale neural data analysis with Spark","fork":false,"url":"https://api.github.com/repos/freeman-lab/thunder","forks_url":"https://api.github.com/repos/freeman-lab/thunder/forks","keys_url":"https://api.github.com/repos/freeman-lab/thunder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freeman-lab/thunder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freeman-lab/thunder/teams","hooks_url":"https://api.github.com/repos/freeman-lab/thunder/hooks","issue_events_url":"https://api.github.com/repos/freeman-lab/thunder/issues/events{/number}","events_url":"https://api.github.com/repos/freeman-lab/thunder/events","assignees_url":"https://api.github.com/repos/freeman-lab/thunder/assignees{/user}","branches_url":"https://api.github.com/repos/freeman-lab/thunder/branches{/branch}","tags_url":"https://api.github.com/repos/freeman-lab/thunder/tags","blobs_url":"https://api.github.com/repos/freeman-lab/thunder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freeman-lab/thunder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freeman-lab/thunder/git/refs{/sha}","trees_url":"https://api.github.com/repos/freeman-lab/thunder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freeman-lab/thunder/statuses/{sha}","languages_url":"https://api.github.com/repos/freeman-lab/thunder/languages","stargazers_url":"https://api.github.com/repos/freeman-lab/thunder/stargazers","contributors_url":"https://api.github.com/repos/freeman-lab/thunder/contributors","subscribers_url":"https://api.github.com/repos/freeman-lab/thunder/subscribers","subscription_url":"https://api.github.com/repos/freeman-lab/thunder/subscription","commits_url":"https://api.github.com/repos/freeman-lab/thunder/commits{/sha}","git_commits_url":"https://api.github.com/repos/freeman-lab/thunder/git/commits{/sha}","comments_url":"https://api.github.com/repos/freeman-lab/thunder/comments{/number}","issue_comment_url":"https://api.github.com/repos/freeman-lab/thunder/issues/comments/{number}","contents_url":"https://api.github.com/repos/freeman-lab/thunder/contents/{+path}","compare_url":"https://api.github.com/repos/freeman-lab/thunder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freeman-lab/thunder/merges","archive_url":"https://api.github.com/repos/freeman-lab/thunder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freeman-lab/thunder/downloads","issues_url":"https://api.github.com/repos/freeman-lab/thunder/issues{/number}","pulls_url":"https://api.github.com/repos/freeman-lab/thunder/pulls{/number}","milestones_url":"https://api.github.com/repos/freeman-lab/thunder/milestones{/number}","notifications_url":"https://api.github.com/repos/freeman-lab/thunder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freeman-lab/thunder/labels{/name}","releases_url":"https://api.github.com/repos/freeman-lab/thunder/releases{/id}","created_at":"2013-06-11T07:00:47Z","updated_at":"2015-01-14T23:41:02Z","pushed_at":"2015-01-14T23:41:01Z","git_url":"git://github.com/freeman-lab/thunder.git","ssh_url":"git@github.com:freeman-lab/thunder.git","clone_url":"https://github.com/freeman-lab/thunder.git","svn_url":"https://github.com/freeman-lab/thunder","homepage":"","size":43407,"stargazers_count":236,"watchers_count":236,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":54,"mirror_url":null,"open_issues_count":8,"forks":54,"open_issues":8,"watchers":236,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/freeman-lab/thunder/pulls/74"},"html":{"href":"https://github.com/freeman-lab/thunder/pull/74"},"issue":{"href":"https://api.github.com/repos/freeman-lab/thunder/issues/74"},"comments":{"href":"https://api.github.com/repos/freeman-lab/thunder/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/freeman-lab/thunder/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/freeman-lab/thunder/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/freeman-lab/thunder/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/freeman-lab/thunder/statuses/ac27bac08e6c1808b05893f1634ec813aa037f77"}}}}