-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEBImage_34RD.R
106 lines (86 loc) · 3.14 KB
/
EBImage_34RD.R
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
############################# CD3 ###############################
#cell surface CD4 receptor image
CD3 = data$`34RD`$CD3
#hist(CD_8a_cell_surface)
display(CD3)
CD3.norm = normalize(CD3, inputRange = quantile(CD3, c(0,0.99)))
#hist(CD4_cell_surface.norm)
CD3.norm.blur = gblur(CD3.norm, sigma = 1)
display(CD3.norm.blur)
#cell segentation
cells = rgbImage(green = 1.5*CD3.norm.blur)
#cell surface mask
#get cells that stand out of the moving background window
cmask = thresh(CD3.norm.blur, w=7, h=7, offset=0.05)
#get rid of noises
cmask = opening(cmask, makeBrush(3, shape='disc'))
#apply watershed to further segment cells
cmask = watershed(distmap(cmask), 2)
display(CD3.norm.blur)
display(colorLabels(cmask))
#segment regions with seeds = cmask
ctmask = propagate(CD3.norm.blur, seeds = cmask)
display(colorLabels(ctmask))
#display(paintObjects(cmask, CD4_cell_surface.norm.blur, col = "#ff00ff"))
#paint outline of cell mask on image of cells
segmented = paintObjects(ctmask, cells, col = "#ff00ff")
display(cells)
display(segmented)
############################# H3 ###############################
#histone3 marker image
histone = data$`34RD`$`Histone-H3`
#hist(CD_8a_cell_surface)
display(histone)
histone.norm = normalize(histone, inputRange = quantile(histone, c(0,0.99)))
#hist(CD4_cell_surface.norm)
histone.norm.blur = gblur(histone.norm, sigma = 1)
display(histone.norm.blur)
#cell segentation
cells = rgbImage(green = 1.5*histone.norm.blur)
#cell mask
#get cells that stand out of the moving background window
cmask = thresh(histone.norm.blur, w=10, h=10, offset=0.05)
#get rid of noises
cmask = opening(cmask, makeBrush(3, shape='disc'))
#apply watershed to further segment cells
cmask = watershed(distmap(cmask), 2)
cmask = fillHull(cmask)
display(histone.norm.blur)
display(bwlabel(cmask))
#segment regions with seeds = cmask
ctmask = propagate(histone.norm.blur, seeds = cmask)
display(colorLabels(ctmask))
#display(paintObjects(cmask, CD4_cell_surface.norm.blur, col = "#ff00ff"))
#paint outline of cell mask on image of cells
segmented = paintObjects(ctmask, cells, col = "#ff00ff")
display(cells)
display(segmented)
############################ CD 20 #############################
#histone3 marker image
CD20 = data$`34RD`$CD20
#hist(CD_8a_cell_surface)
display(CD20)
CD20.norm = normalize(CD20, inputRange = quantile(CD20, c(0,0.99)))
#hist(CD4_cell_surface.norm)
CD20.norm.blur = gblur(CD20.norm, sigma = 1)
display(CD20.norm.blur)
#cell segentation
cells = rgbImage(green = 1.5*CD20.norm.blur)
#cell mask
#get cells that stand out of the moving background window
cmask = thresh(CD20.norm.blur, w=7, h=7, offset=0.05)
#get rid of noises
cmask = opening(cmask, makeBrush(3, shape='disc'))
#apply watershed to further segment cells
cmask = watershed(distmap(cmask), 2)
cmask = fillHull(cmask)
display(CD20.norm.blur)
display(colorLabels(cmask))
#segment regions with seeds = cmask
ctmask = propagate(CD20.norm.blur, seeds = cmask)
display(colorLabels(ctmask))
#display(paintObjects(cmask, CD4_cell_surface.norm.blur, col = "#ff00ff"))
#paint outline of cell mask on image of cells
segmented = paintObjects(ctmask, cells, col = "#ff00ff")
display(cells)
display(segmented)