dicomtrolley.rad69¶
Retrieve data from servers using the rad69 protocol
see [rad69 document set] (https://gazelle.ihe.net/content/rad-69-retrieve-imaging-document-set) And the corresponding [transaction] (https://profiles.ihe.net/ITI/TF/Volume2/ITI-43.html)
Rad69
¶
Bases: Downloader
A connection to a Rad69 server
Source code in dicomtrolley/rad69.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
__init__(session, url, request_per_series=True, errors_to_ignore=None, use_async=False, max_workers=4)
¶
Parameters¶
session: requests.session A logged in session over which rad69 calls can be made url: str rad69 endpoint, including protocol and port. Like https://server:2525/rids request_per_series: bool, optional If true, split rad69 requests per series when downloading. If false, request all instances at once. Splitting reduces load on server. defaults to True. errors_to_ignore: List[Type], optional Errors of this type encountered during download are caught and skipped. Defaults to empty list, meaning any error is propagated use_async: bool, optional If True, download will split instances into chunks and download each chunk in a separate thread. If False, use single thread Defaults to False max_workers: int, optional Only used of use_async=True. Number of workers to use for multi-threading
Source code in dicomtrolley/rad69.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
check_for_response_errors(response)
staticmethod
¶
Raise exceptions if this response is not a multi-part rad69 soap response.
Parameters¶
response: response response as returned from a rad69 call
Raises¶
DICOMTrolleyError If response is not as expected
Source code in dicomtrolley/rad69.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
create_instance_request(instance)
¶
Create the SOAP xml structure needed to request an instance from a rad69 server
Source code in dicomtrolley/rad69.py
229 230 231 232 233 | |
create_instances_request(instances)
¶
Create the SOAP xml structure to request all given instances from server
Source code in dicomtrolley/rad69.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
datasets(objects)
¶
Retrieve all instances via rad69
A Rad69 request typically contains multiple instances. The data for all instances is then streamed back as one multipart http response
Raises¶
NonInstanceParameterError If objects contain non-instance targets like a StudyInstanceUID. Rad69 can only download instances
Returns¶
Iterator[Dataset, None, None]
Source code in dicomtrolley/rad69.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
datasets_async(objects, max_workers)
¶
Split instances into chunks and retrieve each chunk in separate thread
Parameters¶
objects: Sequence[DICOMDownloadable] Retrieve dataset for each instance in these objects max_workers: int Use this number of workers in ThreadPoolExecutor. Defaults to default for ThreadPoolExecutor
Notes¶
rad69 allows any number of slices to be combined in one request. The response is a chunked multi-part http response with all image data. Requesting each slice individually is inefficient. Requesting all slices in one thread might limit speed. Somewhere in the middle seems the best bet for optimal speed. This function splits all instances between the available workers and lets workers process the response streams.
Raises¶
DICOMTrolleyError When a server response cannot be parsed as DICOM
Returns¶
Iterator[Dataset, None, None]
Source code in dicomtrolley/rad69.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
datasets_single_thread(objects)
¶
Retrieve all instances via rad69, without async
A Rad69 request typically contains multiple instances. The data for all instances is then streamed back as one multipart http response
Raises¶
NonInstanceParameterError If objects contain non-instance targets like a StudyInstanceUID. Rad69 can only download instances
Returns¶
Iterator[Dataset, None, None]
Source code in dicomtrolley/rad69.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
download_iterator(instances)
¶
Perform a rad69 request and iterate over the returned datasets
Returns¶
Iterator[Dataset, None, None] All datasets included in the response
Source code in dicomtrolley/rad69.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
get_dataset(instance)
¶
Get DICOM dataset for the given instance (slice)
Raises¶
DICOMTrolleyError If getting does not work for some reason
Note¶
Getting single datasets is not efficient in rad69. If you want to loop this function, use Rad69.datasets() instead
Returns¶
Dataset A pydicom dataset
Source code in dicomtrolley/rad69.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
handle_response_error(error)
¶
Handle exceptions raised during rad69 request or download
Source code in dicomtrolley/rad69.py
396 397 398 399 400 401 402 | |
parse_rad69_response(response)
¶
Extract datasets out of http response from a rad69 server
Raises¶
DICOMTrolleyError If response is not as expected or if parsing fails
Returns¶
Iterator[Dataset, None, None] All datasets included in this response
Source code in dicomtrolley/rad69.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
parse_rad69_soap_error_response(response)
staticmethod
¶
Interpret response as rad69 error, raise more helpful exceptions
Raises¶
XDSMissingDocumentError: If data for any requested id could not be found Rad69ServerError For any unspecified but valid rad69 error response DICOMTrolleyError if this is not a valid rad69 error response.
Notes¶
This just pragmatically interprets the first error returned and assumes the rest are the same. Not quite right but let's not overdo it.
Source code in dicomtrolley/rad69.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
series_download_iterator(instances, index=0)
¶
Identical to create_download_iterator, except adds a debug log call
Source code in dicomtrolley/rad69.py
202 203 204 205 206 207 208 209 210 | |
split_instances(instances, num_bins)
staticmethod
¶
Split the given instance references into even piles
Source code in dicomtrolley/rad69.py
404 405 406 407 408 409 | |
verify_response(response)
¶
Check for errors in rad69 response and handle them
Source code in dicomtrolley/rad69.py
284 285 | |
Rad69ServerError
¶
Bases: DICOMTrolleyError
Represents a valid error response from a rad69 server
Source code in dicomtrolley/rad69.py
412 413 414 415 | |
XDSMissingDocumentError
¶
Bases: Rad69ServerError
Some requested ID could not be found on the server
Source code in dicomtrolley/rad69.py
418 419 420 421 | |