Amount of Tissue
def QuantCore(self, image, filename, save=False):
image = gaussian(rgb2gray(image), sigma=2)
thresh = threshold_triangle(image[image > 0])
binary = np.logical_and(image < thresh, image > 0)
wholeCore = np.sum(binary)
if save:
self.info.emit("Saving - " + filename + '_core.tiff')
imagesave = Image.fromarray(binary)
imagesave.save(self.inputpath+os.sep+filename + '_core.tiff')
return wholeCore
Amount of Signal
def QuantStain(self, image, filename, save=False):
img_hsv = rgb2hsv(image)
img_hue = img_hsv[:, :, 0]
image_sat = img_hsv[:, :, 1]
hue = np.logical_and(img_hue > 0.02, img_hue < 0.10)
if self.threshold:
stain = np.logical_and(hue, image_sat > self.threshold)
else:
print("Defult threshold")
stain = np.logical_and(hue, image_sat > 0.79)
self.current_image = stain[::10, ::10].astype(float)
self.figures.emit()
if save:
self.info.emit("Saving - " + filename+'_stain.tiff')
imagesave = Image.fromarray(stain)
imagesave.save(self.inputpath+os.sep+filename+'_stain.tiff')
stint = np.copy(image)
stint = exposure.rescale_intensity(stint, out_range=(0, 255))
stint[stain == 0] = 0
stint = color.rgb2gray(stint)
stint = np.ravel(stint)
stint = stint[stint != 0]
stint_mean = stint.mean()
stint_std = stint.std()
stained = np.sum(stain)
return stained, stint_mean, stint_std