def mag_scaled_embedding_patch_count()

in ez_wsi_dicomweb/patch_embedding_types.py [0:0]


  def mag_scaled_embedding_patch_count(self) -> int:
    """Returns number of patch request count. Scales count by downsamping mag.

    Pete endpoint limits total patch requests and scales DICOM patch requests by
    magnification to estimate backend load. Perform similar scaling here to
    keep client and server in sync.

    Returns:
      request count size for patch.
    """
    patch = self.patch
    if not isinstance(patch, dicom_slide.DicomPatch):
      return 1
    if not isinstance(patch.level, slide_level_map.ResizedLevel):
      return 1
    resize_level = patch.level
    source_level = resize_level.source_level
    patch_count_scale_factor = math.ceil(max(resize_level.scale_factors())) ** 2
    return min(patch_count_scale_factor, source_level.number_of_frames)