forked from olakiril/PyMouse_atlab
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDatabase.py
executable file
·290 lines (250 loc) · 9.25 KB
/
Database.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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import datajoint as dj
schema = dj.schema('pipeline_behavior')
def erd():
"""for convenience"""
dj.ERD(schema).draw()
@schema
class SetupInfo(dj.Lookup):
definition = """
#
setup : varchar(256) # Setup name
---
ip : varchar(16) # setup IP address
state="ready" : enum('ready','running','stopped','sleeping') #
animal_id=null : int # animal id
task_idx=null : int # task identification number
task="train" : enum('train','calibrate')
last_ping=null : timestamp
"""
@schema
class LiquidCalibration(dj.Manual):
definition = """
# Liquid delivery calibration sessions for each probe
setup : varchar(256) # Setup name
probe : int # probe number
date : date # session date (only one per day is allowed)
"""
class PulseWeight(dj.Part):
definition = """
# Data for volume per pulse duty cycle estimation
-> LiquidCalibration
pulse_dur : int # duration of pulse in ms
---
pulse_num : int # number of pulses
weight : float # weight of total liquid released in gr
"""
@schema
class ExperimentType(dj.Lookup):
definition = """
# Experiment type
exp_type : char(128) # experiment schema
---
description = '' : varchar(2048) # some description of the experiment
"""
contents = [
('MultiProbe', '2AFC & GoNOGo tasks with lickspout'),
('DummyMultiProbe', 'Same as Multiprobe but with a dummy probe'),
('FreeWater', 'Reward upon lick'),
('ProbeTest', 'Testing probes'),
('Pasive', 'No reward/punishment'),
]
@schema
class StimulusType(dj.Lookup):
definition = """
# Stimulus type
stim_type : char(128) # stimulus schema
---
description = '' : varchar(2048) # some description of the experiment
"""
contents = [
('Movies', 'Typical movies stimulus'),
('RPMovies', 'Same as Movies but for Raspberry pi'),
('Gratings', 'Orientation Gratings'),
('NoStimulus', 'Free water condition with no stimulus'),
]
@schema
class Task(dj.Lookup):
definition = """
# Behavioral experiment parameters
task_idx : int # task identification number
---
-> ExperimentType
-> StimulusType
intertrial_duration = 30 : int # time in between trials (s)
trial_duration = 30 : int # trial time (s)
timeout_duration = 180 : int # timeout punishment delay (s)
airpuff_duration = 400 : int # duration of positive punishment (ms)
response_interval = 1000 : int # time before a new lick is considered a valid response (ms)
reward_amount = 8 : int # microliters of liquid
silence_thr = 30 : int # lickless period after which stimulus is paused (min)
conditions : varchar(4095) # stimuli to be presented (array of dictionaries)
description ='' : varchar(2048) # task description
start_time=null : time
stop_time=null : time
"""
contents = [
(1,'MultiProbe','RPMovies', 30, 30, 180, 400, 1000, 8, 30,
"[{'probe':[1], 'clip_number':list(range(1,3)), 'movie_name':['obj1v4']},\
{'probe':[2], 'clip_number':list(range(1,3)), 'movie_name':['obj2v4']}]",
'3d object experiment'),
]
@schema
class CalibrationTask(dj.Lookup):
definition = """
# Calibration parameters
task_idx : int # task identification number
---
probe='[1,2]' : varchar(128) # probe number
pulse_dur : int # duration of pulse in ms
pulse_num : int # number of pulses
pulse_interval : int # interval between pulses in ms
save='yes' : enum('yes','no')# store calibration
"""
@schema
class MouseWeight(dj.Manual):
definition = """
# Weight of the animal
animal_id : int # animal id
timestamp=CURRENT_TIMESTAMP : timestamp
---
weight : float # in grams
"""
@schema
class Session(dj.Manual):
definition = """
# Behavior session info
animal_id : int # animal id
session_id : smallint # session number
---
intertrial_duration : int # time in between trials (s)
trial_duration : int # trial time (s)
timeout_duration : int # timeout punishment delay (s)
airpuff_duration : int # duration of positive punishment (ms)
response_interval : int # time before a new lick is considered a valid response (ms)
reward_amount : int # microliters of liquid
setup : varchar(256) # computer id
session_tmst : timestamp # session timestamp
notes ='' : varchar(2048) # session notes
"""
@schema
class Condition(dj.Manual):
definition = """
# unique stimulus conditions
-> Session
cond_idx : smallint # unique condition index
---
"""
@schema
class Trial(dj.Manual):
definition = """
# Trial information
-> Session
-> Condition
trial_idx : smallint # unique condition index
---
start_time : int # start time from session start (ms)
end_time : int # end time from session start (ms)
last_flip_count : int # the last flip number in this trial
"""
@schema
class Lick(dj.Manual):
definition = """
# Lick timestamps
-> Session
time : int # time from session start (ms)
probe : int # probe number
"""
@schema
class LiquidDelivery(dj.Manual):
definition = """
# Liquid delivery timestamps
-> Session
time : int # time from session start (ms)
probe : int # probe number
"""
@schema
class AirpuffDelivery(dj.Manual):
definition = """
# Air puff delivery timestamps
-> Session
time : int # time from session start (ms)
probe=0 : int # probe number
"""
@schema
class OdorDelivery(dj.Manual):
definition = """
# Odor delivery timestamps
-> Session
time : int # time from session start (ms)
odor_idx=0 : int # odor number
"""
@schema
class Movie(dj.Lookup):
definition = """
# movies used for generating clips and stills
movie_name : char(8) # short movie title
---
path : varchar(255) #
movie_class : enum('mousecam','object3d','madmax','multiobject') #
original_file : varchar(255) #
file_template : varchar(255) # filename template with full path
file_duration : float # (s) duration of each file (must be equal)
codec="-c:v libx264 -preset slow -crf 5" : varchar(255) #
movie_description : varchar(255) # full movie title
"""
class Still(dj.Part):
definition = """
# Cached still frames from the movie
-> Movie
still_id : int # ids of still images from the movie
---
still_frame : longblob # uint8 grayscale movie
"""
class Clip(dj.Part):
definition = """
# Clips from movies
-> Movie
clip_number : int # clip index
---
file_name : varchar(255) # full file name
clip : longblob #
"""
@schema
class MovieClipCond(dj.Manual):
definition = """
# movie clip conditions
-> Condition
---
-> Movie.Clip
"""
@schema
class GratingCond(dj.Manual):
definition = """
# Orientation gratings conditions
-> Condition
---
direction : int # in degrees (0-360)
spatial_period : int # pixels/cycle
temporal_freq : float # cycles/sec
contrast=100 : int # 0-100 Michelson contrast
phase=0 : float # initial phase in rad
square=0 : tinyint # square wave flag (binary)
"""
@schema
class RewardCond(dj.Manual):
definition = """
# reward probe conditions
-> Condition
---
probe=0 :int # probe number
"""
@schema
class OdorCond(dj.Manual):
definition = """
# reward probe conditions
-> Condition
---
odor_dur=1000 :int # odor duration (ms)
odor_idx=0 :int # odor index for channel mapping
odor_name="" :varchar(255) # name of the odor
"""