imi-bigpicture / wsidicom

Python package for reading DICOM WSI file sets.
Apache License 2.0
33 stars 5 forks source link

`file_meta` unavailable for instance from DICOMweb #125

Closed psavery closed 10 months ago

psavery commented 10 months ago

For one of my examples, I am encountering the following error:

  File "/opt/wsidicom/wsidicom/wsidicom.py", line 153, in open_web
    source = WsiDicomWebSource(
  File "/opt/wsidicom/wsidicom/web/wsidicom_web_source.py", line 97, in __init__
    annotation_instance = AnnotationInstance.open_dataset(instance)
  File "/opt/wsidicom/wsidicom/graphical_annotations.py", line 1688, in open_dataset
    if dataset.file_meta.MediaStorageSOPClassUID != ANN_SOP_CLASS_UID:
  File "/opt/venv/lib/python3.9/site-packages/pydicom/dataset.py", line 907, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Dataset' object has no attribute 'file_meta'

Is the file_meta attribute unavailable for instances obtained via DICOMweb?

Here is a reproducer of the issue:

from dicomweb_client import DICOMwebClient
from pydicom.datadict import tag_for_keyword
from pydicom.tag import Tag
from wsidicom import WsiDicom, WsiDicomWebClient

url = 'https://idc-external-006.uc.r.appspot.com/dcm4chee-arc/aets/DCM4CHEE/rs'
study_uid = '2.25.18199272949575141157802058345697568861'
series_uid_tag = Tag(tag_for_keyword('SeriesInstanceUID')).json_key

client = DICOMwebClient(url)
series = client.search_for_series(study_uid)
series_uids = [x[series_uid_tag]['Value'][0] for x in series]

wsi_client = WsiDicomWebClient(client)
slide = WsiDicom.open_web(
    wsi_client,
    study_uid,
    series_uids,
)
erikogabrielsson commented 10 months ago

I have also observed this bug. An dataset fetch from dicom web is not expected to have the file_meta property. So the check should be removed from the annotation class.

erikogabrielsson commented 10 months ago

I removed this check in the Decoder-development branch

erikogabrielsson commented 10 months ago

Fixed by #126