{"action":"created","comment":{"url":"https://api.github.com/repos/spacetx/starfish/pulls/comments/201873079","pull_request_review_id":136461060,"id":201873079,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTg3MzA3OQ==","diff_hunk":"@@ -705,16 +706,190 @@ def max_proj(self, *dims: Indices) -> numpy.ndarray:\n \n         \"\"\"\n         axes = list()\n+\n+        # preserve data's type\n+        dtype = self.numpy_array.dtype\n+\n         for dim in dims:\n             try:\n                 axes.append(ImageStack.AXES_MAP[dim])\n             except KeyError:\n                 raise ValueError(\n                     \"Dimension: {} not supported. Expecting one of: {}\".format(dim, ImageStack.AXES_MAP.keys()))\n \n-        return numpy.max(self._data, axis=tuple(axes))\n+        max_projection = np.max(self._data, axis=tuple(axes)).astype(dtype)\n+        return max_projection\n+\n+    @staticmethod\n+    def _default_tile_extras_provider(hyb: int, ch: int, z: int) -> Any:\n+        \"\"\"\n+        Returns None for extras for any given hyb/ch/z.\n+        \"\"\"\n+        return None\n+\n+    @staticmethod\n+    def _default_tile_data_provider(hyb: int, ch: int, z: int, height: int, width: int) -> np.ndarray:\n+        \"\"\"\n+        Returns a tile of just ones for any given hyb/ch/z.\n+        \"\"\"\n+        return np.ones((height, width))\n+\n+    @classmethod\n+    def synthetic_stack(\n+            cls,\n+            num_hyb: int=4,\n+            num_ch: int=4,\n+            num_z: int=12,\n+            tile_height: int=50,\n+            tile_width: int=40,\n+            tile_data_provider: Callable[[int, int, int, int, int], np.ndarray]=None,\n+            tile_extras_provider: Callable[[int, int, int], Any]=None,\n+    ) -> \"ImageStack\":\n+        \"\"\"generate a synthetic ImageStack\n+\n+        Returns\n+        -------\n+        ImageStack :\n+            imagestack containing a tensor whose default shape is (2, 3, 4, 30, 20)\n+            and whose default values are all 1.\n+\n+        \"\"\"\n+        if tile_data_provider is None:\n+            tile_data_provider = cls._default_tile_data_provider\n+        if tile_extras_provider is None:\n+            tile_extras_provider = cls._default_tile_extras_provider\n+\n+        img = TileSet(\n+            {Coordinates.X, Coordinates.Y, Indices.HYB, Indices.CH, Indices.Z},\n+            {\n+                Indices.HYB: num_hyb,\n+                Indices.CH: num_ch,\n+                Indices.Z: num_z,\n+            },\n+            default_tile_shape=(tile_height, tile_width),\n+        )\n+        for hyb in range(num_hyb):\n+            for ch in range(num_ch):\n+                for z in range(num_z):\n+                    tile = Tile(\n+                        {\n+                            Coordinates.X: (0.0, 0.001),\n+                            Coordinates.Y: (0.0, 0.001),\n+                            Coordinates.Z: (0.0, 0.001),\n+                        },\n+                        {\n+                            Indices.HYB: hyb,\n+                            Indices.CH: ch,\n+                            Indices.Z: z,\n+                        },\n+                        extras=tile_extras_provider(hyb, ch, z),\n+                    )\n+                    tile.numpy_array = tile_data_provider(hyb, ch, z, tile_height, tile_width)\n+\n+                    img.add_tile(tile)\n+\n+        stack = cls(img)\n+        return stack\n+\n+    @classmethod\n+    def synthetic_spots(\n+            cls, intensities, num_z, height, width, n_photons_background=1000,\n+            point_spread_function=(4, 2, 2), camera_detection_efficiency=0.25,\n+            background_electrons=1, graylevel: float=37000.0 / 2 ** 16, ad_conversion_bits=16,\n+    ) -> \"ImageStack\":\n+        \"\"\"Generate a synthetic ImageStack from a set of Features stored in an IntensityTable\n+\n+        Parameters\n+        ----------\n+        intensities : IntensityTable\n+            IntensityTable containing coordinates of fluorophores. Used to position and generate\n+            spots in the output ImageStack\n+        num_z : int\n+            Number of z-planes in the ImageStack\n+        height : int\n+            Height in pixels of the ImageStack\n+        width : int\n+            Width in pixels of the ImageStack\n+        n_photons_background : int\n+            Number of background photons to add to the image -- set to 0 to eliminate background\n+            (default 1000)\n+        point_spread_function : Tuple[int]\n+            The width of the gaussian density wherein photons spread around their light source.\n+            Set to zero to eliminate this (default (4, 2, 2))\n+        camera_detection_efficiency : float\n+            The efficiency of the camera to detect light. Set to 1 to remove this filter (default\n+            0.25)\n+        background_electrons : int","path":"starfish/image/_stack.py","position":288,"original_position":288,"commit_id":"5e1bf6152fa1de9afefc02bde4359ccf590b8c60","original_commit_id":"5e1bf6152fa1de9afefc02bde4359ccf590b8c60","user":{"login":"ambrosejcarr","id":5239152,"node_id":"MDQ6VXNlcjUyMzkxNTI=","avatar_url":"https://avatars1.githubusercontent.com/u/5239152?v=4","gravatar_id":"","url":"https://api.github.com/users/ambrosejcarr","html_url":"https://github.com/ambrosejcarr","followers_url":"https://api.github.com/users/ambrosejcarr/followers","following_url":"https://api.github.com/users/ambrosejcarr/following{/other_user}","gists_url":"https://api.github.com/users/ambrosejcarr/gists{/gist_id}","starred_url":"https://api.github.com/users/ambrosejcarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambrosejcarr/subscriptions","organizations_url":"https://api.github.com/users/ambrosejcarr/orgs","repos_url":"https://api.github.com/users/ambrosejcarr/repos","events_url":"https://api.github.com/users/ambrosejcarr/events{/privacy}","received_events_url":"https://api.github.com/users/ambrosejcarr/received_events","type":"User","site_admin":false},"body":"Poisson rate per pixel. will make clearer. Thanks!","created_at":"2018-07-11T23:48:22Z","updated_at":"2018-07-11T23:48:22Z","html_url":"https://github.com/spacetx/starfish/pull/298#discussion_r201873079","pull_request_url":"https://api.github.com/repos/spacetx/starfish/pulls/298","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/spacetx/starfish/pulls/comments/201873079"},"html":{"href":"https://github.com/spacetx/starfish/pull/298#discussion_r201873079"},"pull_request":{"href":"https://api.github.com/repos/spacetx/starfish/pulls/298"}},"in_reply_to_id":201775587},"pull_request":{"url":"https://api.github.com/repos/spacetx/starfish/pulls/298","id":197607542,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3NjA3NTQy","html_url":"https://github.com/spacetx/starfish/pull/298","diff_url":"https://github.com/spacetx/starfish/pull/298.diff","patch_url":"https://github.com/spacetx/starfish/pull/298.patch","issue_url":"https://api.github.com/repos/spacetx/starfish/issues/298","number":298,"state":"open","locked":false,"title":"ENH: Codebook + IntensityTable demonstrated on ISS Pipeline","user":{"login":"ambrosejcarr","id":5239152,"node_id":"MDQ6VXNlcjUyMzkxNTI=","avatar_url":"https://avatars1.githubusercontent.com/u/5239152?v=4","gravatar_id":"","url":"https://api.github.com/users/ambrosejcarr","html_url":"https://github.com/ambrosejcarr","followers_url":"https://api.github.com/users/ambrosejcarr/followers","following_url":"https://api.github.com/users/ambrosejcarr/following{/other_user}","gists_url":"https://api.github.com/users/ambrosejcarr/gists{/gist_id}","starred_url":"https://api.github.com/users/ambrosejcarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambrosejcarr/subscriptions","organizations_url":"https://api.github.com/users/ambrosejcarr/orgs","repos_url":"https://api.github.com/users/ambrosejcarr/repos","events_url":"https://api.github.com/users/ambrosejcarr/events{/privacy}","received_events_url":"https://api.github.com/users/ambrosejcarr/received_events","type":"User","site_admin":false},"body":"I tried to cut this up, but wasn't comfortable editing diff headers, so instead I have one gigantic PR, but I've annotated parts of it to try to make clear why changes were made. \r\n\r\nThis includes four main (unfortunately somewhat interwoven) changes: \r\n1. Implementation of Codebook + IntensityTable\r\n2. Modification of the synthetic framework to: \r\n    1. Generate synthetic `Codebooks`\r\n    2. Use the `Codebook` to generate synthetic `IntensityTables`\r\n    3. Use the `IntensityTables` to generate synthetic `ImageStacks`\r\n3. Modification of the gaussian spot detector to allow, among other things, synthetic ImageStacks to be transformed back into IntensityTables, which can then be decoded and matched to the original `Codebook` for testing\r\n4. Added a significant number of additional tests to verify everything works. \r\n\r\nThe places to start are: \r\n1. `codebook.Codebook`: this class implements the codebook according to the spaceTx spec, including the ability to generate random codes, and decode `IntensityTables`\r\n2. `intensity_table.IntensityTable`: this class implements a 3-d tensor that holds intensities for each spot, channel, and hybridization round, including the ability to generate synthetic IntensityTables guided by a codebook\r\n3. `ImageStack.synthetic_spots`: this method constructs synthetic ImageStacks from IntensityTables\r\n\r\nAfter that, it makes sense to look at the `GaussianSpotDetector`. \r\n\r\nThe most important new tests are in `starfish/test/test_synthetic_data.py`, which take synthetic codebooks to spots to images, then detect the spots and decode them, verifying that everything matches. \r\n\r\nFor the sundry changes that litter other files, I've attempted to drop comments to explain why they were made. \r\n\r\nIn addition to the tests, the ISS Breast notebook generates identical results under the new framework. ","created_at":"2018-06-27T03:31:51Z","updated_at":"2018-07-11T23:48:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abe1faf94249f53a8a1b47450aaf13900e1f7be7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":613940759,"node_id":"MDU6TGFiZWw2MTM5NDA3NTk=","url":"https://api.github.com/repos/spacetx/starfish/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/spacetx/starfish/pulls/298/commits","review_comments_url":"https://api.github.com/repos/spacetx/starfish/pulls/298/comments","review_comment_url":"https://api.github.com/repos/spacetx/starfish/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spacetx/starfish/issues/298/comments","statuses_url":"https://api.github.com/repos/spacetx/starfish/statuses/5e1bf6152fa1de9afefc02bde4359ccf590b8c60","head":{"label":"spacetx:ajc-codebook-intensity-table","ref":"ajc-codebook-intensity-table","sha":"5e1bf6152fa1de9afefc02bde4359ccf590b8c60","user":{"login":"spacetx","id":37218549,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3MjE4NTQ5","avatar_url":"https://avatars0.githubusercontent.com/u/37218549?v=4","gravatar_id":"","url":"https://api.github.com/users/spacetx","html_url":"https://github.com/spacetx","followers_url":"https://api.github.com/users/spacetx/followers","following_url":"https://api.github.com/users/spacetx/following{/other_user}","gists_url":"https://api.github.com/users/spacetx/gists{/gist_id}","starred_url":"https://api.github.com/users/spacetx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spacetx/subscriptions","organizations_url":"https://api.github.com/users/spacetx/orgs","repos_url":"https://api.github.com/users/spacetx/repos","events_url":"https://api.github.com/users/spacetx/events{/privacy}","received_events_url":"https://api.github.com/users/spacetx/received_events","type":"Organization","site_admin":false},"repo":{"id":92539237,"node_id":"MDEwOlJlcG9zaXRvcnk5MjUzOTIzNw==","name":"starfish","full_name":"spacetx/starfish","owner":{"login":"spacetx","id":37218549,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3MjE4NTQ5","avatar_url":"https://avatars0.githubusercontent.com/u/37218549?v=4","gravatar_id":"","url":"https://api.github.com/users/spacetx","html_url":"https://github.com/spacetx","followers_url":"https://api.github.com/users/spacetx/followers","following_url":"https://api.github.com/users/spacetx/following{/other_user}","gists_url":"https://api.github.com/users/spacetx/gists{/gist_id}","starred_url":"https://api.github.com/users/spacetx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spacetx/subscriptions","organizations_url":"https://api.github.com/users/spacetx/orgs","repos_url":"https://api.github.com/users/spacetx/repos","events_url":"https://api.github.com/users/spacetx/events{/privacy}","received_events_url":"https://api.github.com/users/spacetx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spacetx/starfish","description":"*fish -- a standardized analysis pipeline for image-based transcriptomics","fork":false,"url":"https://api.github.com/repos/spacetx/starfish","forks_url":"https://api.github.com/repos/spacetx/starfish/forks","keys_url":"https://api.github.com/repos/spacetx/starfish/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spacetx/starfish/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spacetx/starfish/teams","hooks_url":"https://api.github.com/repos/spacetx/starfish/hooks","issue_events_url":"https://api.github.com/repos/spacetx/starfish/issues/events{/number}","events_url":"https://api.github.com/repos/spacetx/starfish/events","assignees_url":"https://api.github.com/repos/spacetx/starfish/assignees{/user}","branches_url":"https://api.github.com/repos/spacetx/starfish/branches{/branch}","tags_url":"https://api.github.com/repos/spacetx/starfish/tags","blobs_url":"https://api.github.com/repos/spacetx/starfish/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spacetx/starfish/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spacetx/starfish/git/refs{/sha}","trees_url":"https://api.github.com/repos/spacetx/starfish/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spacetx/starfish/statuses/{sha}","languages_url":"https://api.github.com/repos/spacetx/starfish/languages","stargazers_url":"https://api.github.com/repos/spacetx/starfish/stargazers","contributors_url":"https://api.github.com/repos/spacetx/starfish/contributors","subscribers_url":"https://api.github.com/repos/spacetx/starfish/subscribers","subscription_url":"https://api.github.com/repos/spacetx/starfish/subscription","commits_url":"https://api.github.com/repos/spacetx/starfish/commits{/sha}","git_commits_url":"https://api.github.com/repos/spacetx/starfish/git/commits{/sha}","comments_url":"https://api.github.com/repos/spacetx/starfish/comments{/number}","issue_comment_url":"https://api.github.com/repos/spacetx/starfish/issues/comments{/number}","contents_url":"https://api.github.com/repos/spacetx/starfish/contents/{+path}","compare_url":"https://api.github.com/repos/spacetx/starfish/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spacetx/starfish/merges","archive_url":"https://api.github.com/repos/spacetx/starfish/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spacetx/starfish/downloads","issues_url":"https://api.github.com/repos/spacetx/starfish/issues{/number}","pulls_url":"https://api.github.com/repos/spacetx/starfish/pulls{/number}","milestones_url":"https://api.github.com/repos/spacetx/starfish/milestones{/number}","notifications_url":"https://api.github.com/repos/spacetx/starfish/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spacetx/starfish/labels{/name}","releases_url":"https://api.github.com/repos/spacetx/starfish/releases{/id}","deployments_url":"https://api.github.com/repos/spacetx/starfish/deployments","created_at":"2017-05-26T18:45:11Z","updated_at":"2018-07-09T20:44:52Z","pushed_at":"2018-07-11T23:45:47Z","git_url":"git://github.com/spacetx/starfish.git","ssh_url":"git@github.com:spacetx/starfish.git","clone_url":"https://github.com/spacetx/starfish.git","svn_url":"https://github.com/spacetx/starfish","homepage":"","size":33666,"stargazers_count":34,"watchers_count":34,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":66,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":14,"open_issues":66,"watchers":34,"default_branch":"master"}},"base":{"label":"spacetx:master","ref":"master","sha":"02d40a0af98d424f61d00d94a7cdda865581a187","user":{"login":"spacetx","id":37218549,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3MjE4NTQ5","avatar_url":"https://avatars0.githubusercontent.com/u/37218549?v=4","gravatar_id":"","url":"https://api.github.com/users/spacetx","html_url":"https://github.com/spacetx","followers_url":"https://api.github.com/users/spacetx/followers","following_url":"https://api.github.com/users/spacetx/following{/other_user}","gists_url":"https://api.github.com/users/spacetx/gists{/gist_id}","starred_url":"https://api.github.com/users/spacetx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spacetx/subscriptions","organizations_url":"https://api.github.com/users/spacetx/orgs","repos_url":"https://api.github.com/users/spacetx/repos","events_url":"https://api.github.com/users/spacetx/events{/privacy}","received_events_url":"https://api.github.com/users/spacetx/received_events","type":"Organization","site_admin":false},"repo":{"id":92539237,"node_id":"MDEwOlJlcG9zaXRvcnk5MjUzOTIzNw==","name":"starfish","full_name":"spacetx/starfish","owner":{"login":"spacetx","id":37218549,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3MjE4NTQ5","avatar_url":"https://avatars0.githubusercontent.com/u/37218549?v=4","gravatar_id":"","url":"https://api.github.com/users/spacetx","html_url":"https://github.com/spacetx","followers_url":"https://api.github.com/users/spacetx/followers","following_url":"https://api.github.com/users/spacetx/following{/other_user}","gists_url":"https://api.github.com/users/spacetx/gists{/gist_id}","starred_url":"https://api.github.com/users/spacetx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spacetx/subscriptions","organizations_url":"https://api.github.com/users/spacetx/orgs","repos_url":"https://api.github.com/users/spacetx/repos","events_url":"https://api.github.com/users/spacetx/events{/privacy}","received_events_url":"https://api.github.com/users/spacetx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spacetx/starfish","description":"*fish -- a standardized analysis pipeline for image-based transcriptomics","fork":false,"url":"https://api.github.com/repos/spacetx/starfish","forks_url":"https://api.github.com/repos/spacetx/starfish/forks","keys_url":"https://api.github.com/repos/spacetx/starfish/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spacetx/starfish/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spacetx/starfish/teams","hooks_url":"https://api.github.com/repos/spacetx/starfish/hooks","issue_events_url":"https://api.github.com/repos/spacetx/starfish/issues/events{/number}","events_url":"https://api.github.com/repos/spacetx/starfish/events","assignees_url":"https://api.github.com/repos/spacetx/starfish/assignees{/user}","branches_url":"https://api.github.com/repos/spacetx/starfish/branches{/branch}","tags_url":"https://api.github.com/repos/spacetx/starfish/tags","blobs_url":"https://api.github.com/repos/spacetx/starfish/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spacetx/starfish/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spacetx/starfish/git/refs{/sha}","trees_url":"https://api.github.com/repos/spacetx/starfish/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spacetx/starfish/statuses/{sha}","languages_url":"https://api.github.com/repos/spacetx/starfish/languages","stargazers_url":"https://api.github.com/repos/spacetx/starfish/stargazers","contributors_url":"https://api.github.com/repos/spacetx/starfish/contributors","subscribers_url":"https://api.github.com/repos/spacetx/starfish/subscribers","subscription_url":"https://api.github.com/repos/spacetx/starfish/subscription","commits_url":"https://api.github.com/repos/spacetx/starfish/commits{/sha}","git_commits_url":"https://api.github.com/repos/spacetx/starfish/git/commits{/sha}","comments_url":"https://api.github.com/repos/spacetx/starfish/comments{/number}","issue_comment_url":"https://api.github.com/repos/spacetx/starfish/issues/comments{/number}","contents_url":"https://api.github.com/repos/spacetx/starfish/contents/{+path}","compare_url":"https://api.github.com/repos/spacetx/starfish/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spacetx/starfish/merges","archive_url":"https://api.github.com/repos/spacetx/starfish/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spacetx/starfish/downloads","issues_url":"https://api.github.com/repos/spacetx/starfish/issues{/number}","pulls_url":"https://api.github.com/repos/spacetx/starfish/pulls{/number}","milestones_url":"https://api.github.com/repos/spacetx/starfish/milestones{/number}","notifications_url":"https://api.github.com/repos/spacetx/starfish/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spacetx/starfish/labels{/name}","releases_url":"https://api.github.com/repos/spacetx/starfish/releases{/id}","deployments_url":"https://api.github.com/repos/spacetx/starfish/deployments","created_at":"2017-05-26T18:45:11Z","updated_at":"2018-07-09T20:44:52Z","pushed_at":"2018-07-11T23:45:47Z","git_url":"git://github.com/spacetx/starfish.git","ssh_url":"git@github.com:spacetx/starfish.git","clone_url":"https://github.com/spacetx/starfish.git","svn_url":"https://github.com/spacetx/starfish","homepage":"","size":33666,"stargazers_count":34,"watchers_count":34,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":66,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":14,"open_issues":66,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spacetx/starfish/pulls/298"},"html":{"href":"https://github.com/spacetx/starfish/pull/298"},"issue":{"href":"https://api.github.com/repos/spacetx/starfish/issues/298"},"comments":{"href":"https://api.github.com/repos/spacetx/starfish/issues/298/comments"},"review_comments":{"href":"https://api.github.com/repos/spacetx/starfish/pulls/298/comments"},"review_comment":{"href":"https://api.github.com/repos/spacetx/starfish/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spacetx/starfish/pulls/298/commits"},"statuses":{"href":"https://api.github.com/repos/spacetx/starfish/statuses/5e1bf6152fa1de9afefc02bde4359ccf590b8c60"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ambrosejcarr"}}