def __init__(self, subject):
     """ Fixation """
     fp = dictattr()
     fp.bgbrightness = 0.5
     fp.color = (1.0, 0.0, 0.0, 1.0)
     fp.width = 0.25
     
     self.fixation_left = Fixation(viewport='left', subject=subject, params=fp)
     self.fixation_right = Fixation(viewport='right', subject=subject, params=fp)        
     
     """ Random Dots with disc"""
     dp = dictattr()
     dp.bgbrightness = 0.5
     dp.antialiase = True
     
     dp.dotSquareWidth = 7.5
     dp.dotsNumber = 2000
     dp.randomSeed = 0
     dp.dotColor = (0.8, 0.8, 0.8)
     dp.dotSize = 3
     dp.discDistDeg = 2.5
     dp.discDiameter = 1.25
     dp.disparity = 0
     
     self.dp = dp
     self.subject = subject
     self.disc_left = StereoDisc(viewport='left', subject=subject, params=dp)
     self.disc_right = StereoDisc(viewport='right', subject=subject, params=dp)
     
     """ Mask: Random Dots """
     mp = dictattr()
     mp.bgbrightness = 0.5
     mp.antialiase = True
     
     mp.dotSquareWidth = 7.5
     mp.dotsNumber = 4500
     mp.randomSeed = 1
     mp.dotColor = (1, 1, 1)
     mp.dotSize = 2
     
     self.mp = mp
     self.mask_left = RandomDots(viewport='left', subject=subject, params=mp)
     self.mask_right = RandomDots(viewport='right', subject=subject, params=mp)
     
     """ Hint """
     hp = dictattr()
     hp.bgbrightness = 0.5
     hp.text = "Press left or right for disc interval."
     hp.xorigDeg = 5.0
     hp.yorigDeg = 0.0
     hp.color = (1.0, 0.0, 0.0, 1.0)
     hp.fontsize = 25
     self.hint_left = Hint(viewport="left", params=hp)
     hp.xorigDeg = -5.0
     self.hint_right = Hint(viewport="right", params=hp)
     
     self.sweep = FrameSweep()
     self.key_response = LeftRightKeyResponse(self.sweep)
     self.mouse_response = LeftRightMouseResponse(self.sweep)        
Exemple #2
0
 def __init__(self, subject, eye):
     """ Fixation """
     fp = dictattr()
     fp.bgbrightness = 0.5
     fp.color = (1.0, 0.0, 0.0, 1.0)
     fp.width = 0.25
     
     self.fixation_left = Fixation(viewport='left', subject=subject, params=fp)
     self.fixation_right = Fixation(viewport='right', subject=subject, params=fp)
     
     """ SED Grating """
     gp = dictattr()
     gp.bgbrightness = 0.5
     gp.on = True
     gp.mask = "circle"
     gp.ml = 0.5
     gp.sfreqCycDeg = 3.0
     gp.tfreqCycSec = 0.0
     gp.phase0 = 0
     gp.contrast = 0.5
     gp.ori = 0.0
     gp.maskDiameterDeg = 1.25
     gp.radius = 2.0
     
     self.grating_left = SEDGrating(viewport='left', subject=subject, params=gp)
     gp.ori = 90.0
     self.grating_right = SEDGrating(viewport='right', subject=subject, params=gp)
     
     """ Mask """
     mp = dictattr()
     mp.bgbrightness = 0.5
     mp.ml = (0.5, 0.5)
     mp.ori = (0.0, 90.0)
     mp.sfreqCycDeg = (3.0, 3.0)
     mp.tfreqCycSec = (0.0, 0.0)
     
     self.plaid_left = Plaid(viewport="left", params=mp)
     self.plaid_right = Plaid(viewport="right", params=mp)
     
     """ Hint """
     hp = dictattr()
     hp.bgbrightness = 0.5
     hp.text = "Press left(right) or up(down) for grating orientation."
     hp.xorigDeg = 5.0
     hp.yorigDeg = 0.0
     hp.color = (1.0, 0.0, 0.0, 1.0)
     hp.fontsize = 25
     self.hint_left = Hint(viewport="left", params=hp)
     hp.xorigDeg = -5.0
     self.hint_right = Hint(viewport="right", params=hp)
     
     self.sweep = FrameSweep()
     self.key_response = LeftRightKeyResponse(self.sweep)
     self.mouse_response = LeftRightMouseResponse(self.sweep)
     
     self.test_eye = eye
p.contrast = 1
# background brightness (0-1)
p.bgbrightness = 0.5
# antialiase the bar?
p.antialiase = True
# flash the grating?
p.flash = False
# duration of each on period (sec)
p.flashduration = 0.5
# duration of each off period (sec)
p.flashinterval = 0.3
# factor to chage bar width and height by left/right/up/down key
p.sizemultiplier = 1.02
# factor to change temporal freq by on up/down
p.tfreqmultiplier = 1.01
# factor to change spatial freq by on left/right
p.sfreqmultiplier = 1.01
# factor to change contrast by on +/-
p.contrastmultiplier = 1.005
# orientation step size to snap to when scrolling mouse wheel (deg)
p.snapDeg = 12

stimulus_control = ManGrating(disp_info=True, params=p, viewport='control')
stimulus_left = ManGrating(disp_info=False, params=p, viewport='left')
stimulus_right = ManGrating(disp_info=False, params=p, viewport='right')

sweep = FrameSweep()
sweep.add_stimulus(stimulus_control)
sweep.add_stimulus(stimulus_left)
sweep.add_stimulus(stimulus_right)
sweep.go()
Exemple #4
0
p.contrast = 1
# background brightness (0-1)
p.bgbrightness = 0.5
# antialiase the bar?
p.antialiase = True
# flash the grating?
p.flash = False
# duration of each on period (sec)
p.flashduration = 0.5
# duration of each off period (sec)
p.flashinterval = 0.3
# factor to chage bar width and height by left/right/up/down key
p.sizemultiplier = 1.02
# factor to change temporal freq by on up/down
p.tfreqmultiplier = 1.01
# factor to change spatial freq by on left/right
p.sfreqmultiplier = 1.01
# factor to change contrast by on +/-
p.contrastmultiplier = 1.005
# orientation step size to snap to when scrolling mouse wheel (deg)
p.snapDeg = 12

stimulus_control = ManGrating(disp_info=True, params=p, viewport='control')
stimulus_left = ManGrating(disp_info=False, params=p, viewport='left')
stimulus_right = ManGrating(disp_info=False, params=p, viewport='right')

sweep = FrameSweep()
sweep.add_stimulus(stimulus_control)
sweep.add_stimulus(stimulus_left)
sweep.add_stimulus(stimulus_right)
sweep.go()
Exemple #5
0
p_left.contrast = 1.0

p_right = dictattr()
p_right.layout = layout
p_right.bgbrightness = 0.0
p_right.contrast = 0.5

cycle_left = dictattr(duration=0.04, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.04, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=None, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=None, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

if __name__ == '__main__':
    sweep = FrameSweep()
    movie_left = TimingSetMovie(viewport='left', 
                                surface=pygame_surface, texture_obj=texture_object,
                                params=p_left, subject=subject, sweepseq=sequence_left)
    movie_right = TimingSetMovie(viewport='right',
                                 surface=pygame_surface, texture_obj=texture_object,
                                 params=p_right, subject=subject, sweepseq=sequence_right)
    sweep.add_stimulus(movie_left)
    sweep.add_stimulus(movie_right)
    sweep.add_quit_callback(movie.stop)
    
    movie.play()
    #sweep.go(prestim=0.5,poststim=0.5)
    import cProfile,pstats
    cProfile.run('sweep.go()','movie_profile')
    p = pstats.Stats('movie_profile')
from StimControl.LightStim.LightData import dictattr,IndexedParam

DefaultScreen(['left','right'])

p = dictattr()
p.ml = 0.5
p.tfreqCycSec = 2.0
p.bgbrightness = 0.0
p.phase0 = 0
p.contrast = 1

orientation = IndexedParam('orientation')
spatial_freq = [None]
phase_at_t0 = [None]

param_sequence = ParamSeque(repeat=4, orientation=orientation, spatial_freq=spatial_freq, phase_at_t0=phase_at_t0, frame_duration=2.0, blank_duration=1.0)

random_grating = ParamsGrating(viewport='left', params=p, sweepseq=param_sequence)

import pickle
with open('test_pickle.pkl','w') as file:
    pickle.dump(random_grating,file,1)
with open('test_pickle.pkl','r') as file:
    unpckled_stim = pickle.load(file)
    
sweep = FrameSweep()
sweep.add_stimulus(unpckled_stim)

sweep.go()

pre_left = 0.0 if stim_interval > 0 else abs(stim_interval)
pre_right = 0.0 if stim_interval <= 0 else stim_interval

repeats = 1000
rand_phase = True

cycle_left = dictattr(duration=0.132, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.132, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=repeats, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=repeats, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

fp = dictattr()
fp.color = (1.0, 0.0, 0.0, 1.0)
fp.width = 0.25

fixation_left = Fixation(viewport='left', subject=subject, params=fp)
fixation_right = Fixation(viewport='right', subject=subject, params=fp)

for i in range(6):
    sweep = FrameSweep()
    grating_left = RandOriTimingSetGrating(viewport='left', params=p_left, subject=subject, sweepseq=sequence_left)
    grating_right = OrthOriTimingSetGrating(viewport='right', params=p_right, subject=subject, sweepseq=sequence_right)
    sweep.add_stimulus(grating_left)
    sweep.add_stimulus(grating_right)
    sweep.add_stimulus(fixation_left)
    sweep.add_stimulus(fixation_right)
    sweep.go(prestim=5.0,poststim=5.0,duration=(150.0,'seconds'))
# Copyright (C) 2010-2011 Huang Xin
#
# See LICENSE.TXT that came with this file.

from __future__ import division
from StimControl.LightStim.SweepSeque import ParamSeque
from StimControl.LightStim.LightData import dictattr
from StimControl.LightStim.FrameControl import FrameSweep
from StimControl.LightStim.Grating import ParamsGrating
from StimControl.LightStim.Core import DefaultScreen
from StimControl.LightStim.LightData import IndexedParam

DefaultScreen(['left','right'])

p = dictattr()
p.ml = 0.5
p.tfreqCycSec = 2.0
p.bgbrightness = 0.0
p.phase0 = 0
p.contrast = 1

orientation = [None]
spatial_freq = IndexedParam('spatial_freq')
phase_at_t0 = [None]

param_sequence = ParamSeque(repeat=4, orientation=orientation, spatial_freq=spatial_freq, phase_at_t0=phase_at_t0, frame_duration=2.0, blank_duration=1.0)

random_grating = ParamsGrating(viewport='left', params=p, sweepseq=param_sequence)
sweep = FrameSweep()
sweep.add_stimulus(random_grating)
sweep.go()
"""Background settings"""
# background brightness (0-1)
p.bgbrightness = 0.5
# screen gamma: None, or single value, or 3-tuple
p.gamma = None
"""CheckBoard settings"""
p.checkbdon = False
p.cbcolormap = 'ggr'
"""Noise settings"""
# sweep duration (sec)
p.sweepSec = 0.04
# post-sweep duration to display blank screen (sec)
p.postsweepSec = 0.0
# noise position index in stimulus grid
x_index = range(p.griddim[0])
y_index = range(p.griddim[1])
contrast = [0, 1]

noise_sequence = SparseNoiseSeque(repeat=4,
                                  x_index=x_index,
                                  y_index=y_index,
                                  contrast=contrast,
                                  frame_duration=p.sweepSec,
                                  blank_duration=p.postsweepSec)

stimulus_left = WhiteNoise(viewport=eye, params=p, sweepseq=noise_sequence)

sweep = FrameSweep()
sweep.add_stimulus(stimulus_left)
sweep.go(prestim=15.0, poststim=5.0, RSTART=True)
Pyro.config.PYRO_TRACELEVEL = 3
Pyro.config.PYRO_PICKLE_FORMAT = 1


class StimulusPoolController(SweepController,Pyro.core.ObjBase):
    """ Maintain a stimulus pool and synchronize the pool with sweep viewport
    """
    def __init__(self,*arg,**kw):
        super(StimulusPoolController, self).__init__(*arg,**kw)
        Pyro.core.ObjBase.__init__(self)
    def add_stimulus(self,stimulus):
        self.framesweep.add_stimulus(stimulus)
    def remove_stimulus(self,stimulus):
        pass

sweep = FrameSweep()
dummy_stimulus = Dummy_Stimulus()
sweep.add_stimulus(dummy_stimulus)

pyro_server = PyroServer()

#quit_controller = PyroConstantController(during_go_value=0)
#pyro_server.connect(quit_controller,'quit_controller')
#sweep.add_controller(sweep,'quit', quit_controller)
#sweep.add_controller(None,None, pyro_server.create_listener_controller())

stimulus_pool = StimulusPoolController(framesweep=sweep)
pyro_server.connect(stimulus_pool,'stimulus_pool')
sweep.add_controller(None,None, stimulus_pool)
sweep.add_controller(None,None, pyro_server.create_listener_controller())
p.bgbrightness = 0.5
# screen gamma: None, or single value, or 3-tuple
p.gamma = None
"""CheckBoard settings"""
p.checkbdon = False
p.cbcolormap = 'ggr'

"""Noise settings"""
# sweep duration (sec)
p.sweepSec = 0.04
# post-sweep duration to display blank screen (sec)
p.postsweepSec = 0.0
# noise position index in stimulus grid
x_index = range(p.griddim[0])
y_index = range(p.griddim[1])
contrast = [0,1]

noise_sequence = SparseNoiseSeque(repeat=8, x_index=x_index, y_index=y_index, contrast=contrast, frame_duration=p.sweepSec, blank_duration=p.postsweepSec)

stimulus_left = WhiteNoise(viewport='left', params=p, sweepseq=noise_sequence)

sweep = FrameSweep()
sweep.add_stimulus(stimulus_left)

import cProfile,pstats
cProfile.run('sweep.go(preframesweepSec, postframesweepSec)','sparse_noise_profile')
p = pstats.Stats('sparse_noise_profile')
p.sort_stats('cumulative')
p.print_stats()

DefaultScreen(['left','right'])

p = dictattr()
p.ml = 0.5
p.tfreqCycSec = 0.0
p.bgbrightness = 0.5
p.phase0 = 0
p.contrast = 1

stim_interval = 0.0

pre_left = 0.0 if stim_interval > 0 else abs(stim_interval)
pre_right = 0.0 if stim_interval <= 0 else stim_interval

repeats = 1600

cycle_left = dictattr(duration=0.132, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.132, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=repeats, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=repeats, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

grating_left = TimingSetGrating(viewport='left', params=p, sweepseq=sequence_left)
p.phase0 = 180.0
grating_right = TimingSetGrating(viewport='right', params=p, sweepseq=sequence_right)
sweep = FrameSweep()
sweep.add_stimulus(grating_left)
sweep.add_stimulus(grating_right)
sweep.go()
Exemple #13
0
class Disparity(object):
    def __init__(self, subject):
        """ Fixation """
        fp = dictattr()
        fp.bgbrightness = 0.5
        fp.color = (1.0, 0.0, 0.0, 1.0)
        fp.width = 0.25
        
        self.fixation_left = Fixation(viewport='left', subject=subject, params=fp)
        self.fixation_right = Fixation(viewport='right', subject=subject, params=fp)        
        
        """ Random Dots with disc"""
        dp = dictattr()
        dp.bgbrightness = 0.5
        dp.antialiase = True
        
        dp.dotSquareWidth = 7.5
        dp.dotsNumber = 2000
        dp.randomSeed = 0
        dp.dotColor = (0.8, 0.8, 0.8)
        dp.dotSize = 3
        dp.discDistDeg = 2.5
        dp.discDiameter = 1.25
        dp.disparity = 0
        
        self.dp = dp
        self.subject = subject
        self.disc_left = StereoDisc(viewport='left', subject=subject, params=dp)
        self.disc_right = StereoDisc(viewport='right', subject=subject, params=dp)
        
        """ Mask: Random Dots """
        mp = dictattr()
        mp.bgbrightness = 0.5
        mp.antialiase = True
        
        mp.dotSquareWidth = 7.5
        mp.dotsNumber = 4500
        mp.randomSeed = 1
        mp.dotColor = (1, 1, 1)
        mp.dotSize = 2
        
        self.mp = mp
        self.mask_left = RandomDots(viewport='left', subject=subject, params=mp)
        self.mask_right = RandomDots(viewport='right', subject=subject, params=mp)
        
        """ Hint """
        hp = dictattr()
        hp.bgbrightness = 0.5
        hp.text = "Press left or right for disc interval."
        hp.xorigDeg = 5.0
        hp.yorigDeg = 0.0
        hp.color = (1.0, 0.0, 0.0, 1.0)
        hp.fontsize = 25
        self.hint_left = Hint(viewport="left", params=hp)
        hp.xorigDeg = -5.0
        self.hint_right = Hint(viewport="right", params=hp)
        
        self.sweep = FrameSweep()
        self.key_response = LeftRightKeyResponse(self.sweep)
        self.mouse_response = LeftRightMouseResponse(self.sweep)        
    
    def set_disparity(self, disp):
        self.disparity = disp
    
    def update_disparity(self, cross):
        if random.choice([True, False]):
            self.disc_left.parameters.disparity = self.disparity if cross else 0
            self.disc_right.parameters.disparity = 0
        else:
            self.disc_left.parameters.disparity = 0
            self.disc_right.parameters.disparity = self.disparity if cross else 0
    
    def get_cross_interval(self):
        return self.cross_interval
    
    def demo(self):
        self.update_disparity(cross=True)
        self.sweep.add_stimulus(self.disc_left)
        self.sweep.add_stimulus(self.disc_right)
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.add_controller(None, None, self.key_response)
        self.sweep.add_controller(None, None, self.mouse_response)
        self.sweep.go(duration=('forever',''))
        
    def run(self):
        random.seed()
        self.cross_interval = random.choice([1,2])
        """ Randomize dots """
        self.dp.randomSeed = random.randint(0,1000)
        self.disc_left = StereoDisc(viewport='left', subject=self.subject, params=self.dp)
        self.disc_right = StereoDisc(viewport='right', subject=self.subject, params=self.dp)
        self.mp.randomSeed = random.randint(0,1000)
        self.mask_left = RandomDots(viewport='left', subject=self.subject, params=self.mp)
        self.mask_right = RandomDots(viewport='right', subject=self.subject, params=self.mp)
        """ Fixation """
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(2.0,'seconds'))
        """ Interval-1 """
        self.update_disparity(self.cross_interval == 1)
        self.sweep.add_stimulus(self.disc_left)
        self.sweep.add_stimulus(self.disc_right)
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.2,'seconds'))
        """ Blank """
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.4,'seconds'))
        """ Interval-2 """
        self.update_disparity(self.cross_interval == 2)
        self.sweep.add_stimulus(self.disc_left)
        self.sweep.add_stimulus(self.disc_right)
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.2,'seconds'))
        """ Blank """
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.4,'seconds'))
        """ Mask """
        self.sweep.add_stimulus(self.mask_left)
        self.sweep.add_stimulus(self.mask_right)
        self.sweep.go(duration=(0.5,'seconds'))
        
        self.sweep.add_controller(None, None, self.key_response)
        self.sweep.add_controller(None, None, self.mouse_response)
        #self.sweep.add_stimulus(self.hint_left)
        #self.sweep.add_stimulus(self.hint_right)
        self.sweep.go(duration=('forever',''))
        key_response = self.key_response.get_last_response_since_go()
        mouse_response = self.mouse_response.get_last_response_since_go()
        if key_response == "left" or mouse_response == "left_button":
            return self.cross_interval == 1
        elif key_response == "right" or mouse_response == "right_button":
            return self.cross_interval == 2
        else:
            raise RuntimeError("Key or button press is not direction.")
p.gridmag = 2
# noise magnification fator relative to grid cell size
p.widthmag = 2
p.heightmag = 1
"""Background settings"""
# background brightness (0-1)
p.bgbrightness = 0.5
# screen gamma: None, or single value, or 3-tuple
p.gamma = None
"""CheckBoard settings"""
p.checkbdon = False
p.cbcolormap = 'ggr'

"""Noise settings"""
# sweep duration (sec)
p.sweepSec = 0.04
# post-sweep duration to display blank screen (sec)
p.postsweepSec = 0.0
# noise position index in stimulus grid
x_index = range(p.griddim[0])
y_index = range(p.griddim[1])
contrast = [0,1]

noise_sequence = SparseNoiseSeque(repeat=4, x_index=x_index, y_index=y_index, contrast=contrast, frame_duration=p.sweepSec, blank_duration=p.postsweepSec)

stimulus_left = WhiteNoise(viewport=eye, params=p, sweepseq=noise_sequence)

sweep = FrameSweep()
sweep.add_stimulus(stimulus_left)
sweep.go(prestim=15.0,poststim=5.0,RSTART=True)
p_left.layout = layout
p_left.bgbrightness = 0.0
p_left.contrast = 1.0

p_right = dictattr()
p_right.layout = layout
p_right.bgbrightness = 0.0
p_right.contrast = 0.5

cycle_left = dictattr(duration=0.016, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.016, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=None, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=None, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

if __name__ == '__main__':
    sweep = FrameSweep()
    movie_left = TimingSetMovie(viewport='left', 
                                surface=pygame_surface, texture_obj=texture_object,
                                params=p_left, subject=subject, sweepseq=sequence_left)
    movie_right = TimingSetMovie(viewport='right',
                                 surface=pygame_surface, texture_obj=texture_object,
                                 params=p_right, subject=subject, sweepseq=sequence_right)
    sweep.add_stimulus(movie_left)
    sweep.add_stimulus(movie_right)
    sweep.add_quit_callback(movie.stop)
    
    movie.play()
    sweep.go(prestim=0.5,poststim=0.5)
p.checkbdon = False
p.cbcolormap = 'ggr'
"""Noise settings"""
# sweep duration (sec)
p.sweepSec = 0.04
# post-sweep duration to display blank screen (sec)
p.postsweepSec = 0.0
# noise position index in stimulus grid
x_index = range(p.griddim[0])
y_index = range(p.griddim[1])
contrast = [0, 1]

noise_sequence = SparseNoiseSeque(repeat=8,
                                  x_index=x_index,
                                  y_index=y_index,
                                  contrast=contrast,
                                  frame_duration=p.sweepSec,
                                  blank_duration=p.postsweepSec)

stimulus_left = WhiteNoise(viewport='left', params=p, sweepseq=noise_sequence)

sweep = FrameSweep()
sweep.add_stimulus(stimulus_left)

import cProfile, pstats
cProfile.run('sweep.go(preframesweepSec, postframesweepSec)',
             'sparse_noise_profile')
p = pstats.Stats('sparse_noise_profile')
p.sort_stats('cumulative')
p.print_stats()
Exemple #17
0
#
# See LICENSE.TXT that came with this file.

from __future__ import division
from StimControl.LightStim.SweepSeque import ParamSeque
from StimControl.LightStim.FrameControl import FrameSweep
from StimControl.LightStim.Grating import ParamsGrating
from StimControl.LightStim.Core import DefaultScreen
from StimControl.LightStim.LightData import dictattr, IndexedParam

DefaultScreen(['left', 'right'])

p = dictattr()
p.ml = 0.5
p.tfreqCycSec = 2.0
p.bgbrightness = 0.0
p.phase0 = 0
p.contrast = 1

orientation = IndexedParam('orientation')
param_sequence = ParamSeque(repeat=4,
                            orientation=orientation,
                            frame_duration=2.0,
                            blank_duration=1.0)

random_grating = ParamsGrating(viewport='left',
                               params=p,
                               sweepseq=param_sequence)
sweep = FrameSweep()
sweep.add_stimulus(random_grating)
sweep.go()
Exemple #18
0
p_left.contrast = 1.0

p_right = dictattr()
p_right.layout = layout
p_right.bgbrightness = 0.0
p_right.contrast = 0.5

cycle_left = dictattr(duration=0.016, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.016, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=None, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=None, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

if __name__ == '__main__':
    sweep = FrameSweep()
    movie_left = TimingSetMovie(viewport='left',
                                surface=pygame_surface,
                                texture_obj=texture_object,
                                params=p_left,
                                subject=subject,
                                sweepseq=sequence_left)
    movie_right = TimingSetMovie(viewport='right',
                                 surface=pygame_surface,
                                 texture_obj=texture_object,
                                 params=p_right,
                                 subject=subject,
                                 sweepseq=sequence_right)
    sweep.add_stimulus(movie_left)
    sweep.add_stimulus(movie_right)
    sweep.add_quit_callback(movie.stop)
Exemple #19
0
# Generate random orientation and spatial frequency gratings.
#
# Copyright (C) 2010-2011 Huang Xin
#
# See LICENSE.TXT that came with this file.

from __future__ import division
from StimControl.LightStim.SweepSeque import ParamSeque
from StimControl.LightStim.FrameControl import FrameSweep
from StimControl.LightStim.Grating import PhaseGrating
from StimControl.LightStim.Core import DefaultScreen
from StimControl.LightStim.LightData import dictattr,IndexedParam

DefaultScreen(['left','right'])

p = dictattr()
p.ml = 0.5
p.tfreqCycSec = 0.0
p.bgbrightness = 0.0
p.phase0 = 0
p.contrast = 1

phase_at_t0 = IndexedParam('phase_at_t0')
param = ParamSeque(repeat=4, phase_at_t0=phase_at_t0, frame_duration=1.0, blank_duration=1.0)
grating = PhaseGrating(viewport='left', params=p, sweepseq=param)

sweep = FrameSweep()
sweep.add_stimulus(grating)
sweep.go()
p.tfreqCycSec = 0.0
p.bgbrightness = 0.5
p.phase0 = 0
p.contrast = 1

stim_interval = 0.0

pre_left = 0.0 if stim_interval > 0 else abs(stim_interval)
pre_right = 0.0 if stim_interval <= 0 else stim_interval

repeats = 1600

cycle_left = dictattr(duration=0.132, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.132, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=repeats, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=repeats, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

grating_left = TimingSetGrating(viewport='left',
                                params=p,
                                sweepseq=sequence_left)
p.phase0 = 180.0
grating_right = TimingSetGrating(viewport='right',
                                 params=p,
                                 sweepseq=sequence_right)
sweep = FrameSweep()
sweep.add_stimulus(grating_left)
sweep.add_stimulus(grating_right)
sweep.go()
repeats = 1600
rand_phase = False
orth_eye = 'left'

cycle_left = dictattr(duration=0.132, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.132, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=repeats, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=repeats, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

if rand_phase:
    if orth_eye is None:
        grating_left = RandPhaseTimingSetGrating(viewport='left', params=p_left, sweepseq=sequence_left)
        grating_right = RandPhaseTimingSetGrating(viewport='right', params=p_right, sweepseq=sequence_right)
    elif orth_eye == 'left':
        grating_left = OrthOriTimingSetGrating(viewport='left', params=p_left, sweepseq=sequence_left)
        grating_right = RandPhaseTimingSetGrating(viewport='right', params=p_right, sweepseq=sequence_right)
    elif orth_eye == 'right':
        grating_left = RandPhaseTimingSetGrating(viewport='left', params=p_left, sweepseq=sequence_left)
        grating_right = OrthOriTimingSetGrating(viewport='right', params=p_right, sweepseq=sequence_right)
else:
    grating_left = TimingSetGrating(viewport='left', params=p_left, sweepseq=sequence_left)
    grating_right = TimingSetGrating(viewport='right', params=p_right, sweepseq=sequence_right)
    
sweep = FrameSweep()
sweep.add_stimulus(grating_left)
sweep.add_stimulus(grating_right)
sweep.go(prestim=5.0,poststim=5.0,RSTART=True)
Exemple #22
0
class SED(object):
    def __init__(self, subject, eye):
        """ Fixation """
        fp = dictattr()
        fp.bgbrightness = 0.5
        fp.color = (1.0, 0.0, 0.0, 1.0)
        fp.width = 0.25
        
        self.fixation_left = Fixation(viewport='left', subject=subject, params=fp)
        self.fixation_right = Fixation(viewport='right', subject=subject, params=fp)
        
        """ SED Grating """
        gp = dictattr()
        gp.bgbrightness = 0.5
        gp.on = True
        gp.mask = "circle"
        gp.ml = 0.5
        gp.sfreqCycDeg = 3.0
        gp.tfreqCycSec = 0.0
        gp.phase0 = 0
        gp.contrast = 0.5
        gp.ori = 0.0
        gp.maskDiameterDeg = 1.25
        gp.radius = 2.0
        
        self.grating_left = SEDGrating(viewport='left', subject=subject, params=gp)
        gp.ori = 90.0
        self.grating_right = SEDGrating(viewport='right', subject=subject, params=gp)
        
        """ Mask """
        mp = dictattr()
        mp.bgbrightness = 0.5
        mp.ml = (0.5, 0.5)
        mp.ori = (0.0, 90.0)
        mp.sfreqCycDeg = (3.0, 3.0)
        mp.tfreqCycSec = (0.0, 0.0)
        
        self.plaid_left = Plaid(viewport="left", params=mp)
        self.plaid_right = Plaid(viewport="right", params=mp)
        
        """ Hint """
        hp = dictattr()
        hp.bgbrightness = 0.5
        hp.text = "Press left(right) or up(down) for grating orientation."
        hp.xorigDeg = 5.0
        hp.yorigDeg = 0.0
        hp.color = (1.0, 0.0, 0.0, 1.0)
        hp.fontsize = 25
        self.hint_left = Hint(viewport="left", params=hp)
        hp.xorigDeg = -5.0
        self.hint_right = Hint(viewport="right", params=hp)
        
        self.sweep = FrameSweep()
        self.key_response = LeftRightKeyResponse(self.sweep)
        self.mouse_response = LeftRightMouseResponse(self.sweep)
        
        self.test_eye = eye
        
    def update_orientation(self):
        self.test_eye_ori = random.choice([0, 90])
        if self.test_eye == "left":
            self.grating_left.parameters.ori = self.test_eye_ori
            self.grating_right.parameters.ori = abs(self.test_eye_ori - 90)
        else:
            self.grating_left.parameters.ori = abs(self.test_eye_ori - 90)
            self.grating_right.parameters.ori = self.test_eye_ori
        # if self.test_eye == "left":
            # self.grating_left.parameters.ori = self.orientation["test"][0]
            # self.grating_right.parameters.ori = self.orientation["control"][0]
        # else:
            # self.grating_left.parameters.ori = self.orientation["control"][0]
            # self.grating_right.parameters.ori = self.orientation["test"][0]

    def update_test_contrast(self, contrast):
        if self.test_eye == "left":
            self.grating_left.parameters.contrast = contrast
        elif self.test_eye == "right":
            self.grating_right.parameters.contrast = contrast
            
    def update_control_contrast(self, contrast):
        if self.test_eye == "left":
            self.grating_right.parameters.contrast = contrast
        elif self.test_eye == "right":
            self.grating_left.parameters.contrast = contrast
            
    def get_test_eye(self):
        return self.test_eye
    
    def get_test_eye_orientation(self):
        if self.test_eye_ori == 0:
            return "horizontal"
        else:
            return "vertical"
        #return self.orientation["test"][1]
    
    def run(self):
        #self.sweep = FrameSweep()
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(2.0,'seconds'))
        self.sweep.add_stimulus(self.grating_left)
        self.sweep.add_stimulus(self.grating_right)
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.5,'seconds'))
        self.sweep.add_stimulus(self.plaid_left)
        self.sweep.add_stimulus(self.plaid_right)
        self.sweep.go(duration=(0.2,'seconds'))
        self.sweep.add_controller(None, None, self.key_response)
        self.sweep.add_controller(None, None, self.mouse_response)
        #self.sweep.add_stimulus(self.hint_left)
        #self.sweep.add_stimulus(self.hint_right)
        self.sweep.go(duration=('forever',''))
        key_response = self.key_response.get_last_response_since_go()
        mouse_response = self.mouse_response.get_last_response_since_go()
        if key_response in ("left", "right") or mouse_response == "left_button":
            return "horizontal"
        elif key_response in ("up", "down") or mouse_response == "right_button":
            return "vertical"            
        else:
            raise RuntimeError("Key or button press is not direction.")
Exemple #23
0
class StimulusPoolController(SweepController, Pyro.core.ObjBase):
    """ Maintain a stimulus pool and synchronize the pool with sweep viewport
    """
    def __init__(self, *arg, **kw):
        super(StimulusPoolController, self).__init__(*arg, **kw)
        Pyro.core.ObjBase.__init__(self)

    def add_stimulus(self, stimulus):
        self.framesweep.add_stimulus(stimulus)

    def remove_stimulus(self, stimulus):
        pass


sweep = FrameSweep()
dummy_stimulus = Dummy_Stimulus()
sweep.add_stimulus(dummy_stimulus)

pyro_server = PyroServer()

#quit_controller = PyroConstantController(during_go_value=0)
#pyro_server.connect(quit_controller,'quit_controller')
#sweep.add_controller(sweep,'quit', quit_controller)
#sweep.add_controller(None,None, pyro_server.create_listener_controller())

stimulus_pool = StimulusPoolController(framesweep=sweep)
pyro_server.connect(stimulus_pool, 'stimulus_pool')
sweep.add_controller(None, None, stimulus_pool)
sweep.add_controller(None, None, pyro_server.create_listener_controller())
p_right.contrast = 1.0

cycle_left = dictattr(duration=0.016, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.016, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=None, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=None, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

if __name__ == '__main__':
    player = MoviePlayer(argv[-1])
    width, height = player.get_size()
    buffer_data = multiprocessing.sharedctypes.RawArray('B', width*height*3)
    player.set_buffer(buffer_data)
    
    sweep = FrameSweep()
    pygame_surface = pygame.surface.Surface((width,height))
    movie_left = TimingSetMovie(viewport='left', 
                                surface=pygame_surface,
                                texture_obj=BufferedTextureObject(buffer_data, dimensions=2),
                                params=p_left, subject=subject, sweepseq=sequence_left)
    movie_right = TimingSetMovie(viewport='right',
                                 surface=pygame_surface,
                                 texture_obj=BufferedTextureObject(buffer_data, dimensions=2),
                                 params=p_right, subject=subject, sweepseq=sequence_right)
    sweep.add_stimulus(movie_left)
    sweep.add_stimulus(movie_right)
    sweep.add_quit_callback(player.stop)
    player.seek(seek)
    player.start()
    sweep.go()
cycle_left = dictattr(duration=0.132, pre=pre_left, stimulus=0.016)
cycle_right = dictattr(duration=0.132, pre=pre_right, stimulus=0.016)
block_left = dictattr(repeat=repeats, cycle=cycle_left, interval=0.0)
block_right = dictattr(repeat=repeats, cycle=cycle_right, interval=0.0)
sequence_left = TimingSeque(repeat=1, block=block_left, shuffle=True)
sequence_right = TimingSeque(repeat=1, block=block_right, shuffle=True)

fp = dictattr()
fp.color = (1.0, 0.0, 0.0, 1.0)
fp.width = 0.25

fixation_left = Fixation(viewport='left', subject=subject, params=fp)
fixation_right = Fixation(viewport='right', subject=subject, params=fp)

for i in range(2):
    sweep = FrameSweep()
    grating_left = RandOriTimingSetGrating(viewport='left',
                                           params=p_left,
                                           subject=subject,
                                           sweepseq=sequence_left)
    grating_right = RandOriTimingSetGrating(viewport='right',
                                            params=p_right,
                                            subject=subject,
                                            sweepseq=sequence_right)
    sweep.add_stimulus(grating_left)
    sweep.add_stimulus(grating_right)
    sweep.add_stimulus(fixation_left)
    sweep.add_stimulus(fixation_right)
    sweep.go(prestim=5.0, poststim=5.0, duration=(150.0, 'seconds'))
p.gridmag = 2
# noise magnification fator relative to grid cell size
p.widthmag = 4
p.heightmag = 1
"""Background settings"""
# background brightness (0-1)
p.bgbrightness = 0.5
# screen gamma: None, or single value, or 3-tuple
p.gamma = None
"""CheckBoard settings"""
p.checkbdon = False
p.cbcolormap = 'ggr'

"""Noise settings"""
# sweep duration (sec)
p.sweepSec = 0.04
# post-sweep duration to display blank screen (sec)
p.postsweepSec = 0.0
# noise position index in stimulus grid
x_index = range(p.griddim[0])
y_index = range(p.griddim[1])
contrast = [0,1]

noise_sequence = SparseNoiseSeque(repeat=8, x_index=x_index, y_index=y_index, contrast=contrast, frame_duration=p.sweepSec, blank_duration=p.postsweepSec)

stimulus_left = WhiteNoise(viewport='right', params=p, sweepseq=noise_sequence)

sweep = FrameSweep()
sweep.add_stimulus(stimulus_left)
sweep.go(prestim=preframesweepSec, poststim=postframesweepSec)
# Generate random phase grating.
#
# Copyright (C) 2010-2011 Huang Xin
#
# See LICENSE.TXT that came with this file.

from __future__ import division
from StimControl.LightStim.SweepSeque import ParamSeque
from StimControl.LightStim.FrameControl import FrameSweep
from StimControl.LightStim.Grating import ParamsGrating
from StimControl.LightStim.LightData import dictattr

eye = 'left'

p = dictattr()
p.ml = 0.5
p.tfreqCycSec = 0.0
p.bgbrightness = 0.0
p.phase0 = 0
p.contrast = 1

phase_at_t0 = [0.0, 90.0, 180.0, 270.0]
param = ParamSeque(repeat=200, phase_at_t0=phase_at_t0, frame_duration=0.016, blank_duration=0.2)
grating = ParamsGrating(viewport=eye, params=p, sweepseq=param)

sweep = FrameSweep()
sweep.add_stimulus(grating)
sweep.go(prestim=5.0,poststim=5.0,RSTART=True)
Exemple #28
0
class Disparity(object):
    def __init__(self, subject):
        """ Fixation """
        fp = dictattr()
        fp.bgbrightness = 0.5
        fp.color = (1.0, 0.0, 0.0, 1.0)
        fp.width = 0.25

        self.fixation_left = Fixation(viewport='left',
                                      subject=subject,
                                      params=fp)
        self.fixation_right = Fixation(viewport='right',
                                       subject=subject,
                                       params=fp)
        """ Random Dots with disc"""
        dp = dictattr()
        dp.bgbrightness = 0.5
        dp.antialiase = True

        dp.dotSquareWidth = 7.5
        dp.dotsNumber = 2000
        dp.randomSeed = 0
        dp.dotColor = (0.8, 0.8, 0.8)
        dp.dotSize = 3
        dp.discDistDeg = 2.5
        dp.discDiameter = 1.25
        dp.disparity = 0

        self.dp = dp
        self.subject = subject
        self.disc_left = StereoDisc(viewport='left',
                                    subject=subject,
                                    params=dp)
        self.disc_right = StereoDisc(viewport='right',
                                     subject=subject,
                                     params=dp)
        """ Mask: Random Dots """
        mp = dictattr()
        mp.bgbrightness = 0.5
        mp.antialiase = True

        mp.dotSquareWidth = 7.5
        mp.dotsNumber = 4500
        mp.randomSeed = 1
        mp.dotColor = (1, 1, 1)
        mp.dotSize = 2

        self.mp = mp
        self.mask_left = RandomDots(viewport='left',
                                    subject=subject,
                                    params=mp)
        self.mask_right = RandomDots(viewport='right',
                                     subject=subject,
                                     params=mp)
        """ Hint """
        hp = dictattr()
        hp.bgbrightness = 0.5
        hp.text = "Press left or right for disc interval."
        hp.xorigDeg = 5.0
        hp.yorigDeg = 0.0
        hp.color = (1.0, 0.0, 0.0, 1.0)
        hp.fontsize = 25
        self.hint_left = Hint(viewport="left", params=hp)
        hp.xorigDeg = -5.0
        self.hint_right = Hint(viewport="right", params=hp)

        self.sweep = FrameSweep()
        self.key_response = LeftRightKeyResponse(self.sweep)
        self.mouse_response = LeftRightMouseResponse(self.sweep)

    def set_disparity(self, disp):
        self.disparity = disp

    def update_disparity(self, cross):
        if random.choice([True, False]):
            self.disc_left.parameters.disparity = self.disparity if cross else 0
            self.disc_right.parameters.disparity = 0
        else:
            self.disc_left.parameters.disparity = 0
            self.disc_right.parameters.disparity = self.disparity if cross else 0

    def get_cross_interval(self):
        return self.cross_interval

    def demo(self):
        self.update_disparity(cross=True)
        self.sweep.add_stimulus(self.disc_left)
        self.sweep.add_stimulus(self.disc_right)
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.add_controller(None, None, self.key_response)
        self.sweep.add_controller(None, None, self.mouse_response)
        self.sweep.go(duration=('forever', ''))

    def run(self):
        random.seed()
        self.cross_interval = random.choice([1, 2])
        """ Randomize dots """
        self.dp.randomSeed = random.randint(0, 1000)
        self.disc_left = StereoDisc(viewport='left',
                                    subject=self.subject,
                                    params=self.dp)
        self.disc_right = StereoDisc(viewport='right',
                                     subject=self.subject,
                                     params=self.dp)
        self.mp.randomSeed = random.randint(0, 1000)
        self.mask_left = RandomDots(viewport='left',
                                    subject=self.subject,
                                    params=self.mp)
        self.mask_right = RandomDots(viewport='right',
                                     subject=self.subject,
                                     params=self.mp)
        """ Fixation """
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(2.0, 'seconds'))
        """ Interval-1 """
        self.update_disparity(self.cross_interval == 1)
        self.sweep.add_stimulus(self.disc_left)
        self.sweep.add_stimulus(self.disc_right)
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.2, 'seconds'))
        """ Blank """
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.4, 'seconds'))
        """ Interval-2 """
        self.update_disparity(self.cross_interval == 2)
        self.sweep.add_stimulus(self.disc_left)
        self.sweep.add_stimulus(self.disc_right)
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.2, 'seconds'))
        """ Blank """
        self.sweep.add_stimulus(self.fixation_left)
        self.sweep.add_stimulus(self.fixation_right)
        self.sweep.go(duration=(0.4, 'seconds'))
        """ Mask """
        self.sweep.add_stimulus(self.mask_left)
        self.sweep.add_stimulus(self.mask_right)
        self.sweep.go(duration=(0.5, 'seconds'))

        self.sweep.add_controller(None, None, self.key_response)
        self.sweep.add_controller(None, None, self.mouse_response)
        #self.sweep.add_stimulus(self.hint_left)
        #self.sweep.add_stimulus(self.hint_right)
        self.sweep.go(duration=('forever', ''))
        key_response = self.key_response.get_last_response_since_go()
        mouse_response = self.mouse_response.get_last_response_since_go()
        if key_response == "left" or mouse_response == "left_button":
            return self.cross_interval == 1
        elif key_response == "right" or mouse_response == "right_button":
            return self.cross_interval == 2
        else:
            raise RuntimeError("Key or button press is not direction.")
from StimControl.LightStim.FrameControl import FrameSweep
from StimControl.LightStim.Grating import ParamMapGrating
from StimControl.LightStim.LightData import dictattr, IndexedParam

eye = "left"

p = dictattr()
p.ml = 0.5
p.tfreqCycSec = 2.0
p.bgbrightness = 0.5
p.phase0 = 0
p.contrast = 1

orientation = IndexedParam("orientation_180")
spatial_freq = IndexedParam("spatial_freq")
phase_at_t0 = [None]

param_sequence = ParamSeque(
    repeat=4,
    orientation=orientation,
    spatial_freq=spatial_freq,
    phase_at_t0=phase_at_t0,
    frame_duration=0.1,
    blank_duration=0.0,
)

random_grating = ParamMapGrating(viewport=eye, params=p, sweepseq=param_sequence)
sweep = FrameSweep()
sweep.add_stimulus(random_grating)
sweep.go(prestim=5.0, poststim=5.0, RSTART=True)
Exemple #30
0
    def __init__(self, subject):
        """ Fixation """
        fp = dictattr()
        fp.bgbrightness = 0.5
        fp.color = (1.0, 0.0, 0.0, 1.0)
        fp.width = 0.25

        self.fixation_left = Fixation(viewport='left',
                                      subject=subject,
                                      params=fp)
        self.fixation_right = Fixation(viewport='right',
                                       subject=subject,
                                       params=fp)
        """ Random Dots with disc"""
        dp = dictattr()
        dp.bgbrightness = 0.5
        dp.antialiase = True

        dp.dotSquareWidth = 7.5
        dp.dotsNumber = 2000
        dp.randomSeed = 0
        dp.dotColor = (0.8, 0.8, 0.8)
        dp.dotSize = 3
        dp.discDistDeg = 2.5
        dp.discDiameter = 1.25
        dp.disparity = 0

        self.dp = dp
        self.subject = subject
        self.disc_left = StereoDisc(viewport='left',
                                    subject=subject,
                                    params=dp)
        self.disc_right = StereoDisc(viewport='right',
                                     subject=subject,
                                     params=dp)
        """ Mask: Random Dots """
        mp = dictattr()
        mp.bgbrightness = 0.5
        mp.antialiase = True

        mp.dotSquareWidth = 7.5
        mp.dotsNumber = 4500
        mp.randomSeed = 1
        mp.dotColor = (1, 1, 1)
        mp.dotSize = 2

        self.mp = mp
        self.mask_left = RandomDots(viewport='left',
                                    subject=subject,
                                    params=mp)
        self.mask_right = RandomDots(viewport='right',
                                     subject=subject,
                                     params=mp)
        """ Hint """
        hp = dictattr()
        hp.bgbrightness = 0.5
        hp.text = "Press left or right for disc interval."
        hp.xorigDeg = 5.0
        hp.yorigDeg = 0.0
        hp.color = (1.0, 0.0, 0.0, 1.0)
        hp.fontsize = 25
        self.hint_left = Hint(viewport="left", params=hp)
        hp.xorigDeg = -5.0
        self.hint_right = Hint(viewport="right", params=hp)

        self.sweep = FrameSweep()
        self.key_response = LeftRightKeyResponse(self.sweep)
        self.mouse_response = LeftRightMouseResponse(self.sweep)
p.tfreqCycSec = 2.0
p.bgbrightness = 0.5
p.phase0 = 0
p.contrast = 1

#Monocular stimuli
phase_at_t0 = [0]
monocular_param_left = ParamSeque(repeat=1, phase_at_t0=phase_at_t0, frame_duration=2.0, blank_duration=1.0)
monocular_param_right = ParamSeque(repeat=1, phase_at_t0=phase_at_t0, frame_duration=2.0, blank_duration=1.0)
monocular_grating_left = MonocularGrating(viewport='left', params=p, sweepseq=monocular_param_left)
monocular_grating_right = MonocularGrating(viewport='right', params=p, sweepseq=monocular_param_right)

#Binocular stimuli
phase_at_t0 = [0]*16
param_left = ParamSeque(repeat=4, phase_at_t0=phase_at_t0, frame_duration=2.0, blank_duration=1.0)

phase_at_t0 = IndexedParam('phase_at_t0')
param_right = ParamSeque(repeat=4, phase_at_t0=phase_at_t0, frame_duration=2.0, blank_duration=1.0)

grating_left = ParamsGrating(viewport='left', params=p, sweepseq=param_left, trigger=False)
grating_right = ParamsGrating(viewport='right', params=p, sweepseq=param_right)

sweep = FrameSweep()
sweep.add_stimulus(monocular_grating_left)
sweep.go()
sweep.add_stimulus(monocular_grating_right)
sweep.go()
sweep.add_stimulus(grating_left)
sweep.add_stimulus(grating_right)
sweep.go()
Exemple #32
0
# Display blank screen.
#
# Copyright (C) 2010-2012 Huang Xin
#
# See LICENSE.TXT that came with this file.

from __future__ import division
from StimControl.LightStim.FrameControl import FrameSweep
from StimControl.LightStim.Core import Dummy_Stimulus

duration = 15.0

dummy_stimulus = Dummy_Stimulus()

sweep = FrameSweep()
sweep.add_stimulus(dummy_stimulus)
sweep.parameters.go_duration = (duration, 'seconds')
sweep.go(prestim=5.0,poststim=5.0,RSTART=False)