-
Notifications
You must be signed in to change notification settings - Fork 0
/
Automatic.py
66 lines (45 loc) · 2.39 KB
/
Automatic.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
from FileHandler import FileHandler
#This class runs automatic mode
#It is called from a seperate thread, hence presence of "self.system.control.stop_threads.is_set()" checks
class Automatic():
#constructor gets system object and filehandler
def __init__(self,system):
self.system = system
self.fileHandler = FileHandler(self)
#starts autofocus, runs autofocus, then analyzes, then writes results, then moves carousel
#does that 20 times in a for loop
def start(self):
import time
start_time = time.time()
for i in range(20):
if(self.system.control.stop_threads.is_set()):
break
#auto focus
self.system.focus.autoFocus()
bestImage = self.system.currImage_analyze
# print("best image found")
if(self.system.control.stop_threads.is_set()):
break
x = self.system.bloodCounter.countWBC(bestImage)#count WBC's
if(self.system.control.stop_threads.is_set()):
break
y = self.system.bloodCounter.countRBC(bestImage)#count RBC's
if(self.system.control.stop_threads.is_set()):
break
z = self.system.bloodCounter.calcRatio()#calc WBC:RBC ratio
if(self.system.control.stop_threads.is_set()):
break
pathFlag = self.system.util.pathologyWarn(z)#set pathology flage based on ratio
#send data to main thread via shared queue
dataArray = ['update_auto',x,y,z,pathFlag,i]
self.system.GUI.queue.put(dataArray)
#write results to datafile
self.fileHandler.writeRatio(self.system.control.wb,self.system.control.ws1,i, z, pathFlag)
self.fileHandler.writeDateTime(self.system.control.wb,self.system.control.ws1,i)
self.fileHandler.writePathology(self.system.control.wb,self.system.control.ws1,i,z)
#move carousel to next slide
self.system.carousel.nextSlide()
print("moved carousel")
print("===============================SLIDE {} COMPLETE========================".format(i))
print("--- %s seconds taken by auto ---" % (time.time() - start_time))
return 'done'