Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image/dicom-rle media type #92

Open
erikogabrielsson opened this issue Nov 22, 2023 · 0 comments
Open

image/dicom-rle media type #92

erikogabrielsson opened this issue Nov 22, 2023 · 0 comments

Comments

@erikogabrielsson
Copy link
Contributor

According to the standard image/dicom-rle should be used as media type for transfer syntax 1.2.840.10008.1.2.5 RLE Lossless. However DicomWebClient throws when using it as a media type when fetching frames:

url = 'https://idc-external-006.uc.r.appspot.com/dcm4chee-arc/aets/DCM4CHEE/rs'
dicomweb_client = DICOMwebClient(url)

dicomweb_client.retrieve_instance_frames(
    "1.3.6.1.4.1.5962.99.1.3456320082.756362073.1622659023442.3.0", 
    "1.3.6.1.4.1.5962.1.1.0.0.0.1595262375.18986.35", 
    "1.3.6.1.4.1.5962.99.1.3456320082.756362073.1622659023442.1478.0", 
    [1],
    ("image/dicom-rle",)
)

throws:

File [c:\Users\er-gac\.pyenv\pyenv-win\versions\3.11.2\Lib\site-packages\dicomweb_client\web.py:2961](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2961), in DICOMwebClient.retrieve_instance_frames(self, study_instance_uid, series_instance_uid, sop_instance_uid, frame_numbers, media_types)
   [2930](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2930) def retrieve_instance_frames(
   [2931](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2931)     self,
   [2932](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2932)     study_instance_uid: str,
   (...)
   [2936](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2936)     media_types: Optional[Tuple[Union[str, Tuple[str, str]], ...]] = None
   [2937](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2937) ) -> List[bytes]:
   [2938](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2938)     """Retrieve one or more frames of an image instance.
   [2939](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2939) 
   [2940](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2940)     Parameters
   (...)
   [2958](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2958) 
   [2959](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2959)     """  # noqa: E501
   [2960](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2960)     return list(
-> [2961](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2961)         self._get_instance_frames(
   [2962](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2962)             study_instance_uid=study_instance_uid,
   [2963](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2963)             series_instance_uid=series_instance_uid,
   [2964](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2964)             sop_instance_uid=sop_instance_uid,
   [2965](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2965)             frame_numbers=frame_numbers,
   [2966](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2966)             media_types=media_types,
   [2967](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2967)             stream=False
   [2968](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2968)         )
   [2969](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2969)     )

File [c:\Users\er-gac\.pyenv\pyenv-win\versions\3.11.2\Lib\site-packages\dicomweb_client\web.py:2907](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2907), in DICOMwebClient._get_instance_frames(self, study_instance_uid, series_instance_uid, sop_instance_uid, frame_numbers, media_types, stream)
   [2901](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2901)     return self._http_get_multipart_application_octet_stream(
   [2902](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2902)         url,
   [2903](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2903)         media_types=media_types,
   [2904](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2904)         stream=stream
   [2905](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2905)     )
   [2906](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2906) elif common_media_type.startswith('image'):
-> [2907](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2907)     return self._http_get_multipart_image(
   [2908](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2908)         url,
   [2909](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2909)         media_types=media_types,
   [2910](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2910)         stream=stream
   [2911](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2911)     )
   [2912](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2912) elif common_media_type.startswith('video'):
   [2913](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2913)     return self._http_get_multipart_video(
   [2914](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2914)         url,
   [2915](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2915)         media_types=media_types,
   [2916](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2916)         stream=stream
   [2917](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:2917)     )

File [c:\Users\er-gac\.pyenv\pyenv-win\versions\3.11.2\Lib\site-packages\dicomweb_client\web.py:1201](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1201), in DICOMwebClient._http_get_multipart_image(self, url, media_types, byte_range, params, stream)
   [1197](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1197) if byte_range is not None:
   [1198](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1198)     headers['Range'] = self._build_range_header_field_value(
   [1199](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1199)         byte_range
   [1200](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1200)     )
-> [1201](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1201) headers['Accept'] = self._build_multipart_accept_header_field_value(
   [1202](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1202)     media_types,
   [1203](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1203)     supported_media_types
   [1204](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1204) )
   [1205](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1205) response = self._http_get(
   [1206](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1206)     url,
   [1207](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1207)     params=params,
   [1208](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1208)     headers=headers,
   [1209](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1209)     stream=stream
   [1210](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1210) )
   [1211](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:1211) return self._decode_multipart_message(response, stream=stream)

File [c:\Users\er-gac\.pyenv\pyenv-win\versions\3.11.2\Lib\site-packages\dicomweb_client\web.py:901](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:901), in DICOMwebClient._build_multipart_accept_header_field_value(cls, media_types, supported_media_types)
    [898](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:898) if media_type not in supported_media_types.values():
    [899](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:899)     if not (media_type.endswith('/*') or
    [900](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:900)             media_type.endswith('/')):
--> [901](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:901)         raise ValueError(
    [902](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:902)             f'Media type "{media_type}" is not supported for '
    [903](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:903)             'requested resource.'
    [904](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:904)         )
    [905](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:905) if transfer_syntax_uid is not None:
    [906](file:///C:/Users/er-gac/.pyenv/pyenv-win/versions/3.11.2/Lib/site-packages/dicomweb_client/web.py:906)     if transfer_syntax_uid != '*':

ValueError: Media type "image/dicom-rle" is not supported for requested resource.

Not that I expect the frame to be available in RLE, but the expected error would be:

HTTPError: 406 Client Error: Not Acceptable for url: https://idc-external-006.uc.r.appspot.com/dcm4chee-arc/aets/DCM4CHEE/rs/studies/1.3.6.1.4.1.5962.99.1.3456320082.756362073.1622659023442.3.0/series/1.3.6.1.4.1.5962.1.1.0.0.0.1595262375.18986.35/instances/1.3.6.1.4.1.5962.99.1.3456320082.756362073.1622659023442.1478.0/frames/1

as I get if I change to media type image/x-dicom-rle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant