def iterateStimulus(p): for iF in range(p['nFr']): QDS.SetObjColor(p['nB'], p['BoxIndList'], p['Frames'][iF]) QDS.Scene_Render(p['durMarker_s'], p['nB'], p['BoxIndList'], p['BoxPosList'], 1) QDS.Scene_Render(p['durStim_s'] - p['durMarker_s'], p['nB'], p['BoxIndList'], p['BoxPosList'], 0)
def myLoop(): for iT in range(p['nTrials']): mixA = random.random() perLen_um = random.randint(10, 500) QDS.SetShaderParams(1, [perLen_um, perDur_s, minRGBA, maxRGBA, mixA]) ObjRotList = [random.randint(0, 359)] * nObj QDS.Scene_RenderEx(p['dt_s'], ObjIndList, ObjPosList, ObjMagList, ObjRotList, 0)
def iterateStimulus(p): for t_pnt in range(p['rand_streams'].shape[1]): IND, RGB, POS, MAG, ANG = [], [], [], [], [] for itx in range(len(p['domain'])): IND.append(itx, ) RGB.append(3 * (int(p['rand_streams'][itx, t_pnt] * p['iFull']), )) POS.append((0, 0), ) MAG.append((1, 1), ) ANG.append(0, ) QDS.SetObjColor(itx, [IND[itx]], [RGB[itx]]) QDS.Scene_RenderEx(1 / p["frameRate"], IND, POS, MAG, ANG, 0)
def myLoop(): QDS.Start_Movie(1, (-200,-200), [0,39,3,1], (1.0,1.0), 128, 0, _screen=0) QDS.Start_Movie(2, (-200,-200), [0,39,3,1], (1.0,1.0), 128, 0, _screen=1) for iT in range(p['nTrials']): isMark = int((iT % 20) == 0) # Update colors of sinusoidal+flickering spots # per = math.pi*2 *iT*p['dt_s']/Spot_SinPer_s iSin = (math.sin(per) +1)/2 iCos = (math.cos(per) +1)/2 Spots_colL = [] r = 0 g = 0 b = int(255 *iSin) u = int(255 *iSin) Spots_colL.append((r,g,b,u)) g = int(255 *iSin) b = 0 Spots_colL.append((r,g,b,u)) g = int(255 *iCos) b = g Spots_colL.append((r,g,b,0)) g = int(255 *(iT % 2)) b = g u = int(255 *iCos) Spots_colL.append((r,g,b,u)) g = int(255 *(1- (iT % 2))) b = g Spots_colL.append((r,g,b)) Spots_colL.append((255,128,128)) # Set colors and render # indL = Grad_indL +Spots_indL magL = Grad_magL +Spots_magL posL = Grad_posL +Spots_posL rotL = Grad_rotL +Spots_rotL """ indL = Spots_indL magL = Spots_magL posL = Spots_posL rotL = Spots_rotL """ QDS.SetObjColorEx(Spots_indL, Spots_colL, Spots_alpL) #QDS.SetObjColorAlphaByVertex([Spot_ID_sinW], [[(255,0,0,200),(0,55,0,128)]]) if not(p['useStripes']): QDS.SetObjColorAlphaByVertex(Grad_indL, Grad_colL) QDS.Scene_RenderEx(p['dt_s'], indL, posL, magL, rotL, isMark)
def iterateStimulus(p): Intensity = np.ndarray((p['frequency_map'].shape[0], )) for t_pnt in range(p['frequency_map'].shape[0]): frequency = np.log(p['frequency_map'][t_pnt]) contrast = p['contrast_map'][t_pnt] Intensity[t_pnt] = np.sin( np.pi * frequency * t_pnt) * contrast * p["iHalf"] + p["iHalf"] if p['mode'] != 'trace': RGB = 3 * (int(Intensity[t_pnt]), ) QDS.SetObjColor(1, [1], [RGB]) QDS.Scene_Render(p["durFr_s"], 1, [1], [(0, 0)], 0) if p['mode'] is 'trace': return Intensity
def buildStimulus(p): '''Chirp formula is f(t) = sin( 2pi*F0 + pi*K*t^2)), where: F0 is Starting Frequency K = Acceleration (Hz / s) t = time (s)''' p['nPntChirp'] = int(p["chirpDur_s"] /p["durFr_s"]) p['K_HzPerSec'] = p["chirpMaxFreq_Hz"] /p["chirpDur_s"] # acceleration in Hz/s p['durMarker_s'] = p["durFr_s"]*p["nFrPerMarker"] p['RGB_IHalf'] = 3 *(p["IHalf"],) p['RGB_IFull'] = 3 *(p["IFull"],) # Define stimulus objects QDS.DefObj_Box(1, p["dxStim_um"], p["dxStim_um"], 0) QDS.DefObj_Ellipse(2, p["dxStim_um"], p["dxStim_um"])
def buildStimulus(p): radius = np.linspace(0, p['radius_max'], p['radius_itx'] + 1) azimuth = np.linspace(0, p['azimuth_max'], p['azimuth_itx'] + 1) rad_to_degree = lambda rad: rad * 180 / np.pi np.random.seed(seed=p['rng_seed']) domain = [] for a in range(p['radius_itx']): for b in range(p['azimuth_itx']): domain.append((radius[a], radius[a + 1], rad_to_degree(azimuth[b]), rad_to_degree(azimuth[b + 1] - azimuth[b]))) p['domain'] = domain p['rand_streams'] = np.random.rand(len(domain), p['duration'] * p['frameRate']) for itx in range(len(domain)): QDS.DefObj_Sector(itx, domain[itx][1], domain[itx][0], domain[itx][2], domain[itx][3], _astep=10) print(itx, domain[itx][1], domain[itx][0], domain[itx][2], domain[itx][3])
def iterateStimulus(p): '''Define function for single sine ripple, and conversion function to generate RGB values. Generate timeseries for each value pair instance. Iterate over all value pairs, calculating the intensity change at each timepoint. Render the intensity change of the ellipse.''' for (frequency,contrast) in p['contfreq_pairs']: RGB = 3 *(p["iHalf"],) QDS.SetObjColor (1, [1], [RGB]) QDS.Scene_Render(p["tSteadyMID_s"], 1, [1], [(0,0)], 0) for t_pnt in range(int(p['durRipple']/p['durFr_s'])): Intensity = np.sin(np.pi*frequency*t_pnt)*contrast*p["iHalf"]+p["iHalf"] RGB = 3 *(int(Intensity),) QDS.SetObjColor(1, [1], [RGB]) QDS.Scene_Render(p["durFr_s"], 1, [1], [(0,0)], 0)
def buildStimulus(p): p['durMarker_s'] = p["durFr_s"] * p["nFrPerMarker"] p['RGB_IHalf'] = 3 * (p["IHalf"], ) p['RGB_IFull'] = 3 * (p["IFull"], ) # Define stimulus objects QDS.DefObj_Ellipse(1, p["dxStim_um"], p["dxStim_um"])
def buildStimulus(p): radius = [ p['radius_centre'], p['radius_centre'] + 50, p['radius_centre'] + 100 ] azimuth = [0, 120, 240, 360] domain = [] for a in range(p['radius_itx']): for b in range(p['azimuth_itx']): domain.append((radius[a], radius[a + 1], azimuth[b], azimuth[b + 1] - azimuth[b])) p['domain'] = domain QDS.DefObj_Ellipse(0, p["radius_centre"] * 2, p["radius_centre"] * 2) for itx in range(len(domain)): QDS.DefObj_Sector(itx + 1, domain[itx][1], domain[itx][0], domain[itx][2], domain[itx][3], 5)
def MoveBarSeq(): # A function that presents the moving bar in the given number of # directions (= moving bar sequence) for rot_deg in p["DirList"]: # Calculate rotation angle and starting position of bar rot_rad = (rot_deg - 90) / 360.0 * 2 * math.pi x = math.cos(rot_rad) * (p['moveDist_um'] / 2.0) y = math.sin(rot_rad) * (-p['moveDist_um'] / 2.0) # Move the bar stepwise across the screen (as smooth as permitted # by the refresh frequency) QDS.Scene_Clear(p['durMarker_s'], 1) for iStep in range(int(p['nFrToMove'])): QDS.Scene_RenderEx(p["durFr_s"], [1], [(x, y)], [(1.0, 1.0)], [rot_deg], 0) x -= math.cos(rot_rad) * p['umPerFr'] y += math.sin(rot_rad) * p['umPerFr']
def myLoop(): for iT in range(nTrials): isMark = int((iT % 20) == 0) # Update colors of sinusoidal+flickering spots # per = math.pi * 2 * iT * dt_s / Spot_SinPer_s iSin = (math.sin(per) + 1) / 2 iCos = (math.cos(per) + 1) / 2 Spots_colL = [] r = 0 g = 0 b = int(255 * iSin) Spots_colL.append((r, g, b)) g = int(255 * iSin) b = 0 Spots_colL.append((r, g, b)) g = int(255 * iCos) b = g Spots_colL.append((r, g, b)) g = int(255 * (iT % 2)) b = g Spots_colL.append((r, g, b)) g = int(255 * (1 - (iT % 2))) b = g Spots_colL.append((r, g, b)) Spots_colL.append((255, 128, 128)) # Set colors and render # indL = Grad_indL + Spots_indL magL = Grad_magL + Spots_magL posL = Grad_posL + Spots_posL rotL = Grad_rotL + Spots_rotL """ indL = Spots_indL magL = Spots_magL posL = Spots_posL rotL = Spots_rotL """ QDS.SetObjColorEx(Spots_indL, Spots_colL, Spots_alpL) #QDS.SetObjColorAlphaByVertex([Spot_ID_sinW], [[(255,0,0,200),(0,55,0,128)]]) if not (useStripes): QDS.SetObjColorAlphaByVertex(Grad_indL, Grad_colL) QDS.Scene_RenderEx(dt_s, indL, posL, magL, rotL, isMark)
def buildStimulus(p): p['fPath'] = QDS.GetStimulusPath() p['durMarker_s'] = p['durFr_s'] * p['nFrPerMarker'] '''Read file with M sequence''' try: f = open(p['fPath'] + '\\' + p['fNameNoise'] + '.txt', 'r') iLn = 0 p['Frames'] = [] while 1: line = f.readline() if not line: break parts = line.split(',') if iLn == 0: p['nX'], p['nY'], p['nFr'] = int(parts[0]), int(parts[1]), int( parts[2]) p['nB'] = p['nX'] * p['nY'] else: Frame = [] for iB in range(1, p['nB'] + 1): r = int(parts[iB - 1]) * p['fIntenW'] Frame.append((r, r, r)) p['Frames'].append(Frame) iLn += 1 finally: f.close() '''Define objects Create box objects, one for each field of the checkerboard, such that we can later just change their color to let them appear or disappear''' for iB in range(1, p['nB'] + 1): QDS.DefObj_Box(iB, p['boxDx_um'], p['boxDy_um'], 0) '''Create two lists, one with the indices of the box objects and one with their positions in the checkerboard; these lists later facilitate using the Scene_Render() command to display the checkerboard''' p['BoxIndList'], p['BoxPosList'] = [], [] for iX in range(p['nX']): for iY in range(p['nY']): iB = 1 + iX + iY * p['nX'] x = iX * p['boxDx_um'] - (p['boxDx_um'] * p['nX'] / 2) y = iY * p['boxDy_um'] - (p['boxDy_um'] * p['nY'] / 2) p['BoxIndList'].append(iB) p['BoxPosList'].append((x, y))
def myLoop(): for iT in range(p['nTrials']): """ QDS.SetObjShader(ObjShaList, len(ObjShaList)//2*[1,1]) QDS.Scene_RenderEx(p['dt_s'], ObjIndList, ObjPosList, ObjMagList, ObjRotList, 0) QDS.SetObjShader(ObjShaList, len(ObjShaList)//2*[-1,-1]) """ QDS.Scene_RenderEx(p['dt_s'], ObjIndList, ObjPosList, ObjMagList, ObjRotList, 0)
def buildStimulus(p): p['durMarker_s'] = p["durFr_s"] * p["nFrPerMarker"] p['freq_Hz'] = round(1.0 / p["durFr_s"]) p['umPerFr'] = float(p["vel_umSec"]) / p['freq_Hz'] p['moveDist_um'] = p["vel_umSec"] * p["tMoveDur_s"] p['nFrToMove'] = float(p['moveDist_um']) / p['umPerFr'] # Define stimulus objects QDS.DefObj_Box(1, p["barDx_um"], p["barDy_um"])
def iterateStimulus(p): folderStr = "C:\\Users\\AGEuler\\Documents\\QDSpy\\Stimuli\\Multiplexing\\" tableStr = 'sine_conditions.csv' f = open(folderStr+tableStr,'r') reader = csv.reader(f) conditions = [] for itx,row in enumerate(reader): if itx%2 == 0: conditions.append([float(state) for state in row]) bkg_clr = (0,0,0) pause_counter = 0 for (condition,frequency,contrast) in conditions: if pause_counter == 0: QDS.Scene_Clear(0.05, 1) QDS.Scene_Clear(0.95, 0) pause_counter = 16 pause_counter -=1 for itx in range(int(p['durRipple']/p['durFr_s'])): t_pnt = itx*p['durFr_s'] # Add marker if (itx%(p['MarkPer_s']/p['durFr_s']) < p['nFrPerMarker']): showMarker = 1 else: showMarker = 0 # Calculate stimulus intensity Intensity = math.sin(2*math.pi*frequency*t_pnt)*contrast/100*p["iHalf"]+p["iHalf"] RGB = (int(Intensity),int(Intensity),int(Intensity)) # Set object intensity obj_colour = { 0: [RGB,bkg_clr,], # Centre only 1: [bkg_clr,RGB,], # Annulus only 2: [RGB,RGB,], # Centre and Annulus } QDS.SetObjColor(2, [1,2], obj_colour[condition-1]) QDS.Scene_Render(p["durFr_s"], 2, [1,2], [(0,0),(0,0)], showMarker)
def buildStimulus(p): '''Set random seed. Generate sets of contrast and frequency values. Generate all permutations of these sets. Shuffle the order of the permutation set. Create single elliptical object, for which the freqeuency is modulated.''' random.seed(p['seed']) contrast_values = np.linspace(p['contrast_min'],p['contrast_max'],p['contrast_n']) frequency_values = np.linspace(p['frequency_min'],p['frequency_max'],p['frequency_n']) p['contfreq_pairs'] = [(x,y) for x in frequency_values for y in contrast_values] random.shuffle(p['contfreq_pairs']) # Define stimulus objects QDS.DefObj_Ellipse(1, p["dxStim_um"], p["dxStim_um"])
def iterateStimulus(p): folderStr = "C:\\Users\\AGEuler\\Documents\\QDSpy\\Stimuli\\Multiplexing\\" tableStr = 'grayscale_noise_conditions.csv' f = open(folderStr + tableStr, 'r') reader = csv.reader(f) condition = [] for itx, row in enumerate(reader): if itx % 2 == 0: condition.append([float(state) for state in row]) states = [ (0, 0, 0), (p['iFull'], p['iFull'], p['iFull']), (0, 0, p['iFull']), (0, p['iFull'], 0), ] for t_pnt in range(p['frameRate'] * p['duration']): # Add marker if (t_pnt % (p['MarkPer_s'] * p['frameRate']) < p['nFrPerMarker']): # <- Will this work for longer duration? showMarker = 1 else: showMarker = 0 IND, RGB, POS, MAG, ANG, ALP = [], [], [], [], [], [] # Add stimulus marker for itx in range(7): IND.append(itx, ) RGB.append(states[int(condition[t_pnt][itx])]) POS.append((0, 0), ) MAG.append((1, 1), ) ANG.append(0, ) QDS.SetObjColor(7, IND, RGB) QDS.Scene_RenderEx(1 / p["frameRate"], IND, POS, MAG, ANG, showMarker)
def buildStimulus(p): # http://mathworld.wolfram.com/SpherePointPicking.html np.random.seed(seed=p['rng_seed']) theta = 2 * np.pi * np.random.rand(p['pnt_seed']) phi = np.arccos(2 * np.random.rand(p['pnt_seed']) - 1) dX = np.cos(theta[1:]) * np.sin(phi[1:]) - np.cos(theta[:-1]) * np.sin( phi[:-1]) dY = np.sin(theta[1:]) * np.sin(phi[1:]) - np.sin(theta[:-1]) * np.sin( phi[:-1]) dT = np.cumsum(np.append( 0, 1 / np.sqrt(dX**2 + dY**2))) # <- distance correction? # if p['velocity']*p['duration']/p['frameRate'] > dT.shape[0]: # raise ValueError('Target trajectory exceeds seed trajectory') coord = np.append(np.expand_dims(theta, axis=1), np.expand_dims(phi, axis=1), axis=1) timepoints = np.linspace(0, p['duration'], p['duration'] * p['frameRate']) coord_interp = sp.interpolate.interp1d(dT, coord, kind='cubic', axis=0)(timepoints) spherical_to_cartesian = lambda theta, phi: [ np.cos(theta) * np.sin(phi), np.sin(theta) * np.sin(phi) ] coord_xy = np.asarray( spherical_to_cartesian(coord_interp[:, 0], coord_interp[:, 1])).T coord_to_value = lambda value, parMax, parMin: (value + 1) / 2 * ( parMax - parMin) + parMin frequency = coord_to_value(coord_xy[:, 0], p['frequency_max'], p['frequency_min']) contrast = coord_to_value(coord_xy[:, 1], p['contrast_max'], p['contrast_min']) intensity = np.zeros((frequency.shape[0])) for itx in range(frequency.shape[0]): intensity[itx] = np.sin(2 * np.pi * frequency[itx] ) * contrast[itx] * p['iHalf'] + p['iHalf'] p['intensity'] = intensity # Define stimulus objects QDS.DefObj_Ellipse(1, p['dot_um'], p['dot_um'])
def iterateStimulus(p): for iL in range(p["nTrials"]): # Steady steps QDS.Scene_Clear(p["tSteadyOFF_s"] - p['durMarker_s'], 0) QDS.Scene_Clear(p['durMarker_s'], 1) QDS.SetObjColor(1, [ 1, ], [p['RGB_IFull']]) QDS.Scene_Render(p["tSteadyON_s"], [ 1, ], [ 1, ], [(0, 0)], 0) QDS.Scene_Clear(p['durMarker_s'], 1) QDS.Scene_Clear(p["tSteadyOFF_s"] - p['durMarker_s'], 0)
#!/usr/bin/env python # -*- coding: utf-8 -*- # --------------------------------------------------------------------- import QDS QDS.Initialize("RGC_BG_3s", "'B/G' in fingerprinting stimulus set") # Define global stimulus parameters # p = {"nTrials" : 3, "dxStim_um" : 1000, # Stimulus size "durFr_s" : 1/60.0, # Frame duration "nFrPerMarker" : 3, "RGB_green" : (0,255,0), "RGB_blue" : (0,0,255)} QDS.LogUserParameters(p) # Do some calculations # durMarker_s = p["durFr_s"] *p["nFrPerMarker"] # Define stimulus objects # QDS.DefObj_Ellipse(1, p["dxStim_um"], p["dxStim_um"]) # Start of stimulus run # QDS.StartScript() for iT in range(p["nTrials"]): QDS.SetObjColor (1, [1], [p["RGB_green"]])
#!/usr/bin/env python # -*- coding: utf-8 -*- # # --------------------------------------------------------------------- import QDS QDS.Initialize("video_perlin32", "Perlin noise test") # Define global stimulus parameters # FrRefr_Hz = QDS.GetDefaultRefreshRate() p = { "nTrials": 1, # number of stimulus presentations "vidScale": (3.0, 3.0), # movie scaling (x, y) "vidOrient": 0, # movie orientation "vidAlpha": 255, # transparency of movie "MarkPer_s": 1.0, # number of markers per second "durFr_s": 1 / FrRefr_Hz, # frame duration "nFrPerMarker": 3, "vidName": "Perlin32.avi" } QDS.LogUserParameters(p) # Define objects # QDS.DefObj_Video(1, p["vidName"]) vidparams = QDS.GetVideoParameters(1) p["vidparams"] = vidparams dFr = 1 / FrRefr_Hz
#!/usr/bin/env python # -*- coding: utf-8 -*- # --------------------------------------------------------------------- import QDS import os # Initialize QDS # QDS.Initialize("RGC_Noise", "'noise' in fingerprinting stimulus set") # Define global stimulus parameters # p = { "durStim_s": 0.200, "boxDx_um": 40, "boxDy_um": 40, "fIntenW": 255, # intensity factor # (pixel value(0,1) x fIntenW) "fNameNoise": "RGC_BWNoise_official", "durFr_s": 1 / 60.0, # Frame duration "nFrPerMarker": 3 } QDS.LogUserParameters(p) # Do some calculations and preparations # fPath = QDS.GetStimulusPath() durMarker_s = p["durFr_s"] * p["nFrPerMarker"] print(os.getcwd(), fPath)
#!/usr/bin/env python # -*- coding: utf-8 -*- # # --------------------------------------------------------------------- import QDS QDS.Initialize("movie_water1", "Water movie test") # Define global stimulus parameters # FrRefr_Hz = QDS.GetDefaultRefreshRate() p = {"nTrials" : 1, # number of stimulus presentations "movScale" : (4.0, 4.0), # movie scaling (x, y) "movOrient" : 0, # movie orientation "movAlpha" : 255, # transparency of movie "MarkPer_s" : 1.0, # number of markers per second "durFr_s" : 1/FrRefr_Hz, # frame duration "nFrPerMarker" : 3, "movName" : "water1_flipped.jpg", "rng_seed" : 1, # Random seed "tex_ydim" : 90, # Output resolution, Y dimension "tex_xdim" : 128, # Output resolution, X dimension "duration" : 180, # Stimulus duration (seconds) "yNodes" : 6, # Generator image, Y dimension "xNodes" : 6, # Generator image, X dimension "upFactor" : 48, # Upscaling factor "tempFreq" : 2.5, # Temporal frequency "tempKernelLength": 61, # Length of temporal filter kernel "spatialFreq" : 0.06, # Spatial frequency [?]
# -*- coding: utf-8 -*- """ Stimuilus to calibrate the output power of the lightcrafter. -full field ellipse that increments intensity in 5 unit steps (0 to 255) every 2 seconds. Runs green by default Created on Fri Jul 8 14:25:30 2016 @author: andre maia chagas """ import QDS QDS.Initialize("power_calibration", "'G/B'") # Define global stimulus parameters # minVal = 0 maxVal = 256 step = 5 nsteps = ((maxVal - minVal) / step) * 2 # increase and decrease p = { "nTrials": 1, "dxStim_um": 500, # Stimulus size "durFr_s": 1 / 60.0, # Frame duration "nFrPerMarker": 3, "RGB_green": (0, 255, 0), "RGB_blue": (255, 0, 0) }
def buildStimulus(p): # Define stimulus objects QDS.DefObj_Ellipse(1, 50, 50) QDS.DefObj_Sector(2,125,25,0,360,5)
def iterateStimulus(p): for iL in range(p["nTrials"]): # Steady steps QDS.Scene_Clear(p['durMarker_s'], 1) QDS.Scene_Clear(p["tSteadyOFF2_s"] - p['durMarker_s'], 0) QDS.SetObjColor(1, [p["StimType"]], [p['RGB_IFull']]) QDS.Scene_Render(p["tSteadyON_s"], 1, [p["StimType"]], [(0, 0)], 0) QDS.Scene_Clear(p['durMarker_s'], 1) QDS.Scene_Clear(p["tSteadyOFF_s"] - p['durMarker_s'], 0) QDS.SetObjColor(1, [p["StimType"]], [p['RGB_IHalf']]) QDS.Scene_Render(p["tSteadyMID_s"], 1, [p["StimType"]], [(0, 0)], 0) # Frequency chirp for iT in range(p['nPntChirp']): t_s = iT * p["durFr_s"] # in ms Intensity = math.sin( math.pi * p['K_HzPerSec'] * t_s**2) * p["IHalf"] + p["IHalf"] RGB = 3 * (int(Intensity), ) # -> RGB tuple QDS.SetObjColor(1, [p["StimType"]], [RGB]) QDS.Scene_Render(p["durFr_s"], 1, [p["StimType"]], [(0, 0)], 0) # Gap between frequency chirp and contrast chirp QDS.SetObjColor(1, [p["StimType"]], [p['RGB_IHalf']]) QDS.Scene_Render(p["tSteadyMID_s"], 1, [p["StimType"]], [(0, 0)], 0) # Contrast chirp for iPnt in range(p['nPntChirp']): t_s = iPnt * p["durFr_s"] IRamp = int(p["IHalf"] * t_s / p["chirpDur_s"]) Intensity = math.sin( 2 * math.pi * p["ContrastFreq_Hz"] * t_s) * IRamp + p["IHalf"] RGB = 3 * (int(Intensity), ) QDS.SetObjColor(1, [p["StimType"]], [RGB]) QDS.Scene_Render(p["durFr_s"], 1, [p["StimType"]], [(0, 0)], 0) # Gap after contrast chirp QDS.SetObjColor(1, [p["StimType"]], [p['RGB_IHalf']]) QDS.Scene_Render(p["tSteadyMID_s"], 1, [p["StimType"]], [(0, 0)], 0) QDS.Scene_Clear(p["tSteadyOFF_s"], 0)
#!/usr/bin/env python # -*- coding: utf-8 -*- # # --------------------------------------------------------------------- import random import QDS QDS.Initialize("noise_Colored1_RGBU", "Example for random-colored boxes flickering") # Set random generator seed # random.seed(1) # Define global stimulus parameters # p = {} p['dtFr_s'] = 3 / 60.0 # presentation time per pattern p['nTrials'] = 50 # 0 # # of repeats p['nPrMark'] = 20 # present marker every p['nPrMark']*p['dtFr_s'] p['nRows'] = 30 # dimensions of pattern grid p['nCols'] = 30 p['boxDx'] = 15 # box size in um p['boxDy'] = 15 p['dRot_step'] = 0 # angle by which boxes are rotated # Define objects # Generate one box object per grid position # nB = p['nRows'] * p['nCols'] for iB in range(1, nB + 1):
# Move the bar stepwise across the screen (as smooth as permitted # by the refresh frequency) # QDS.Scene_Clear(durMarker_s, 1) for iStep in range(int(nFrToMove)): QDS.Scene_RenderEx(p["durFr_s"], [1], [(x, y)], [(1.0, 1.0)], [rot_deg], iStep < p["nFrPerMarker"]) x -= math.cos(rot_rad) * umPerFr y += math.sin(rot_rad) * umPerFr # -------------------------------------------------------------------------- # Main script # -------------------------------------------------------------------------- QDS.Initialize("RGC_MovingBar", "'moving bar' in fingerprinting stimulus set") # Define global stimulus parameters # p = { "nTrials": 2, "DirList": [0, 180, 45, 225, 90, 270, 135, 315], "vel_umSec": 1000.0, # speed of moving bar in um/sec "tMoveDur_s": 4.0, # duration of movement (defines distance # the bar travels, not its speed) "barDx_um": 300.0, # bar dimensions in um "barDy_um": 1000.0, "bkgColor": (0, 0, 0), # background color "barColor": (255, 255, 255), # bar color "durFr_s": 1 / 60.0, # Frame duration "nFrPerMarker": 3
def iterateStimulus(p): QDS.SetObjColor(1, [1], [p["barColor"]]) QDS.SetBkgColor(p["bkgColor"]) QDS.Scene_Clear(3.0, 0) QDS.Loop(p["nTrials"], MoveBarSeq)