-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_datafunctions_qt.lua
More file actions
201 lines (191 loc) · 7.52 KB
/
1_datafunctions_qt.lua
File metadata and controls
201 lines (191 loc) · 7.52 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
require 'qtwidget'
require 'qttorch'
require 'image'
function display(mrc,coordinate,particle_size,filename,color)
--image.display(mrc)
if not color then
color = "white"
end
local qimage = qt.QImage.fromTensor(mrc[1])
local painter_image = qtwidget.newimage(qimage)
if color == "test" then
for i=1,#coordinate do
if coordinate[i][3]>0.95 then
if coordinate[i][5] == 1 then
painter_image:arc(coordinate[i][1],coordinate[i][2],particle_size/2,0,360)
painter_image:setcolor("red")
painter_image:setlinewidth(2)
painter_image:stroke()
else
painter_image:arc(coordinate[i][1],coordinate[i][2],particle_size/2,0,360)
painter_image:setcolor("blue")
painter_image:setlinewidth(2)
painter_image:stroke()
end
end
end
else
for i=1,#coordinate do
painter_image:arc(coordinate[i][1],coordinate[i][2],particle_size/2,0,360)
painter_image:setcolor(color)
painter_image:setlinewidth(2)
painter_image:stroke()
end
end
painter_image:write(filename)
painter_image:close()
--return painter_image:image():toTensor():clone()
end
function display_compare(mrc,coordinate1,coordinate2,particle_size,filename,symbol,color1,color2)
-- coordinate 1 refer manual pick, color red
-- coordinate 2 refer autopick , color blue, if is true positive, color black
-- symbol==0 , plot all the particles
-- symbol==1 , plot only the matched particles both
-- symbol==2 , plot the all the coordinate1 as red color, plot the matched coordinate2 as black, plot the unmatched coordinate2 as blue
if not color1 then
color1 = "red"
end
if not color2 then
color2 = "blue"
end
if not symbol then
symbol = 0
end
local qimage = qt.QImage.fromTensor(mrc[1])
local painter_image = qtwidget.newimage(qimage)
for i=1,#coordinate1 do
if symbol==1 then
if coordinate1[i][5] == 1 then
painter_image:arc(coordinate1[i][1],coordinate1[i][2],particle_size/2,0,360)
painter_image:setcolor(color1)
painter_image:setlinewidth(2)
painter_image:stroke()
end
else
painter_image:arc(coordinate1[i][1],coordinate1[i][2],particle_size/2,0,360)
painter_image:setcolor(color1)
painter_image:setlinewidth(2)
painter_image:stroke()
end
end
for i=1,#coordinate2 do
if symbol==1 then
if coordinate2[i][5] == 1 then
painter_image:arc(coordinate2[i][1],coordinate2[i][2],particle_size/2,0,360)
painter_image:setcolor(color2)
painter_image:setlinewidth(2)
painter_image:stroke()
end
elseif symbol==2 then
if coordinate2[i][3]>=0.95 then
if coordinate2[i][5] == 1 then
color2 = "black"
else
color2 = "blue"
end
painter_image:arc(coordinate2[i][1],coordinate2[i][2],particle_size/2,0,360)
painter_image:setcolor(color2)
painter_image:setlinewidth(2)
painter_image:stroke()
end
else
if coordinate2[i][5] == 1 then
color2 = "black"
else
color2 = "blue"
end
painter_image:arc(coordinate2[i][1],coordinate2[i][2],particle_size/2,0,360)
painter_image:setcolor(color2)
painter_image:setlinewidth(2)
painter_image:stroke()
end
end
painter_image:write(filename)
painter_image:close()
end
function display_cross(mrc,coordinate,filename,length,color)
if not color then
color="black"
end
if not length then
length = 10
end
local qimage = qt.QImage.fromTensor(mrc[1]:float():clone())
local painter_image = qtwidget.newimage(qimage)
for i=1,#coordinate do
local coor_x = coordinate[i][1]
local coor_y = coordinate[i][2]
local x1 = coor_x-math.ceil(length/2)
if x1<1 then x1 = 1 end
local x2 = coor_x+math.ceil(length/2)
if x2>mrc:size(3) then x2 = mrc:size(3) end
painter_image:moveto(x1,coor_y)
painter_image:lineto(x2,coor_y)
local y1 = coor_y-math.ceil(length/2)
if y1<1 then y1 = 1 end
local y2 = coor_y+math.ceil(length/2)
if y2>mrc:size(2) then y2 = mrc:size(2) end
painter_image:moveto(coor_x,y1)
painter_image:lineto(coor_x,y2)
painter_image:setcolor(color)
painter_image:setlinewidth(1)
painter_image:stroke()
end
print(filename)
--print(string.sub(filename,1,string.len(filename)-1))
painter_image:write(filename)
painter_image:close()
end
function display_cross_compare(mrc,coordinate_manual,coordinate_auto,filename,length,color1,color2)
if not color1 then
color1="red"
end
if not color2 then
color2="blue"
end
if not length then
length = 10
end
local qimage = qt.QImage.fromTensor(mrc[1]:float():clone())
local painter_image = qtwidget.newimage(qimage)
for i=1,#coordinate_manual do
local coor_x = coordinate_manual[i][1]
local coor_y = coordinate_manual[i][2]
local x1 = coor_x-math.ceil(length/2)
if x1<1 then x1 = 1 end
local x2 = coor_x+math.ceil(length/2)
if x2>mrc:size(3) then x2 = mrc:size(3) end
painter_image:moveto(x1,coor_y)
painter_image:lineto(x2,coor_y)
local y1 = coor_y-math.ceil(length/2)
if y1<1 then y1 = 1 end
local y2 = coor_y+math.ceil(length/2)
if y2>mrc:size(2) then y2 = mrc:size(2) end
painter_image:moveto(coor_x,y1)
painter_image:lineto(coor_x,y2)
painter_image:setcolor(color1)
painter_image:setlinewidth(1)
painter_image:stroke()
end
for i=1,#coordinate_auto do
local coor_x = coordinate_auto[i][1]
local coor_y = coordinate_auto[i][2]
local x1 = coor_x-math.ceil(length/2)
if x1<1 then x1 = 1 end
local x2 = coor_x+math.ceil(length/2)
if x2>mrc:size(3) then x2 = mrc:size(3) end
painter_image:moveto(x1,coor_y)
painter_image:lineto(x2,coor_y)
local y1 = coor_y-math.ceil(length/2)
if y1<1 then y1 = 1 end
local y2 = coor_y+math.ceil(length/2)
if y2>mrc:size(2) then y2 = mrc:size(2) end
painter_image:moveto(coor_x,y1)
painter_image:lineto(coor_y,y2)
painter_image:setcolor(color2)
painter_image:setlinewidth(1)
painter_image:stroke()
end
painter_image:write(filename)
painter_image:close()
end