-
Notifications
You must be signed in to change notification settings - Fork 1
/
TLatMultiplePositions.py
65 lines (49 loc) · 1.87 KB
/
TLatMultiplePositions.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
import datetime
import csv, os
tempDir = os.getenv("TEMP")
VV.Macro.PrintWindow.IsVisible = True
VV.Macro.PrintWindow.Clear()
VV.Acquire.Stage.PositionList.Save(tempDir + "\\PositionList.stg")
VV.Acquire.Stage.Series = False
VV.Acquire.TimeLapse.Series = True
VV.Acquire.Z.Series = False
VV.Acquire.TimeLapse.Stream.Request = True
VV.Macro.InputDialog.Initialize("Experiment Info", True)
VV.Macro.InputDialog.AddLabelOnly("Time-lapse Info")
VV.Macro.InputDialog.AddFloatVariable("Time points number", "TimePoints", 10, 1, 1000, 1)
VV.Macro.InputDialog.AddFloatVariable("Time interval (sec)", "TimeInterval", 60, 1, 10000, 1)
VV.Macro.InputDialog.AddStringVariable("Base File", "basename", VV.Acquire.Sequence.BaseName)
VV.Macro.InputDialog.Show()
nStagePositions = 5
fo = open(tempDir + "\\PositionList.stg")
reader = csv.reader(fo)
StagePositions = []
k=0
for row in reader:
if (k > 3):
StagePositions.append({'Name': row[0],
'X': row[1],
'Y': row[2],
'Z': row[3]})
k += 1
timestart = datetime.datetime.now()
print (timestart.strftime("Experiment started at %H:%M:%S"))
print ("****************")
for timepoint in range(TimePoints):
time0 = datetime.datetime.now()
lineNumber = 0
for stagePos in StagePositions:
VV.Acquire.Sequence.BaseName = basename+"_ntime"+str(timepoint+1)+"_position"+stagePos['Name']+"_"
VV.Stage.XPosition = float(stagePos['X'])
VV.Stage.YPosition = float(stagePos['Y'])
VV.Focus.ZPosition = float(stagePos['Z'])
VV.Acquire.Sequence.Start()
VV.Macro.Control.WaitFor('VV.Acquire.IsRunning', "==", False)
nexttime = timestart + datetime.timedelta(0, (timepoint+1)*TimeInterval)
if timepoint+1 == TimePoints:
print ("Done")
break
print (nexttime.strftime("Next time-point at %H:%M:%S"))
VV.Macro.Control.Delay(((nexttime-time0).total_seconds())*1000,'ms')
VV.Window.CloseAll(False)
VV.Acquire.Sequence.BaseName = basename