Skip to content

Commit

Permalink
BUG: Fix incorrect usage of self.maskArray
Browse files Browse the repository at this point in the history
In full-python calculation of the GLDM matrix, calculation would fail when label != 1. Update GLDM to also work with different mask values.

Fix an additional bug in testUtils, where the Label value stored in the baseline was not passed to the checkMask function when loading a test case.
  • Loading branch information
JoostJM committed Oct 24, 2017
1 parent 7535f8d commit 5d57e73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions radiomics/gldm.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _calculateMatrix(self):

# Set voxels outside delineation to padding value
padVal = numpy.nan
self.matrix[(self.maskArray != self.label)] = padVal
self.matrix[~self.maskArray] = padVal

angles = imageoperations.generateAngles(self.boundingBoxSize, **self.kwargs)
angles = numpy.concatenate((angles, angles * -1))
Expand Down Expand Up @@ -109,7 +109,7 @@ def _calculateMatrix(self):
depMat[~nanMask] += (numpy.abs(angMat[~nanMask]) <= self.gldm_a)

grayLevels = self.coefficients['grayLevels']
dependenceSizes = numpy.unique(depMat[self.labelledVoxelCoordinates])
dependenceSizes = numpy.unique(depMat[self.maskArray])
P_gldm = numpy.zeros((len(grayLevels), len(dependenceSizes)))

with self.progressReporter(grayLevels, desc='calculate GLDM') as bar:
Expand Down
2 changes: 1 addition & 1 deletion tests/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class or test case is changed, function returns True.
interpolator,
self._kwargs.get('label', 1),
self._kwargs.get('padDistance', 5))
bb, correctedMask = imageoperations.checkMask(self._image, self._mask)
bb, correctedMask = imageoperations.checkMask(self._image, self._mask, **self._kwargs)
if correctedMask is not None:
self._mask = correctedMask
self._image, self._mask = imageoperations.cropToTumorMask(self._image, self._mask, bb)
Expand Down

0 comments on commit 5d57e73

Please sign in to comment.