-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer_exp.py
More file actions
45 lines (34 loc) · 1021 Bytes
/
timer_exp.py
File metadata and controls
45 lines (34 loc) · 1021 Bytes
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
import experiment as exp
import schedule
import time
import arena
class TimerExperiment(exp.Experiment):
default_params = {
"interval": 1,
}
default_blocks = [
{"$num_trials": 2},
{"$num_trials": 3, "interval": 2},
{"$num_trials": 6, "interval": 0.5},
{"interval": 2},
]
# mock
params_def = {"interval": (1, {"ui": ["input", "float"]})}
##
def setup(self):
self.cancel_timer = None
def run_block(self):
interval = exp.get_params()["interval"]
self.cancel_timer = schedule.repeat(
self.timer_fn, interval, exp.get_params().get("$num_trials", True)
)
def run_trial(self):
self.log.info(f"{exp.session_state['cur_trial']}: {time.time()}")
arena.run_command("toggle", "Signal LED", update_value=True)
def timer_fn(self):
exp.next_trial()
def end_block(self):
self.cancel_timer()
pass
def end(self):
self.log.info("Stopped timer")