1
1
#!/usr/bin/env python
2
2
3
- # Q: - several standards and/or deviants (probabilities? e.g. std_prob = [0.2 0.5 0.3])
4
- # - option give several markers
5
- # - constraints (min. x standards between deviants)
6
-
7
3
8
4
# ODDBALL BASE CLASS from which all the subclasses inherit.
9
5
#
53
49
import pygame
54
50
55
51
from FeedbackBase .MainloopFeedback import MainloopFeedback
52
+ from lib import marker
56
53
57
54
class Oddball (MainloopFeedback ):
58
55
59
- RUN_START , RUN_END = 252 ,253
60
- COUNTDOWN_START , COUNTDOWN_END = 40 ,41
61
56
STANDARD , DEVIANT = list (),list ()
62
57
# standards have markers 10,11,12,... ; deviants 30,31,32,... (cf. get_stimuli())
63
58
# if self.group_stim_markers==True, then there exist only two markers, one for
64
59
# group standard (10), and one for group deviant (20)
65
60
RESP_STD , RESP_DEV = 1 ,2
66
- SHORTPAUSE_START , SHORTPAUSE_END = 249 , 250
67
61
68
62
def init (self ):
69
63
self .screen_pos = [100 , 100 , 640 , 480 ]
64
+ self .fullscreen = False
70
65
self .FPS = 40
71
- self .nStim = 100
72
- self .nStim_per_block = 50
66
+ self .nStim = 10
67
+ self .nStim_per_block = 5
73
68
self .dev_perc = 0.1
74
69
self .countdown_from = 2
75
70
self .show_standards = True
@@ -196,7 +191,7 @@ def pre_mainloop(self):
196
191
Sets up all the necessary components (e.g. pygame, stimuli, graphics)
197
192
to run the experiment.
198
193
"""
199
- self .send_parallel (self .RUN_START )
194
+ self .send_parallel (marker .RUN_START )
200
195
self .init_pygame ()
201
196
self .get_stimuli ()
202
197
self .error_checking ()
@@ -209,7 +204,7 @@ def post_mainloop(self):
209
204
"""
210
205
Sends end marker to parallel port and quits pygame.
211
206
"""
212
- self .send_parallel (self .RUN_END )
207
+ self .send_parallel (marker .RUN_END )
213
208
pygame .quit ()
214
209
215
210
@@ -376,15 +371,15 @@ def short_pause_tick(self):
376
371
One tick of the short pause loop.
377
372
"""
378
373
if self .shortpauseElapsed == 0 :
379
- self .send_parallel (self . SHORTPAUSE_START )
374
+ self .send_parallel (marker . PAUSE_START )
380
375
381
376
self .shortpauseElapsed += self .elapsed
382
377
383
378
if self .shortpauseElapsed >= self .shortpauseDuration :
384
379
self .shortpause = False
385
380
self .shortpauseElapsed = 0
386
381
self .countdown = True
387
- self .send_parallel (self . SHORTPAUSE_END )
382
+ self .send_parallel (marker . PAUSE_END )
388
383
return
389
384
390
385
self .do_print ("Short Break..." , self .fontColor , self .size / 10 )
@@ -396,7 +391,7 @@ def countdown_tick(self):
396
391
"""
397
392
# start countdown
398
393
if self .countdownElapsed == 0 :
399
- self .send_parallel (self .COUNTDOWN_START )
394
+ self .send_parallel (marker .COUNTDOWN_START )
400
395
self .draw_initial ()
401
396
# initialize stimulus sequence for the next block according to the deviant probability
402
397
n = min (self .nStim_per_block ,self .nStim )
@@ -406,7 +401,7 @@ def countdown_tick(self):
406
401
407
402
# stop countdown
408
403
if self .countdownElapsed >= (self .countdown_from ) * 1000 :
409
- self .send_parallel (self .COUNTDOWN_END )
404
+ self .send_parallel (marker .COUNTDOWN_END )
410
405
self .countdown = False
411
406
self .countdownElapsed = 0
412
407
self .beforestim = True
@@ -515,7 +510,10 @@ def init_pygame(self):
515
510
os .environ ['SDL_VIDEO_WINDOW_POS' ] = "%d,%d" % (self .screen_pos [0 ], self .screen_pos [1 ])
516
511
pygame .init ()
517
512
pygame .display .set_caption ('Oddball' )
518
- self .screen = pygame .display .set_mode ((self .screen_pos [2 ], self .screen_pos [3 ]), pygame .RESIZABLE )
513
+ if self .fullscreen :
514
+ self .screen = pygame .display .set_mode ((self .screen_pos [2 ], self .screen_pos [3 ]), pygame .FULLSCREEN )
515
+ else :
516
+ self .screen = pygame .display .set_mode ((self .screen_pos [2 ], self .screen_pos [3 ]), pygame .RESIZABLE )
519
517
self .clock = pygame .time .Clock ()
520
518
521
519
def contrained_oddball_sequence (self , N , dev_perc , dd_dist = 0 ):
0 commit comments