-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiment.py
64 lines (53 loc) · 1.7 KB
/
experiment.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
# -*- coding: utf-8 -*-
"""
Created on Thu May 19 13:37:51 2022
@author: PaulaSaavedra
"""
from psychopy import visual, core, sound, monitors, prefs
import random
import psychtoolbox as ptb
import keyboard
import time
def experiment (info, board):
prefs.hardware['audioLib'] = ['sounddevice','PTB', 'pyo','pygame']
trial = ['std']*50
positions = []
aux=[]
while (len(aux)<10):
positions.append(random.randrange(2,50,3))
aux = set(positions)
aux = list(aux)
for i in range(10):
trial[aux[i]]='deviant'
markers_list = {'deviant':1, 'std':2}
markers = []
times = []
mon = monitors.Monitor('SMB2030N')
mon.setDistance(114)
window = visual.Window(fullscr=False, screen=1)
for tri in range(len(trial)):
if (keyboard.is_pressed('q')==False):
if (trial[tri] =='std'):
std = sound.Sound(500,0.075)
now_std = ptb.GetSecs()
board.insert_marker(markers_list['std'])
markers.append('std')
std.play(when= now_std)
t0 = time.time()
times.append(t0)
core.wait(0.075)
core.wait(0.5)
else:
deviant = sound.Sound(1000,0.03)
now_deviant = ptb.GetSecs()
board.insert_marker(markers_list['deviant'])
markers.append('deviant')
deviant.play(when= now_deviant)
t0 = time.time()
times.append(t0)
core.wait(0.03)
core.wait(0.5)
else:
break
window.close()
return markers, times, markers_list