-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample.py
More file actions
85 lines (62 loc) · 3.6 KB
/
sample.py
File metadata and controls
85 lines (62 loc) · 3.6 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
import poapi, time
nr_trials = 2;
optotrak = poapi.Poapi()
optotrak.TransputerLoadSystem()
print(optotrak.TransputerInitializeSystem())
print(optotrak.OptotrakLoadCameraParameters("standard"))
#Settings ODAU:
OdauId ="ODAU1";
NumChannels =12; #Number of channels in the collection.
Gain =1; #Gain to use for the analog channels (-10 to 10 V)
DigitalMode =0;
FrameFrequency =500 ; #Frequency to collect data frames at.
ScanFrequency =90000 ; #Frequency to scan channels at.
StreamData =1; #Stream mode for the data buffers.
CollectionTime =5; #Number of seconds of data to collect.
PreTriggerTime =0; #Number of seconds to pre-trigger data by.
#Settings OPTOTRAK:
NumMarkers =4; #Number of markers in the collection.
FrameFrequency =500 ; #Frequency to collect data frames at.
MarkerFrequency =2500; #Marker frequency for marker maximum on-time.
Threshold =30; #Dynamic or Static Threshold value to use.
MinimumGain =160; #Minimum gain code amplification to use.
StreamData =1; #Stream mode for the data buffers.
DutyCycle =0.35; #Marker Duty Cycle to use.
Voltage =7.5; #Voltage to use when turning on markers.
CollectionTime =5; #Number of seconds of data to collect.
PreTriggerTime =0; #Number of seconds to pre-trigger data by.
#### Setup optotrak and odau collection
print("Odau setup collection:{}".format(optotrak.OdauSetupCollection(OdauId, NumChannels, Gain, DigitalMode,FrameFrequency, ScanFrequency, StreamData, CollectionTime, PreTriggerTime,0x0)))
print("Optotrak setup collection: {}".format(optotrak.OptotrakSetupCollection(NumMarkers,FrameFrequency, MarkerFrequency, Threshold, MinimumGain, StreamData,DutyCycle, Voltage, CollectionTime, PreTriggerTime,0x48000060)))
print("Optotrak activate markers: {}".format(optotrak.OptotrakActivateMarkers()))
print("Optotrak Get Status: {}".format(optotrak.OptotrakGetStatus()))
#print(optotrak.OdauGetStatus())
for i in range(nr_trials):
print("Starting trial: {} ".format(str(i)))
print("Odau data buffer initialize: {}".format(optotrak.DataBufferInitializeFile(OdauId, ("/tmp/O#00"+str(i)+".DAT"))))
print("Optotrak data buffer initialize: {}".format(optotrak.DataBufferInitializeFile("OPTOTRAK","/tmp/C#00"+str(i)+".DAT")))
print("Optotrak Data buffer start: {}\n".format(optotrak.DataBufferStart()))
print('Collecting data file...')
#### Test Data collection
time.sleep(0.5)
succeeded,framenr,elems,flags,data = optotrak.DataGetLatest3D()
print(data)
print(framenr)
time.sleep(1)
print("Optotrak Get Latest 3D: {}".format(optotrak.DataGetLatest3D()))
# at each end of the trial the data is saved and written
print("Optotrak Data buffer stop: {}".format(optotrak.DataBufferStop()))
time.sleep(1)
spoolComplete = 0
while not spoolComplete:
succeeded, realTimeData, spoolComplete, spoolStatus, framesBuffered = optotrak.DataBufferWriteData()
print(spoolComplete)
time.sleep(2)
# end of trials
print('Exit experiment...')
#### End of experiment
#print"Optotrak last error: {}".format((optotrak.OptoGetLastError()))
#De-activate the optotrak markers. => not necessary anymore, apparently bufferstop automatically does it, as well as the transputershutdownsystem
#print("Optotrak de activate markers: {}".format(optotrak.OptotrakDeActivateMarkers()))
#Shutdown the transputer message passing system.
#print("Optotrak transputer shutdown: {}".format(optotrak.TransputerShutdownSystem()))