psychopy.org | Reference | Downloads | Github

Frequency and strange stimuli

timing

#1

Hello,

I am using a DLP lightcrafter 3000 and have a double problem:

  1. First, I can get my screen frequency at 180Hz. But, since my lightcrafter can do 120, 240 or 480Hz, I tried to change the frequency of the program without success.

  2. I show a looming stimuli that consist on a black circle. However, when I lunch the program, in any screen, I obtain circles with strange colors (I will detail below).

  3. For the screen frequency, I went to the file called “windowframepack” and changed as below

             class ProjectorFramePacker(object):
                 """Class which packs 3 monochrome images per RGB frame.
             
                 Allowing 180Hz stimuli with DLP projectors such as TI LightCrafter 4500.
             
                 The class overrides methods of the visual.Window class to pack a
                 monochrome image into each RGB channel. PsychoPy is running at 180Hz.
                 The display device is running at 60Hz.  The output projector is producing
                 images at 180Hz.
             
                 Frame packing can work with any projector which can operate in
                 'structured light mode' where each RGB channel is presented
                 sequentially as a monochrome image.  Most home and office projectors
                 cannot operate in this mode, but projectors designed for machine
                 vision applications typically will offer this feature.
             
                 Example usage to use ProjectorFramePacker::
             
                     from psychopy.visual.windowframepack import ProjectorFramePacker
                     win = Window(monitor='testMonitor', screen=1,
                                  fullscr=True, useFBO = True)
                     framePacker = ProjectorFramePacker (win)
                 """
             
                 def __init__(self, win):
                     """
                     :Parameters:
             
                         win : Handle to the window.
             
                     """
                     super(ProjectorFramePacker, self).__init__()
                     self.win = win
                     # monkey patch window
                     win._startOfFlip = self.startOfFlip
                     win._endOfFlip = self.endOfFlip
             
                     # This part is increasingly ugly.  Add a function to set these values?
                     win._monitorFrameRate = 60.0
                     win.monitorFramePeriod = old_div(1.0, win._monitorFrameRate)
                     win.refreshThreshold = (old_div(1.0, win._monitorFrameRate)) * 1.2
    

However, it did not change anything in term of frequency for the screen.

  1. For the stimuli, I have wrote a complete program using the windowframepack.

             # Imports
             import math
             from psychopy import visual, core, monitors
             import psychopy.event
             import pyautogui
             width, height= pyautogui.size()
             from Parameters import *
             from psychopy.visual.windowframepack import ProjectorFramePacker
             
             
             # Set-up screen
             win = visual.Window([608,684],fullscr=True, color=[255,255,255], colorSpace='rgb255', screen = 1, monitor = "DLP", useFBO = True)
             framePacker = ProjectorFramePacker(win)
             winmenu = visual.Window(size = (400,400), color=[255,255,255], colorSpace='rgb255', screen = 0, monitor="testMonitor")
             clock = core.Clock()
             
             # Menu 
             message = visual.TextStim(winmenu, text='Would you like to: \n\n- Display a looming stimuli at Frame frequency (press 1) \n\n- Display a looming stimuli at 30Hz (press 2) \n\n- Display a looming stimuli at 30Hz with different method (press 3) \n\n- Display a looming stimuli at 60Hz (press 4) \n\n- Display a looming stimuli at 250Hz (press 5) \n\n- Display a looming stimuli at 1000Hz (press 6) \n\n- Static period function (press 7) \n\n- Get refresh rate of displays (press 8) \n\n- Exit (press e)', height=0.06, wrapWidth=800, pos=(0,0), color='black')
             message.setAutoDraw(True)  # automatically draw every frame
             winmenu.flip()
             x=xcorr
             y=ycorr
             stimuli = visual.Circle(win, units='pix', radius=0, edges=e, pos=(x, y), lineColor=[0,0,0], fillColor=[0,0,0])
             while psychopy.event.getKeys != 'e':
                 keys=psychopy.event.waitKeys()
                     
                 # Stimuli approaching
                 if '1' in keys: 
                     timer = core.Clock()
                     for FrameN in range(d,0,-1):
                             stimuli.radius=minr+(2*(maxr)*math.tan(math.exp(-1))/(FrameN+1))
                             stimuli.setAutoDraw(True)  
                             win.flip()
                     ta = timer.getTime()
                     print ('total time: ' + str(ta) + ' sec to show ' + str(d) + ',')
                     tb = ta/d
                     print ('meaning 1 image every ' + str(tb) + ' sec,')
                     tc = 1/tb
                     print ('which corresponds to ' + str(tc) + 'Hz.')
                     stimuli.setAutoDraw(False)
                     win.flip()
             
                 if '2' in keys: 
                     timer = core.Clock()
                     for N in range(d,0,-1):
                         clock.reset()
                         while clock.getTime() < 0.032:
                             stimuli.radius=minr+(2*(maxr)*math.tan(math.exp(-1))/(N))
                             stimuli.setAutoDraw(True)  
                             win.flip()
                     ta = timer.getTime()
                     print ('total time: ' + str(ta) + ' sec to show ' + str(d) + ',')
                     tb = ta/d
                     print ('meaning 1 image every ' + str(tb) + ' sec,')
                     tc = 1/tb
                     print ('which corresponds to ' + str(tc) + 'Hz.')
                     stimuli.setAutoDraw(False)
                     win.flip()
                     
                 if '3' in keys: 
                     timer = core.Clock()
                     clock.reset()
                     for N in range(d,0,-1):
                         stimuli.radius=minr+(2*(maxr)*math.tan(math.exp(-1))/(N))
                         stimuli.setAutoDraw(True)  
                         win.flip()
                         core.wait(0.032)
                     ta = timer.getTime()
                     print ('total time: ' + str(ta) + ' sec to show ' + str(d) + ',')
                     tb = ta/d
                     print ('meaning 1 image every ' + str(tb) + ' sec,')
                     tc = 1/tb
                     print ('which corresponds to ' + str(tc) + 'Hz.')
                     stimuli.setAutoDraw(False)
                     win.flip()
             
                 if '4' in keys: 
                     timer = core.Clock()
                     for N in range(d,0,-1):
                         clock.reset()
                         while clock.getTime() < 0.016:
                             stimuli.radius=minr+(2*(maxr)*math.tan(math.exp(-1))/(N))
                             stimuli.setAutoDraw(True)  
                             win.flip()
                     ta = timer.getTime()
                     print ('total time: ' + str(ta) + ' sec to show ' + str(d) + ',')
                     tb = ta/d
                     print ('meaning 1 image every ' + str(tb) + ' sec,')
                     tc = 1/tb
                     print ('which corresponds to ' + str(tc) + 'Hz.')
                     stimuli.setAutoDraw(False)
                     win.flip()
             
                 if '5' in keys: 
                     timer = core.Clock()
                     for N in range(d,0,-1):
                         clock.reset()
                         while clock.getTime() < 0.004:
                             stimuli.radius=minr+(2*(maxr)*math.tan(math.exp(-1))/(N))
                             stimuli.setAutoDraw(True)  
                             win.flip()
                     ta = timer.getTime()
                     print ('total time: ' + str(ta) + ' sec to show ' + str(d) + ',')
                     tb = ta/d
                     print ('meaning 1 image every ' + str(tb) + ' sec,')
                     tc = 1/tb
                     print ('which corresponds to ' + str(tc) + 'Hz.')
                     stimuli.setAutoDraw(False)
                     win.flip()
             
                 if '6' in keys: 
                     timer = core.Clock()
                     for N in range(d,0,-1):
                         clock.reset()
                         while clock.getTime() < 0.001:
                             stimuli.radius=minr+(2*(maxr)*math.tan(math.exp(-1))/(N))
                             stimuli.setAutoDraw(True)  
                             win.flip()
                     ta = timer.getTime()
                     print ('total time: ' + str(ta) + ' sec to show ' + str(d) + ',')
                     tb = ta/d
                     print ('meaning 1 image every ' + str(tb) + ' sec,')
                     tc = 1/tb
                     print ('which corresponds to ' + str(tc) + 'Hz.')
                     stimuli.setAutoDraw(False)
                     win.flip()
             
                 if '8' in keys: 
                     rate = win.getActualFrameRate(nIdentical=10, nMaxFrames=100, nWarmUpFrames=10, threshold=1)
                     print(rate)
                     rate2 = winmenu.getActualFrameRate(nIdentical=10, nMaxFrames=100, nWarmUpFrames=10, threshold=1)
                     print(rate2)
             
             
                 # Exit
                 if 'e' in keys:    
                     win.close()
                     winmenu.close()
                     core.quit()
                     break
                     
                 # Error
                 else:    
                     message.setAutoDraw(True) 
                     winmenu.flip()     
    

Here, the problem is double:
a) when the windowframepack is ON, I have a frequency of 180Hz, but the stimuli does not disappear when I asked for “stimuli.setAutoDraw(False)”. Without the windowframepack, there is no problem, but the frequency is only 60Hz.
b) Rather than having black circles, the circles have different circles with different colours. For example, black in the center, green as intermediate and yellow around. I also found two different nuances of blues…

I thank you in advance for your kind help concerning this problem.