Skip to content

Commit

Permalink
Do not filter by SOPClassUID
Browse files Browse the repository at this point in the history
Google Healthcare API, used by Imaging Data Commons, does not allow
filtering by SOPClassUID. So we cannot use that in the search filter.
We should think of alternatives so that we can include only WSI results.

These changes were needed alongside [this wsidicom PR](imi-bigpicture/wsidicom#149)
in order to view an example dataset.

The following were used for testing:

url = 'https://proxy.imaging.datacommons.cancer.gov/current/viewer-only-no-downloads-see-tinyurl-dot-com-slash-3j3d9jyp/dicomWeb'
study_uid = '2.25.25644321580420796312527343668921514374'
series_uid = '1.3.6.1.4.1.5962.99.1.3205815762.381594633.1639588388306.2.0'

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Jan 30, 2024
1 parent 0e16843 commit 0ba188b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ def importData(self, parent, parentType, params, progress, user, **kwargs):
msg = f'Invalid parent type: {parentType}'
raise RuntimeError(msg)

from wsidicom.uid import WSI_SOP_CLASS_UID
# FIXME: Imaging Data Commons will not allow us to filter by SOPClassUID.
# Is there any other way to filter out non-WSI results?
# from wsidicom.uid import WSI_SOP_CLASS_UID

limit = params.get('limit')
search_filters = params.get('search_filters', {})
Expand All @@ -346,12 +348,9 @@ def importData(self, parent, parentType, params, progress, user, **kwargs):
series_uid_key = dicom_key_to_tag('SeriesInstanceUID')
instance_uid_key = dicom_key_to_tag('SOPInstanceUID')

# We are only searching for WSI datasets. Ignore all others.
# FIXME: is this actually working? For the SLIM server at
# https://imagingdatacommons.github.io/slim/, none of the series
# report a SOPClassUID, but we still get all results anyways.
search_filters = {
'SOPClassUID': WSI_SOP_CLASS_UID,
# See FIXME above
# 'SOPClassUID': WSI_SOP_CLASS_UID,
**search_filters,
}
fields = [
Expand Down
15 changes: 11 additions & 4 deletions sources/dicom/large_image_source_dicom/dicomweb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,25 @@ def get_first_wsi_volume_metadata(client, study_uid, series_uid):
image_type_tag = dicom_key_to_tag('ImageType')
instance_uid_tag = dicom_key_to_tag('SOPInstanceUID')

search_filters = {
'SOPClassUID': WSI_SOP_CLASS_UID,
}
# We can't include the SOPClassUID as a search filter because Imaging Data Commons
# produces an error if we do. Perform the filtering manually instead.
class_uid_tag = dicom_key_to_tag('SOPClassUID')

fields = [
image_type_tag,
instance_uid_tag,
class_uid_tag,
]
wsi_instances = client.search_for_instances(
study_uid, series_uid, search_filters=search_filters, fields=fields)
study_uid, series_uid, fields=fields)

volume_instance = None
for instance in wsi_instances:
class_type = instance.get(class_uid_tag, {}).get('Value')
if not class_type or class_type[0] != WSI_SOP_CLASS_UID:
# Only look at WSI classes
continue

image_type = instance.get(image_type_tag, {}).get('Value')
# It would be nice if we could have a search filter for this, but
# I didn't see one...
Expand Down

0 comments on commit 0ba188b

Please sign in to comment.