-
Notifications
You must be signed in to change notification settings - Fork 0
/
testHeat.py
66 lines (51 loc) · 1.92 KB
/
testHeat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import numpy as np
import matplotlib.pyplot as plot
import cv2
from structureData import *
from quantifyDiversity import *
from diversityHeatmap import *
from diversity2csv import *
from drawDiversityOverlay import *
def testOverlay():
fname = '/home/dms167/Documents/research/I3TH/test/055_Quant.csv'
xy, feat = structureData(fname,1,9) # 9 is ER_NUC
heat, colors = diversityHeatmap(xy,feat, 200,4,'default','QE')
drawDiversityOverlay(fname,xy,colors)
def testMap():
imname = '/home/dms167/Documents/research/I3TH/test/055_DAPI.tif'
fname = '/home/dms167/Documents/research/I3TH/test/055_Quant.csv'
xy, feat = structureData(fname,1,9) # 9 is ER_NUC
heat, colors = diversityHeatmap(xy,feat, 200,4,'default','QE')
colors = colors * 255
#im = cv2.imread(imname,-1)
im = cv2.imread(imname) #for some reason removing -1 works
for i in range(0, np.size(heat)):
#for i in range(0, 20):
cv2.circle(im, tuple(xy[i,:].astype(int)), 13, tuple(colors[i,:].astype(int)),thickness=-1)
cv2.namedWindow('055',cv2.WINDOW_NORMAL)
cv2.imshow('055',im)
cv2.resizeWindow('055', 600, 600)
cv2.waitKey()
cv2.imwrite('ex_055.png',im)
cv2.destroyAllWindows()
def testHeat():
# Define input CSV
fname = '/home/dms167/Documents/research/I3TH/test/055_Quant.csv'
# Extract cell centroids and feature
xy, feat = structureData(fname,1,9,'1') # 9 is ER_NUC
# Compute diversity and color for each cell
heat, colors = diversityHeatmap(xy,feat,200,4,'default','QE')
# Write output
diversity2csv(fname, heat, colors)
# Display overall diversity histogram
print "min heat is %0.3f, max heat is %0.3f" %(np.min(heat), np.max(heat))
hist,bins = np.histogram(heat,bins = 11)
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
plot.bar(center,hist.astype(float)/np.sum(hist),align='center',width=width)
plot.title('median QE = %0.3f' % np.median(heat))
plot.show()
if __name__ == '__main__':
#testHeat()
testMap()
#testOverlay()