Commit fa058b89 authored by Alessia Marcolini's avatar Alessia Marcolini
Browse files

Fix Inactive Volume for constant volumes

parent d8815d99
import numpy import numpy
from scipy import ndimage
from oct2py import Oct2Py, Oct2PyError from oct2py import Oct2Py, Oct2PyError
from scipy import ndimage
from radiomics.firstorder import RadiomicsFirstOrder from radiomics.firstorder import RadiomicsFirstOrder
from .mybase import MyRadiomicsFeaturesBase from .mybase import MyRadiomicsFeaturesBase
...@@ -234,12 +235,12 @@ class MyRadiomicsFirstOrder(MyRadiomicsFeaturesBase): ...@@ -234,12 +235,12 @@ class MyRadiomicsFirstOrder(MyRadiomicsFeaturesBase):
a threshold of 0.01 × (SUVmax)^2 followed by closing and opening morphological operations were used a threshold of 0.01 × (SUVmax)^2 followed by closing and opening morphological operations were used
to differentiate active and inactive regions on FDG-PET scans to differentiate active and inactive regions on FDG-PET scans
- input: 3D array representing the PET volume in SUV format, with - input: 3D array representing the PET volume in SUV format
voxels outside the ROI set to NaNs.
.. note:: .. note::
Extracted from PET scans and not used in the CT feature set. Extracted from PET scans and not used in the CT feature set.
""" """
ROIPet = self.imageArray ROIPet = self.imageArray
mask = self.maskArray mask = self.maskArray
...@@ -298,27 +299,31 @@ class MyRadiomicsFirstOrder(MyRadiomicsFeaturesBase): ...@@ -298,27 +299,31 @@ class MyRadiomicsFirstOrder(MyRadiomicsFeaturesBase):
connObjects = oc.bwconncomp(new_mask, 26) connObjects = oc.bwconncomp(new_mask, 26)
b = numpy.zeros((1, int(connObjects.NumObjects))) if int(connObjects.NumObjects) > 1:
for i in range(int(connObjects.NumObjects)): b = numpy.zeros((1, int(connObjects.NumObjects)))
if isinstance(connObjects.PixelIdxList[0][i], numpy.ndarray):
a = connObjects.PixelIdxList[0][i].shape[0] for i in range(int(connObjects.NumObjects)):
# If the number of of pixel forming and object is lower than 15, reject it if isinstance(connObjects.PixelIdxList[0][i], numpy.ndarray):
if a < 15: a = connObjects.PixelIdxList[0][i].shape[0]
b[:, i] = 0 # If the number of of pixel forming and object is lower than 15, reject it
if a < 15:
b[:, i] = 0
else:
b[:, i] = 1
else: else:
b[:, i] = 1 b[:, i] = 0
else:
b[:, i] = 0
rows, cols = numpy.where(b > 0) rows, cols = numpy.where(b > 0)
sumInactive = sum( sumInactive = sum(
[ [
connObjects.PixelIdxList[rows, cols][i].shape[0] connObjects.PixelIdxList[rows, cols][i].shape[0]
for i in range(len(cols)) for i in range(len(cols))
] ]
) )
else:
sumInactive = 0
sumVolume = numpy.sum(mask) sumVolume = numpy.sum(mask)
except Oct2PyError as e: except Oct2PyError as e:
......
Markdown is supported
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