Skip to content

Commit

Permalink
BUG: fix dicom subseries priorities (#4873)
Browse files Browse the repository at this point in the history
* BUG: fix dicom subseries priorities

This fix loads subseries if there's only one choice and
the there are geometry warnings detected on the full
series.

See: #4872

* BUG: rework confidence logic

Now, the all-files loadable will have a higher
priority by default than any of the subseries,
but it will have a lower confidence if it has
warnings and there is are subseries loadables
with no warnings.

* STYLE: improve scalar volume loadable naming

Avoid relying on loadables[0] and instead keep
an explicit pointer to allFilesLoadable.
  • Loading branch information
pieper committed Apr 21, 2020
1 parent a5afb74 commit 2fbf89c
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions Modules/Scripted/DICOMPlugins/DICOMScalarVolumePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ def examineFiles(self,files):
seriesName = self.defaultSeriesNodeName(seriesUID)

# default loadable includes all files for series
loadable = DICOMLoadable()
loadable.files = files
loadable.name = seriesName
loadable.tooltip = "%d files, first file: %s" % (len(loadable.files), loadable.files[0])
loadable.selected = True
allFilesLoadable = DICOMLoadable()
allFilesLoadable.files = files
allFilesLoadable.name = seriesName
allFilesLoadable.tooltip = "%d files, first file: %s" % (len(allFilesLoadable.files), allFilesLoadable.files[0])
allFilesLoadable.selected = True
# add it to the list of loadables later, if pixel data is available in at least one file

# make subseries volumes based on tag differences
Expand All @@ -189,7 +189,7 @@ def examineFiles(self,files):
#
subseriesFiles = {}
subseriesValues = {}
for file in loadable.files:
for file in allFilesLoadable.files:
# check for subseries values
for tag in subseriesTags:
value = slicer.dicomDatabase.fileValue(file,self.tags[tag])
Expand All @@ -205,7 +205,7 @@ def examineFiles(self,files):
loadables = []

# Pixel data is available, so add the default loadable to the output
loadables.append(loadable)
loadables.append(allFilesLoadable)

#
# second, for any tags that have more than one value, create a new
Expand All @@ -226,12 +226,6 @@ def examineFiles(self,files):
loadable.selected = False
loadables.append(loadable)

if subseriesCount == 1:
# only one kind of subseries, then it's probably correct
# so make them higher confidence than the default all-files version
for subseriesLoadable in loadables[1:]:
subseriesLoadable.confidence = .55

# remove any files from loadables that don't have pixel data (no point sending them to ITK for reading)
# also remove DICOM SEG, since it is not handled by ITK readers
newLoadables = []
Expand Down Expand Up @@ -264,10 +258,19 @@ def examineFiles(self,files):
#
# now for each series and subseries, sort the images
# by position and check for consistency
# then adjust confidence values based on warnings
#
for loadable in loadables:
loadable.files, distances, loadable.warning = DICOMUtils.getSortedImageFiles(loadable.files, self.epsilon)

if subseriesCount == 1 and allFilesLoadable.warning != "":
# there was a sorting warning and
# only one kind of subseries, so it's probably correct
# to have lower confidence in the default all-files version
for loadable in loadables:
if loadable != allFilesLoadable and loadable.warning == "":
allFilesLoadable.confidence = .45

return loadables

def seriesSorter(self,x,y):
Expand Down

0 comments on commit 2fbf89c

Please sign in to comment.