-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraining_protocol.py
More file actions
105 lines (82 loc) · 4.02 KB
/
training_protocol.py
File metadata and controls
105 lines (82 loc) · 4.02 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from village.custom_classes.training_protocol_base import TrainingProtocolBase
class TrainingProtocol(TrainingProtocolBase):
"""
This class defines the training protocol for animal behavior experiments.
The training protocol is run every time a task is finished and it determines:
1. Which new task is scheduled for the subject
2. How training variables change based on performance metrics
Required methods to implement:
- __init__: Initialize the training protocol
- default_training_settings: Define initial parameters. It is called when creating a new subject.
- update_training_settings: Update parameters after each session.
Optional method:
- gui_tabs: Organize the variables in custom GUI tabs
"""
def __init__(self) -> None:
"""Initialize the training protocol."""
super().__init__()
def default_training_settings(self) -> None:
"""
Define all initial training parameters for new subjects.
This method is called when creating a new subject, and these parameters
are saved as the initial values for that subject.
Required parameters:
- next_task (str): Name of the next task to run
- refractory_period (int): Waiting time in seconds between sessions
- minimum_duration (int): Minimum time in seconds for the task before door2 opens
- maximum_duration (int): Maximum time in seconds before task stops automatically
Additional parameters:
You can define any additional parameters needed for your specific tasks.
These can be modified between sessions based on subject performance.
"""
# Required parameters for any training protocol
self.settings.next_task = "Escape" # Next task to run
self.settings.refractory_period = 3600 * 4 # 4 hours between sessions of the same subject
self.settings.minimum_duration = 1 # Minimum duration of 1 second
self.settings.maximum_duration = 2*60*60 # Maximum duration of 2 hours
## Task-specific parameters
# sound parameters
self.settings.starting_amplitude = 0.001 # ?? dB SPL
self.settings.ending_amplitude = 0.5 # ~75 dB SPL
self.settings.ramp_duration = 0.4
self.settings.ramp_down_duration = 0.005
self.settings.hold_duration = 0.595
self.settings.n_repeats = 10
# exploration time
self.settings.exploration_time = 60 * 5
# probability of looming sound being played
self.settings.looming_sound_probability = 0.5 # 50% chance
# grace period duration
self.settings.grace_period = 120 # seconds
# time to wait before deciding to trigger the sound again
self.settings.time_between_sound_triggering_attempts = 120 # seconds
# time to wait after sound is played before starting a new trial
self.settings.time_to_wait_after_sound = 15 # seconds
# trigger zone coordinates
self.settings.trigger_area = 2 # index of the area in the cam_box to use as trigger zone
def update_training_settings(self) -> None:
pass
def define_gui_tabs(self):
"""
Define the organization of the settings in the GUI.
Whatever that is not defined here will be placed in the "General" tab.
They need to have the same name as your settings variables.
You can use the 'Hide' tab to hide a setting from the GUI.
Items in the lists need to have the same name as your settings variables.
You can also restrict the possible values for each setting.
"""
self.gui_tabs = {
"SoundParameters": [
"starting_amplitude",
"ending_amplitude",
"ramp_duration",
"ramp_down_duration",
"hold_duration",
"n_repeats",
],
}
# Define possible values for each variable
self.gui_tabs_restricted = {
#"trigger_area": [1, 2, 3, 4],
"trigger_area" : [2],
}