Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MPBA Radiomics
pyradiomics_custom
Commits
2ce44004
Commit
2ce44004
authored
Mar 12, 2020
by
Nicole Bussola
Browse files
remove depracated from compactness and add solidity feature
parent
07d0d258
Changes
1
Hide whitespace changes
Inline
Side-by-side
radiomics/shape.py
View file @
2ce44004
...
...
@@ -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
])]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment