Commit 5ed18200 authored by Nicole Bussola's avatar Nicole Bussola
Browse files

add reference tetrahedron volume

parent f0baf444
......@@ -425,14 +425,6 @@ class RadiomicsShape(base.RadiomicsFeaturesBase):
of the tumour region (smallest polyhedron containing the tumour region)
"""
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)
......@@ -440,9 +432,7 @@ class RadiomicsShape(base.RadiomicsFeaturesBase):
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(
......@@ -450,10 +440,14 @@ class RadiomicsShape(base.RadiomicsFeaturesBase):
)
tets = ch.points[simplices]
a, b, c, d = tets[:, 0], tets[:, 1], tets[:, 2], tets[:, 3]
# https://stackoverflow.com/questions/24733185/volume-of-convex-hull-with-qhull-from-scipy
tetrahedron_vol = (
numpy.abs(numpy.einsum('ij,ij->i', a - d, numpy.cross(b - d, c - d))) / 6
)
ROIVolume = self.Volume
return ROIVolume / numpy.sum(tetrahedron_vol)
def _interpolate(self, grid, p1, p2):
......
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