Commit 8b4b58e4 authored by Nicole Bussola's avatar Nicole Bussola
Browse files

Add SUVPeak and fix PercentageInactive

parent ce1ca5cf
......@@ -502,12 +502,9 @@ class RadiomicsFirstOrder(base.RadiomicsFeaturesBase):
mask = self.maskArray
ROIPet[~mask] = 0
ROIPet = numpy.pad(a, 1, mode='constant', constant_values=np.nan)
thresh = 0.01 * (numpy.max(ROIPet[~numpy.isnan(ROIPet)]) ** 2)
# mask = ROIPet[~numpy.isnan(ROIPet)]
# ROIPet[numpy.isnan(ROIPet)] = 0
mask_inactive = ROIPet > thresh
# MORPHOLOGICAL OPERATIONS
......@@ -550,15 +547,44 @@ class RadiomicsFirstOrder(base.RadiomicsFeaturesBase):
perimeter = oc.bwperim(mask, 26)
mask_inactive = oc.imclose(mask_inactive, conn)
mask_inactive = oc.imopen(mask_inactive, conn)
new_mask = mask_inactive + perimeter
new_mask[mask == 0] = 10
new_mask[new_mask == 1] = 10
new_mask[new_mask == 2] = 10
new_mask[new_mask == 0] = 1
new_mask[new_mask == 10] = 0
connObjects = oc.bwconncomp(new_mask, 26)
b = numpy.zeros((1, connObjects.NumObjects))
for i in range(connObjects.NumObjects):
a = oc.find(
len(connObjects.PixelIdxList[i]) >= 15
) # If the number of of pixel forming and object is lower than 15, reject it
if a.size == 0:
b[i] = 0
else:
b[i] = 1
[row, col] = oc.find(b > 0)
sumInactive = 0
for i in range(len(col)):
sumInactive = sumInactive + len(
connObjects.PixelIdxList[row[i], col[i]]
)
sumVolume = numpy.sum(mask)
import ipdb
ipdb.set_trace()
except Oct2PyError as e:
print(e)
oc.exit()
new_mask = mask_inactive + perimeter
import ipdb
ipdb.set_trace()
return n
return sumInactive / sumVolume * 100
def getAUCCSHFeatureValue(self):
r"""
......@@ -609,11 +635,7 @@ class RadiomicsFirstOrder(base.RadiomicsFeaturesBase):
r"""
**24. SuvPeak**
Total lesion glycolysis.
Defined as
.. math::
\textit{SUVMean}\times \textit{total volume of the tumour region}
Average of the voxel with maximum SUV within the tumour region and its 26 connected neighbours.
- input: 3D array representing the PET volume in SUV format, with
voxels outside the ROI set to NaNs.
......@@ -624,16 +646,9 @@ class RadiomicsFirstOrder(base.RadiomicsFeaturesBase):
ROIPet = self.imageArray
mask = self.maskArray
ROIPet[~mask] = numpy.nan
# ROIPet = numpy.pad(ROIPet, 1, mode='constant', constant_values=numpy.nan)
xx = numpy.array(
[
[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
[[10, 11, 12], [13, 14, 15], [16, 17, 18]],
[[19, 20, 21], [22, 223, 24], [25, 26, 27]],
]
)
oc = Oct2Py()
ROIPet = oc.double(xx.tolist())
ROIPet = oc.double(ROIPet.tolist())
with Oct2Py() as oc:
try:
......@@ -648,34 +663,62 @@ class RadiomicsFirstOrder(base.RadiomicsFeaturesBase):
[indMaxX, indMaxY, indMaxZ] = numpy.unravel_index(
indMax[0], ROIPet.shape, 'F'
)
connectivity = oc.getneighbors(
oc.strel('arbitrary', oc.conndef(3, 'maximal'))
# connectivity = oc.getneighbors(
# oc.strel(
# 'arbitrary',
# oc.double(numpy.ones((3, 3, 3), dtype=numpy.int).tolist()),
# )
# )
connectivity = numpy.array(
[
[-1, -1, -1],
[0, -1, -1],
[1, -1, -1],
[-1, 0, -1],
[0, 0, -1],
[1, 0, -1],
[-1, 1, -1],
[0, 1, -1],
[1, 1, -1],
[-1, -1, 0],
[0, -1, 0],
[1, -1, 0],
[-1, 0, 0],
[0, 0, 0],
[1, 0, 0],
[-1, 1, 0],
[0, 1, 0],
[1, 1, 0],
[-1, -1, 1],
[0, -1, 1],
[1, -1, 1],
[-1, 0, 1],
[0, 0, 1],
[1, 0, 1],
[-1, 1, 1],
[0, 1, 1],
[1, 1, 1],
]
)
import ipdb
ipdb.set_trace()
nPeak = len(connectivity)
neighborsMax = oc.zeros(1, nPeak)
neighborsMax = numpy.zeros((1, nPeak))
for i in range(nPeak):
neighborsMax[i] = ROIPet[
connectivity(i, 1) + indMaxX,
connectivity(i, 2) + indMaxY,
connectivity(i, 3) + indMaxZ,
neighborsMax[0, i] = ROIPet[
connectivity[i, 0] + indMaxX - 1,
connectivity[i, 1] + indMaxY - 1,
connectivity[i, 2] + indMaxZ - 1,
]
# import ipdb
# ipdb.set_trace()
except Oct2PyError as e:
print(e)
oc.exit()
import ipdb
ipdb.set_trace()
# SUVpeak = mean(neighborsMax(~isnan(neighborsMax)))
return mean(neighborsMax(~isnan(neighborsMax)))
return numpy.mean(neighborsMax[~numpy.isnan(neighborsMax)])
# ROIPet = numpy.pad(ROIPet, 1, mode='constant', constant_values=np.nan)
def getgETUFeatureValue(self):
r"""
**25. gETU**
......
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