Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

SR box problems with EyeLink

Hello,

I am currently running an experiment whereby I need to use a SR button box. There is no indication of the brand or model on the box itself; it is a single button box, that connects via USB to the computer. With the srbox plugin, things seem to work (responses are successfully collected). However:

1) I put the srbox plugin at the beginning of my experiment. For some reason, if I just click "run" the experiment, I get a blank display. I can manage to run successfully the experiment only if I click run, and then I immediately press the button of the button box. Only in this way the instructions and the task are shown. Why does this occur?

2) Participants are supposed to provide their response in a visual search by pressing the button box. During the visual search they have to keep fixation, that is, they have to select the stimulus by attending covertly to the display. I check that they are fixating properly while they are doing the visual search. The problem is that if I collect responses with the button box, the fixation check does not work - whereas when I collect the responses by means of normal keypresses on the keyboard, the fixation check works. I was wondering whether calling srbox.start() might somehow interfere with the eyetracker.sample() function. What could be the problem?

Many thanks in advance for your help!

Comments

  • Hi Sine,

    These two problems might be related. Eyetracker and srbox should not interfere, obviously. It might be worthwhile to dig down the stack trace of sr box and check what things are done upon calling srbox.start() (either with the debugger, or modifying the source code + print statements). Perhaps, you can isolate the process that causes the interference. I don't have button box myself (and neither an eyetracker), so I can't really help you here. If you like, I can try to give you some guidance in trying to find the problem.

    Eduard

    Buy Me A Coffee

  • Hi @eduard ,

    many thanks for your reply. So, I managed to solve the first problem (it was really a silly thing - to be able to access the device srbox from the inline Python script, you need to drag the srbox plugin at the beginning of the experiment, and I had forgotten to modify the Timeout from infinite to a finite number).

    About my second question, I think you are right in saying that the problem might be linked to srbox.start(). I a while loop, where I wait for the button response and, while waiting, I check the fixation. It seems that the while loop does stop at the first iteration or simply there where I get srbox.get_button_press() - it does not even print core.getTime() a few lines below, which should set the timeout for the loop. Below you can see my loop. Perhaps there is something wrong with it and I cannot not see it (please, don't mind the ugliness of the code):


    def keyboard_response(my_canvas,target_shape,target_position,h,d,r,trigger): # SR button responses
    
    
    
    
    	eyetracker.log('searchdisplay on screen')
    
    	pupil_log = []
    
    	dev_log = []
    
    	n_gaze_samples = 6
    
    	max_gaze_deviation = angle2pix(1.5,h,d,r) 
    
    	failed_fixation_vs = 0
    
    	t0 = core.getTime()
    
    	response_made = False
    
    	buttons = []
    
    	srbox.start()
    
    	while not response_made:
    
    		
    
    		button, t1 = srbox.get_button_press(allowed_buttons=[5,6], timeout=None, require_state_change=True)
    
    		srbox.stop()
    
    		
    
    		curPos = eyetracker.sample()	
    
    		x_sample = curPos[0] - hRes/2
    
    		y_sample = (curPos[1] - (r/2))*-1
    
    		dist = np.sqrt((x_sample**2) + (y_sample**2)) # compute distance from the centre where participants need to fixate
    
    		pupil_size = eyetracker.pupil_size() # if this is 0, it means that the eyes are closed - participants blink
    
    
    
    
    		# log the pupil size. This is important for filtering eyeblinks in real-time
    
    
    
    
    		pupil_log.append(pupil_size)
    
    		pupil_logged = [i for i in pupil_log if i != 0]
    
    		median_pupil_size = np.median(np.asarray(pupil_logged))
    
    		pupil_threshold = median_pupil_size * 0.8 # update threshold for blink detection
    
    
    
    
    		# log the gaze deviation
    
    
    
    
    		dev_log.append(dist)
    
    		curr_dev = np.mean(np.asarray(dev_log[-n_gaze_samples:]))
    
    
    
    
    		if all(i >= pupil_threshold for i in pupil_logged[-9:]):
    
    
    
    
    			if curr_dev > max_gaze_deviation:
    
    				#my_canvas.clear()
    
    				fixation(my_canvas,'blue')
    
    				failed_fixation_vs += 1
    
    				print(failed_fixation_vs)
    
    				my_canvas.show()
    
    				# wait until fixation is correct
    
    
    
    
    			else:
    
    				#my_canvas.clear()
    
    				fixation(my_canvas,'black')
    
    				failed_fixation_vs += 0
    
    				my_canvas.show()
    
    
    
    
    		if (button == [5]) and (target_position[0]==-ray):
    
    			rt = t1/1000 - t0
    
    			hit=1
    
    			sent_eeg_trigger(trigger)
    
    			response_made = True
    
    		elif (button == [6]) and (target_position[0]==ray):
    
    			rt = t1/1000 - t0
    
    			hit=1
    
    			sent_eeg_trigger(trigger)
    
    			response_made = True
    
    		elif core.getTime() - t0 > 2.2:
    
    			rt = np.nan
    
    			hit=0
    
    			response_made = True
    
    		else:
    
    			hit=0
    
    			rt = np.nan
    
    			sent_eeg_trigger(trigger)
    
    			response_made = True
    
    
    
            srbox.stop()
    	search_end = core.getTime()
    
            return rt, hit, search_end, failed_fixation_vs
    

    Many thanks for your help!

  • Ah, while copying the code I see that I wrote srbox.stop() both inside the loop and the other at the end of the function. I had actually written it only at the end of the function in the original code (and yet, it does not work)

  • Hi @ eduard, I realized what the problem was, and I am not sure there is an easy way out. The problem is that the function srbox.get_button_pressed() has a timeout argument. This means that it is not possible to get a timestamp value for the srbox and loop until a response is given. The function srbox.get_button_pressed() "freezes" the loop until a response is given, without allowing me to simultaneously check for the fixation.

    Is there another version of the original function which does not have a timeout defined in it?

  • Hi,

    Yes, exactly, that is indeed the problem. There is a solution, and it actually isn't very difficult. Basically the trick is to have a very small timeout set (a few milliseconds), so that the loop does not freeze, but keeps on running. Then, on every iteration the srbox checks whether a response was given, and process it whenever it happens. Would that work? (I use this procedure a lot with regular keyboard presses, so I am no 100% sure it works as well for the srbox)

    Buy Me A Coffee

  • Hi @eduard,

    thanks! actually I had already tried this, but it means that the response can be given in an extremely narrow temporal window, and so it gets missed most of the times.

    Since I need very high time precision (the effect I am looking for is of the order of 20ms), this would seriously impair my data collection :(

  • Ah okay, this might be an issue. WIth keyboard responses, keypresses are monitored and detected all the times and saved in a buffer that Opensesame can check periodically to find a response. That way, responses usually dont get lost, even if the resp window is only 2 ms or so. However, with the srbox, it seems like there is no such buffer, or the buffer is emptied every time a response is polled. I shall try to find that clearing (in case it happens) in the code tomorrow. If there simply is no buffer for keyboard presses, an alternative would be to monkey patch the sr polling function and add eyetracking functionality to it. I don't think this should be terribly complicated.

    I'll try to have a look into it tomorrow. (but of course feel free to explore by yourself)

    Eduard

    Buy Me A Coffee

  • Hi Sine,

    Can you try to call the get_button_press function with the keyword require_state_change set to False ?

    That might work (if it doesn't break other things)

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games