Commit 2ce44004 authored by Nicole Bussola's avatar Nicole Bussola
Browse files

remove depracated from compactness and add solidity feature

parent 07d0d258
......@@ -2,6 +2,7 @@ import numpy
import SimpleITK as sitk
from radiomics import base, cShape, deprecated
from scipy.spatial import ConvexHull
class RadiomicsShape(base.RadiomicsFeaturesBase):
......@@ -203,7 +204,6 @@ class RadiomicsShape(base.RadiomicsFeaturesBase):
"""
return self.Volume / (self.SurfaceArea ** (3.0 / 2.0) * numpy.sqrt(numpy.pi))
@deprecated
def getCompactness2FeatureValue(self):
r"""
**6. Compactness 2**
......@@ -414,6 +414,51 @@ class RadiomicsShape(base.RadiomicsFeaturesBase):
return numpy.sqrt(1.0 - (minor_axis * least_axis / (major_axis ** 2)))
def getSolidityFeatureValue(self):
r"""
**18. Solidity**
This is a custom shape feature, implemented for comparison with Valieres et al.
Eccentricity is defined as:
.. math::
\textit{Eccentricity} = \sqrt{1-\frac{a\times b}{c^2}}
Here, where c is the longest semi-principal axes of the ellipsoid,
and a and b are the second and third longest semi-principal axes of the ellipsoid.
"""
ROIVolume = self.Volume
def tetrahedron_volume(a, b, c, d):
return (
numpy.abs(numpy.einsum('ij,ij->i', a - d, numpy.cross(b - d, c - d)))
/ 6
)
Np = len(self.labelledVoxelCoordinates[0])
coordinates = numpy.array(self.labelledVoxelCoordinates, dtype='int').transpose(
(1, 0)
) # Transpose equals zip(*a)
physicalCoordinates = coordinates * self.pixelSpacing[None, :]
physicalCoordinates -= numpy.mean(physicalCoordinates, axis=0) # Centered at 0
physicalCoordinates /= numpy.sqrt(Np)
# import ipdb
# ipdb.set_trace()
ch = ConvexHull(physicalCoordinates)
simplices = numpy.column_stack(
(numpy.repeat(ch.vertices[0], ch.nsimplex), ch.simplices)
)
tets = ch.points[simplices]
a, b, c, d = tets[:, 0], tets[:, 1], tets[:, 2], tets[:, 3]
tetrahedron_vol = (
numpy.abs(numpy.einsum('ij,ij->i', a - d, numpy.cross(b - d, c - d))) / 6
)
return ROIVolume / numpy.sum(tetrahedron_vol)
def _interpolate(self, grid, p1, p2):
diff = (0.5 - self.maskArray[tuple(grid[p1])]) / (
self.maskArray[tuple(grid[p2])] - self.maskArray[tuple(grid[p1])]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment