Skip to content

Commit

Permalink
ENH: Update calculation of RobustMeanAbsoluteDeviation
Browse files Browse the repository at this point in the history
Change the generation of the mask to prevent greater-than and lesser-than comparisons with NaN values.
  • Loading branch information
JoostJM committed Mar 22, 2019
1 parent decd8e1 commit a7bed1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions radiomics/firstorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,13 @@ def getRobustMeanAbsoluteDeviationFeatureValue(self):
prcnt10 = self.get10PercentileFeatureValue()
prcnt90 = self.get90PercentileFeatureValue()
percentileArray = self.targetVoxelArray.copy()
percentileArray[percentileArray - prcnt10[:, None] < 0] = numpy.nan
percentileArray[percentileArray - prcnt90[:, None] > 0] = numpy.nan

# First get a mask for all valid voxels
msk = ~numpy.isnan(percentileArray)
# Then, update the mask to reflect all valid voxels that are outside the the closed 10-90th percentile range
msk[msk] = ((percentileArray - prcnt10[:, None])[msk] < 0) | ((percentileArray - prcnt90[:, None])[msk] > 0)
# Finally, exclude the invalid voxels by setting them to numpy.nan.
percentileArray[msk] = numpy.nan

return numpy.nanmean(numpy.absolute(percentileArray - numpy.nanmean(percentileArray, 1, keepdims=True)), 1)

Expand Down

0 comments on commit a7bed1d

Please sign in to comment.