Skip to content

Commit

Permalink
let dicomweb-client handle pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
vanossj committed Aug 30, 2022
1 parent 3cb3041 commit 0696ec6
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions DICOMwebBrowser/DICOMwebBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def setup(self):
# Ensure that correct version of dicomweb-clien Python package is installed
needRestart = False
needInstall = False
minimumDicomwebClientVersion = "0.51"
minimumDicomwebClientVersion = "0.57"
try:
import dicomweb_client
from packaging import version
Expand Down Expand Up @@ -573,19 +573,7 @@ def connectToServer(self):
else:
try:
# Get all studies
studies = []
offset = 0

while True:
subset = self.DICOMwebClient.search_for_studies(offset=offset)
if len(subset) == 0:
break
if subset[0] in studies:
# got the same study twice, so probably this server does not respect offset,
# therefore we cannot do paging
break
studies.extend(subset)
offset += len(subset)
studies = self.DICOMwebClient.search_for_studies(get_remaining=True)

# Save to cache
with open(cacheFile, 'w') as f:
Expand Down Expand Up @@ -631,7 +619,7 @@ def studySelected(self, row):

else:
try:
series = self.DICOMwebClient.search_for_series(self.selectedStudyInstanceUID)
series = self.DICOMwebClient.search_for_series(self.selectedStudyInstanceUID, get_remaining=True)
# Save to cache
with open(cacheFile, 'w') as f:
json.dump(series, f)
Expand Down Expand Up @@ -800,7 +788,8 @@ def downloadSelectedSeries(self):
#response = self.DICOMwebClient.get_image(seriesInstanceUid=selectedSeries)
instances = self.DICOMwebClient.search_for_instances(
study_instance_uid=selectedStudy,
series_instance_uid=selectedSeries
series_instance_uid=selectedSeries,
get_remaining=True
)
self.progressMessage = "Retrieving data from server"
logging.debug("Retrieving data from server")
Expand Down

0 comments on commit 0696ec6

Please sign in to comment.