-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbpod_mock.py
More file actions
36 lines (30 loc) · 1.19 KB
/
bpod_mock.py
File metadata and controls
36 lines (30 loc) · 1.19 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
import numpy as np
class MessageMock():
def __init__(self, message: str):
self.content = message
class BpodMock():
def __init__(self):
self.reset_trial()
def reset_trial(self):
self.current_trial = {
"Trial start timestamp": np.nan,
"Events timestamps": {},
"States timestamps": {},
}
self.events_occurrences = []
return
def record_message(self, message: str):
self.events_occurrences.append(MessageMock(message))
return
def record_event(self, event_name: str, timestamp: float):
if event_name not in self.current_trial["Events timestamps"].keys():
self.current_trial["Events timestamps"][event_name] = [timestamp]
else:
self.current_trial["Events timestamps"][event_name].append(timestamp)
return
def record_state(self, state_name: str, interval: list[float]):
if state_name not in self.current_trial["States timestamps"].keys():
self.current_trial["States timestamps"][state_name] = [interval]
else:
self.current_trial["States timestamps"][state_name].append(interval)
return