forked from SjulsonLab/RPi4_behavior_boxes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_visualstim.py
More file actions
executable file
·64 lines (48 loc) · 2.18 KB
/
testing_visualstim.py
File metadata and controls
executable file
·64 lines (48 loc) · 2.18 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
#!/usr/bin/env python3
# testing the visual stim class
import logging
from visualstim import VisualStim
import time
import collections, pysistence
import socket
from datetime import datetime
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s.%(msecs)03d,[%(levelname)s],%(message)s",
datefmt=('%H:%M:%S'),
handlers=[
logging.StreamHandler()
]
)
# defining immutable mouse dict (once defined for a mouse, this should never change)
mouse_info = pysistence.make_dict({'mouse_name': 'mouse01',
'fake_field': 'fake_info',
})
# making fake session_info
session_info = collections.OrderedDict()
session_info['mouse_name'] = mouse_info['mouse_name']
#session_info['trainingPhase'] = 4
session_info['basedir'] = '/home/pi/fakedata'
session_info['weight'] = 32.18
session_info['manual_date'] = '2021-01-27'
session_info['date'] = datetime.now().strftime("%Y-%m-%d")
session_info['time'] = datetime.now().strftime('%H%M%S')
session_info['datetime'] = session_info['date'] + '_' + session_info['time']
session_info['basename'] = mouse_info['mouse_name'] + '_' + session_info['datetime']
session_info['box_name'] = socket.gethostname()
session_info['dir_name'] = session_info['basedir'] + "/" + session_info['mouse_name'] + "_" + session_info['datetime']
# session_info['config'] = 'freely_moving_v1'
session_info['config'] = 'head_fixed_v1'
# visual stimulus
session_info['gray_level'] = 40 # the pixel value from 0-255 for the screen between stimuli
session_info['vis_gratings'] = ['/home/pi/gratings/first_grating.grat', '/home/pi/gratings/second_grating.grat']
session_info['vis_raws'] = []
logging.info("initiating vstim")
screen = VisualStim(session_info)
# screen.load_stimulus_dir('/home/pi/gratings')
screen.show_stimulus('first_grating.grat')
# proof that the threading works - note that other stuff is done while the
# stimulus is playing
for i in range(21):
logging.info("these should be slightly more than 200 ms apart")
time.sleep(0.2)