|
8 | 8 | [DICOM part18 section 10.4] |
9 | 9 | (https://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_10.4.html) |
10 | 10 |
|
11 | | -Notes |
12 | | ------ |
13 | | -Models only the parts of WADO-RS directly related to downloading DICOM image data. |
14 | | -WADO-RS also supports downloading metadata and rendered images, but these are |
15 | | -outside the scope of the dicomtrolley project. |
16 | | -
|
17 | | -Specifically, from DICOM PS3.18 section 10.4 |
18 | | -
|
19 | | -Download supported by dicomtrolley: |
20 | | -
|
21 | | -* Instance resources (download all instances) |
22 | | -
|
23 | | -Download Not Supported by dicomtrolley: |
24 | | -
|
25 | | -* Metadata resources |
26 | | -
|
27 | | -* Rendered resources |
28 | | -
|
29 | | -* Thumbnail resources |
30 | | -
|
31 | | -* Bulkdata resources |
32 | | -
|
33 | | -* Pixel Data resources |
34 | | -
|
35 | 11 | """ |
36 | 12 | import json |
37 | 13 | from itertools import chain |
|
58 | 34 |
|
59 | 35 |
|
60 | 36 | class WadoRS(Downloader): |
61 | | - """A connection to a WADO-RS server""" |
| 37 | + """A connection to a WADO-RS endpoints for downloading full datasets""" |
62 | 38 |
|
63 | 39 | def __init__( |
64 | 40 | self, session, url, http_chunk_size=5242880, request_per_series=True |
@@ -231,8 +207,42 @@ def wado_rs_instance_uri(self, reference: DICOMObjectReference): |
231 | 207 | ) |
232 | 208 |
|
233 | 209 |
|
234 | | -class WadoRSMetaData(WadoRS): |
235 | | - """A WADO-RS /metadata Downloader that downloads only metadata, no PixelData""" |
| 210 | +class WadoRSMetaData(Downloader): |
| 211 | + """A connection to WADO-RS to download only metadata, no PixelData""" |
| 212 | + |
| 213 | + def __init__(self, session, url): |
| 214 | + """ |
| 215 | + Parameters |
| 216 | + ---------- |
| 217 | + session: requests.session |
| 218 | + A logged-in session over which WADO calls can be made |
| 219 | + url: str |
| 220 | + WADO-RS endpoint, including protocol and port. Like |
| 221 | + https://server:8080/wado |
| 222 | + """ |
| 223 | + |
| 224 | + self.session = session |
| 225 | + self.url = url |
| 226 | + |
| 227 | + def datasets(self, objects: Sequence[DICOMDownloadable]): |
| 228 | + """Retrieve each instance |
| 229 | +
|
| 230 | + Returns |
| 231 | + ------- |
| 232 | + Iterator[Dataset, None, None] |
| 233 | +
|
| 234 | + Raises |
| 235 | + ------ |
| 236 | + DICOMTrolleyError |
| 237 | + If getting does not work for some reason |
| 238 | + """ |
| 239 | + logger.debug("Getting datasets") |
| 240 | + if isinstance(objects, DICOMDownloadable): |
| 241 | + objects = [objects] # handle passing single object instead of list |
| 242 | + |
| 243 | + return chain.from_iterable( |
| 244 | + self.download_iterator(obj) for obj in objects |
| 245 | + ) |
236 | 246 |
|
237 | 247 | def wado_rs_instance_uri(self, reference: DICOMObjectReference): |
238 | 248 | """WADO-RS URI to request all instances contained in referenced object""" |
|
0 commit comments