Skip to content

Commit

Permalink
Update WsiDicomWebClient init call
Browse files Browse the repository at this point in the history
As of the latest `wsidicom` release (0.13.0), the new `__init__` method
just takes a `requests.Session` object. The old `__init__` method was
moved to the class method `create_client()`. So we need to update
the way we initialize it.

In girder#1349, we are adding authentication where we create the DICOMwebClient
object ourselves, so go ahead and do that now to simplify that one.

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Nov 13, 2023
1 parent 799f653 commit db2de1b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions sources/dicom/large_image_source_dicom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from .dicom_tags import dicom_key_to_tag

dicomweb_client = None
pydicom = None
wsidicom = None

Expand All @@ -32,16 +33,19 @@ def _lazyImport():
module initialization because it is slow.
"""
global wsidicom
global dicomweb_client
global pydicom

if wsidicom is None:
try:
import dicomweb_client
import pydicom
import wsidicom
except ImportError:
msg = 'dicom modules not found.'
raise TileSourceError(msg)
warnings.filterwarnings('ignore', category=UserWarning, module='wsidicom')
warnings.filterwarnings('ignore', category=UserWarning, module='dicomweb_client')
warnings.filterwarnings('ignore', category=UserWarning, module='pydicom')


Expand Down Expand Up @@ -168,26 +172,24 @@ def _open_wsi_dicomweb(self, info):
study_uid = info['study_uid']
series_uid = info['series_uid']

# These are optional keys
qido_prefix = info.get('qido_prefix')
wado_prefix = info.get('wado_prefix')
auth = info.get('auth')

# Create the client
client = wsidicom.WsiDicomWebClient(
# Create the web client
client = dicomweb_client.DICOMwebClient(
url,
qido_prefix=qido_prefix,
wado_prefix=wado_prefix,
auth=auth,
# The following are optional keys
qido_url_prefix=info.get('qido_prefix'),
wado_url_prefix=info.get('wado_prefix'),
session=info.get('auth'),
)

wsidicom_client = wsidicom.WsiDicomWebClient(client)

# Identify the transfer syntax
transfer_syntax = self._identify_dicomweb_transfer_syntax(client,
study_uid,
series_uid)

# Open the WSI DICOMweb file
return wsidicom.WsiDicom.open_web(client, study_uid, series_uid,
return wsidicom.WsiDicom.open_web(wsidicom_client, study_uid, series_uid,
requested_transfer_syntax=transfer_syntax)

def _identify_dicomweb_transfer_syntax(self, client, study_uid, series_uid):
Expand Down

0 comments on commit db2de1b

Please sign in to comment.