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 `DICOMwebClient` 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 3cf9860
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 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,30 +172,28 @@ 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):
# "client" is a wsidicom.WsiDicomWebClient
# "client" is a DICOMwebClient

# This is how we select the JPEG type to return
# The available transfer syntaxes used by wsidicom may be found here:
Expand All @@ -211,7 +213,7 @@ def _identify_dicomweb_transfer_syntax(self, client, study_uid, series_uid):

# Access the dicom web client, and search for one instance for the given
# study and series. Check the available transfer syntaxes.
result, = client._client.search_for_instances(
result, = client.search_for_instances(
study_uid, series_uid,
fields=[available_transfer_syntax_tag], limit=1)

Expand Down

0 comments on commit 3cf9860

Please sign in to comment.