ez_wsi_dicomweb/dicom_slide.py [1657:1714]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  def _filter_dicom_object(
      self,
      instance: dicom_web_interface.DicomObject,
      slide_instances_uid_set: set[str],
      filter_by_annotation_iod: Optional[str],
      filter_by_operator_id: Optional[str],
  ) -> bool:
    """Filters instances by annotation IOD, referenced series UID, and operator ID."""

    ds = pydicom.Dataset.from_json(instance.dicom_tags)

    # Filter by provided IOD.
    if filter_by_annotation_iod and ds.SOPClassUID != filter_by_annotation_iod:
      return False

    # Check if instance is referencing the slide's series or one if its
    # instances.
    reference_found = False

    if ds.SeriesInstanceUID == self.path.series_uid:
      reference_found = True

    try:
      # https://dicom.innolitics.com/ciods/vl-whole-slide-microscopy-image/common-instance-reference/00081115/0020000e
      if (
          not reference_found
          and ds.ReferencedSeriesSequence[0].SeriesInstanceUID
          == self.path.series_uid
      ):
        reference_found = True
    except AttributeError:
      pass
    try:
      # https://dicom.innolitics.com/ciods/microscopy-bulk-simple-annotations/microscopy-bulk-simple-annotations/00081140/00081155
      if (
          not reference_found
          and ds.ReferencedImageSequence[0].ReferencedSOPInstanceUID
          in slide_instances_uid_set
      ):
        reference_found = True
    except AttributeError:
      pass

    if not reference_found:
      return False

    # Filter by operator ID.
    try:
      if not filter_by_operator_id:
        return True
      for code in ds.OperatorIdentificationSequence:
        for code in code.PersonIdentificationCodeSequence:
          if code.LongCodeValue == filter_by_operator_id:
            return True
    except AttributeError:
      pass

    return False
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



ez_wsi_dicomweb/dicom_slide.py [2197:2254]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  def _filter_dicom_object(
      self,
      instance: dicom_web_interface.DicomObject,
      slide_instances_uid_set: set[str],
      filter_by_annotation_iod: Optional[str],
      filter_by_operator_id: Optional[str],
  ) -> bool:
    """Filters instances by annotation IOD, referenced series UID, and operator ID."""

    ds = pydicom.Dataset.from_json(instance.dicom_tags)

    # Filter by provided IOD.
    if filter_by_annotation_iod and ds.SOPClassUID != filter_by_annotation_iod:
      return False

    # Check if instance is referencing the slide's series or one if its
    # instances.
    reference_found = False

    if ds.SeriesInstanceUID == self.path.series_uid:
      reference_found = True

    try:
      # https://dicom.innolitics.com/ciods/vl-whole-slide-microscopy-image/common-instance-reference/00081115/0020000e
      if (
          not reference_found
          and ds.ReferencedSeriesSequence[0].SeriesInstanceUID
          == self.path.series_uid
      ):
        reference_found = True
    except AttributeError:
      pass
    try:
      # https://dicom.innolitics.com/ciods/microscopy-bulk-simple-annotations/microscopy-bulk-simple-annotations/00081140/00081155
      if (
          not reference_found
          and ds.ReferencedImageSequence[0].ReferencedSOPInstanceUID
          in slide_instances_uid_set
      ):
        reference_found = True
    except AttributeError:
      pass

    if not reference_found:
      return False

    # Filter by operator ID.
    try:
      if not filter_by_operator_id:
        return True
      for code in ds.OperatorIdentificationSequence:
        for code in code.PersonIdentificationCodeSequence:
          if code.LongCodeValue == filter_by_operator_id:
            return True
    except AttributeError:
      pass

    return False
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



