Skip to content

Commit

Permalink
sparse image
Browse files Browse the repository at this point in the history
  • Loading branch information
dalessioluca committed Mar 18, 2022
1 parent efcdbb0 commit 307954f
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/tissue_purifier/data/sparse_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,30 @@ def raw_to_pixel(
y_pixel = (y_raw - self.origin[1]) / self._pixel_size
return x_pixel, y_pixel

@property
def category_to_channels(self) -> dict:
""" The mapping between categories and channels in the image. """
return self._categories_to_codes

@property
def channels_to_category(self) -> numpy.ndarray:
"""
The mapping between channels in the image and categories.
Note that a channel can represent more than one category.
For example CD+ and CD- cells can both be shown in channel 7.
In that case channels_to_category[7] -> "CD+_CD-".
"""
list_tmp = [None]*self.shape[-3]
for cat, ch in self._categories_to_codes.items():
if list_tmp[ch] is None:
list_tmp[ch] = str(cat)
else:
list_tmp[ch] = "{}_{}".format(list_tmp[ch], str(cat))
return numpy.array(list_tmp)

@property
def anndata(self) -> AnnData:
""" The anndata object used to create th:w
e image. Might be None. """
""" The anndata object used to create the image. Might be None. """
return self._anndata

@property
Expand Down

0 comments on commit 307954f

Please sign in to comment.