deepliif 1.2.4__py3-none-any.whl → 1.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
deepliif/util/__init__.py CHANGED
@@ -558,8 +558,8 @@ def get_information(filename):
558
558
 
559
559
  class WSIReader:
560
560
  """
561
- Assumes the file is a single image (e.g., not a stacked
562
- OME TIFF) and will always return uint8 pixel type data.
561
+ Assumes the file is a single RGB image (e.g., not a stacked OME TIFF).
562
+ This reader will always return the data with pixel type of uint8.
563
563
  """
564
564
 
565
565
  def __init__(self, path):
@@ -568,6 +568,7 @@ class WSIReader:
568
568
  omexml = bioformats.OMEXML(metadata)
569
569
 
570
570
  self._path = path
571
+ self._metadata = metadata
571
572
  self._width = omexml.image().Pixels.SizeX
572
573
  self._height = omexml.image().Pixels.SizeY
573
574
  self._pixel_type = omexml.image().Pixels.PixelType
@@ -614,17 +615,79 @@ class WSIReader:
614
615
  def height(self):
615
616
  return self._height
616
617
 
617
- def read(self, xywh):
618
+ def read(self, xywh, zeros_on_error=False):
619
+ x, y, w, h = xywh
620
+
618
621
  if self._tif is not None:
619
- x, y, w, h = xywh
620
622
  try:
621
623
  return self._zarr[y:y+h, x:x+w]
622
624
  except Exception as e:
623
625
  pass
624
626
 
625
- px = self._bfreader.read(XYWH=xywh, rescale=self._rescale)
626
- if self._rescale:
627
- px = (px * 255).astype(np.uint8)
627
+ try:
628
+ px = self._bfreader.read(XYWH=xywh, rescale=self._rescale)
629
+ if self._rescale:
630
+ px = (px * 255).astype(np.uint8)
631
+ return px
632
+ except Exception as e:
633
+ if not zeros_on_error:
634
+ return self._read_region_by_tiles(xywh)
635
+
636
+ return np.zeros((h, w, 3), dtype=np.uint8)
637
+
638
+ def _read_region_by_tiles(self, xywh):
639
+ tile_width, tile_height = None, None
640
+
641
+ try:
642
+ if self._tif is not None and self._tif.pages[0].is_tiled:
643
+ tile_width = self._tif.pages[0].tilewidth
644
+ tile_height = self._tif.pages[0].tilelength
645
+ else:
646
+ root = et.fromstring(self._metadata.encode('utf-8'))
647
+ for origmeta in root.findall('.//{http://www.openmicroscopy.org/Schemas/OME/2016-06}OriginalMetadata'):
648
+ key, value = None, None
649
+ for om in origmeta:
650
+ if 'Key' in om.tag:
651
+ key = om.text
652
+ elif 'Value' in om.tag:
653
+ value = om.text
654
+ if key == 'TileWidth' and value is not None:
655
+ tile_width = int(value)
656
+ elif key == 'TileLength' and value is not None:
657
+ tile_height = int(value)
658
+ except Exception as e:
659
+ pass
660
+
661
+ if tile_width is None or tile_height is None:
662
+ tile_width, tile_height = 512, 512
663
+
664
+ x0, y0, w, h = xywh
665
+ w0 = x0 % tile_width
666
+ h0 = y0 % tile_height
667
+ x1 = x0 + w0
668
+ y1 = y0 + h0
669
+
670
+ px = np.zeros((h, w, 3), dtype=np.uint8)
671
+ tile = self.read((x0, y0, w0, h0), True)
672
+ px[0:h0, 0:w0] = tile
673
+
674
+ for x in range(x1, x0+w, tile_width):
675
+ tw = min(tile_width, x0+w-x)
676
+ tile = self.read((x, y0, tw, h0), True)
677
+ px[0:h0, x-x0:x-x0+tw] = tile
678
+
679
+ for y in range(y1, y0+h, tile_height):
680
+ th = min(tile_height, y0+h-y)
681
+ tile = self.read((x0, y, w0, th), True)
682
+ px[y-y0:y-y0+th, 0:w0] = tile
683
+
684
+ for y in range(y1, y0+h, tile_height):
685
+ for x in range(x1, x0+w, tile_width):
686
+ tw = min(tile_width, x0+w-x)
687
+ th = min(tile_height, y0+h-y)
688
+ tile = self.read((x, y, tw, th), True)
689
+ px[y-y0:y-y0+th, x-x0:x-x0+tw] = tile
690
+
628
691
  return px
629
692
 
630
693
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: deepliif
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: DeepLIIF: Deep-Learning Inferred Multiplex Immunofluorescence for Immunohistochemical Image Quantification
5
5
  Home-page: https://github.com/nadeemlab/DeepLIIF
6
6
  Author: Parmida93
@@ -66,7 +66,7 @@ segmentation.*
66
66
 
67
67
  © This code is made available for non-commercial academic purposes.
68
68
 
69
- ![Version](https://img.shields.io/static/v1?label=latest&message=v1.2.4&color=darkgreen)
69
+ ![Version](https://img.shields.io/static/v1?label=latest&message=v1.2.5&color=darkgreen)
70
70
  [![Total Downloads](https://static.pepy.tech/personalized-badge/deepliif?period=total&units=international_system&left_color=grey&right_color=blue&left_text=total%20downloads)](https://pepy.tech/project/deepliif?&left_text=totalusers)
71
71
 
72
72
  ![overview_image](./images/overview.png)*Overview of DeepLIIF pipeline and sample input IHCs (different
@@ -23,16 +23,16 @@ deepliif/options/base_options.py,sha256=m5UXY8MvjNcDisUWuiP228yoT27SsCh1bXS_Td6S
23
23
  deepliif/options/processing_options.py,sha256=OnNT-ytoTQzetFiMEKrWvrsrhZlupRK4smcnIk0MbqY,2947
24
24
  deepliif/options/test_options.py,sha256=4ZbQC5U-nTbUz8jvdDIbse5TK_mjw4D5yNjpVevWD5M,1114
25
25
  deepliif/options/train_options.py,sha256=5eA_oxpRj2-HiuMMvC5-HLapxNFG_JXOQ3K132JjpR8,3580
26
- deepliif/util/__init__.py,sha256=iqC3FvU7QDHdChZtf-nAaUzO61y02a7BiDmxpL679tc,35302
26
+ deepliif/util/__init__.py,sha256=6grD2DvrLXSeNpPkfs3BOtxq-4CEvNWkQWX_VdWpMBY,37728
27
27
  deepliif/util/checks.py,sha256=xQirKbZxZErsAXc27M5miQUUyxptoIEJSDaUKv1nY7c,1371
28
28
  deepliif/util/get_data.py,sha256=HaRoQYb2u0LUgLT7ES-w35AmJ4BrlBEJWU4Cok29pxI,3749
29
29
  deepliif/util/html.py,sha256=RNAONZ4opP-bViahgmpSbHwOc6jXKQRnWRAVIaeIvac,3309
30
30
  deepliif/util/image_pool.py,sha256=M89Hc7DblRWroNP71S9mAdRn7h3DrhPFPjqFxxZYSgw,2280
31
31
  deepliif/util/util.py,sha256=l7QsUL8gSMJSGH5-Nin6IsjPl9HTyaKk8Z5cd-yuPjs,11055
32
32
  deepliif/util/visualizer.py,sha256=BeRIEzbpx0YCn1_zFCtV1JHLMzyWed_nw65wiyKRlcc,20259
33
- deepliif-1.2.4.dist-info/LICENSE.md,sha256=HlZw_UPS6EtJimJ_Ci7xKh-S5Iubs0Z8y8E6EZ3ZNyE,956
34
- deepliif-1.2.4.dist-info/METADATA,sha256=dscN8jbrXPjEWzgs3q27L24ft2vqiDXiCcDoIKoN1Ac,35266
35
- deepliif-1.2.4.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
36
- deepliif-1.2.4.dist-info/entry_points.txt,sha256=f70-10j2q68o_rDlsE3hspnv4ejlDnXwwGZ9JJ-3yF4,37
37
- deepliif-1.2.4.dist-info/top_level.txt,sha256=vLDK5YKmDz08E7PywuvEjAo7dM5rnIpsjR4c0ubQCnc,13
38
- deepliif-1.2.4.dist-info/RECORD,,
33
+ deepliif-1.2.5.dist-info/LICENSE.md,sha256=HlZw_UPS6EtJimJ_Ci7xKh-S5Iubs0Z8y8E6EZ3ZNyE,956
34
+ deepliif-1.2.5.dist-info/METADATA,sha256=1DS0A1oAIuZA2wFSz4hA4d7bM8LOqMLC6n_KVXm02Jo,35266
35
+ deepliif-1.2.5.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
36
+ deepliif-1.2.5.dist-info/entry_points.txt,sha256=f70-10j2q68o_rDlsE3hspnv4ejlDnXwwGZ9JJ-3yF4,37
37
+ deepliif-1.2.5.dist-info/top_level.txt,sha256=vLDK5YKmDz08E7PywuvEjAo7dM5rnIpsjR4c0ubQCnc,13
38
+ deepliif-1.2.5.dist-info/RECORD,,