def create_stimulus(info, return_env=False): control(info) import numpy as np fx, fy, ft = mc.get_grids(info[height], info[width], info[frame]) env_color = 1 env_orientation = 1 env_radial = 1 env_speed = 1 if (info[color] == True): if (info[ft_0] == True): ft_0_color = np.inf else: ft_0_color = 1 env_color = mc.envelope_color(fx, fy, ft, alpha=info[alpha], ft_0=ft_0_color) if (info[orientation] == True): env_orientation = mc.envelope_orientation(fx, fy, ft, theta=info[theta], B_theta=info[B_theta]) if (info[radial] == True): if (info[ft_0b] == True): ft_0_radial = np.inf else: ft_0_radial = 1 env_radial = mc.envelope_radial(fx, fy, ft, sf_0=info[sf_0], B_sf=info[B_sf], ft_0=ft_0_radial, loggabor=info[loggabor]) if (info[speed] == True): env_speed = mc.envelope_speed(fx, fy, ft, V_X=info[V_X], V_Y=info[V_Y], B_V=info[B_V]) env = env_color * env_orientation * env_radial * env_speed if (info[random_cloud] == True): if (info[seed] == 'None'): seed_t = None else: seed_t = int(info[seed]) env = mc.random_cloud(env, seed=seed_t, impulse=info[impulse], do_amp=info[do_amp]) env = mc.rectif(env, contrast=1.) env = env * 255 if (return_env == True): return (env) stimulus = np.zeros([info[height], info[width], info[frame], 3]).astype(int) if (info[isoluminance] == True): stimulus[:, :, :, 0] = env stimulus[:, :, :, 1] = 255 - env stimulus[:, :, :, 2] = 127 else: for i in range(3): stimulus[:, :, :, i] = env[:, :, :] return(stimulus)
""" # width and height of your screen w, h = 1920, 1200 w, h = 2560, 1440 # width and height of the stimulus w_stim, h_stim = 1024, 1024 loops = 1 import MotionClouds as mc print 'started get_grids' fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame) print 'started color' color = mc.envelope_color(fx, fy, ft) print 'started enveope' env = color *(mc.envelope_gabor(fx, fy, ft, V_X=1.) + mc.envelope_gabor(fx, fy, ft, V_X=-1.)) print 'started rectif' z = 2*mc.rectif(mc.random_cloud(env), contrast=.5) -1. print 'ended motion clouds' #from pyglet.gl import gl_info from psychopy import visual, core, event, logging logging.console.setLevel(logging.DEBUG) print 'started stim' win = visual.Window([w, h], fullscr=True) stim = visual.GratingStim(win, size=(w_stim, h_stim), units='pix', interpolate=True,
colStep = thisTrial['colStep'] # alpha step print 'sat=' + str(sat) + '; colStep=' + str(colStep) colOdd = [150,1,1] # green colEven = [330,sat,1] # red is adjusted and is assigned to gratings in even frames # initiating the gratings if precompileMode: grtL = np.load(precompiledDir + os.sep + 'mc_' + '{0:.1f}'.format(vL) + '_sf' + str(sfL) + '_bsf' + str(BsfL) + '_bv' + str(BvL) + '_sz' + str(szL) + '.npy') grtR = np.load(precompiledDir + os.sep + 'mc_' + '{0:.1f}'.format(vR) + '_sf' + str(sfR) + '_bsf' + str(BsfR) + '_bv' + str(BvR) + '_sz' + str(szR) + '.npy') else: fx, fy, ft = mc.get_grids(szL, szL, nFrames) grtCol = mc.envelope_color(fx, fy, ft) grtL = 2*mc.rectif(mc.random_cloud(grtCol * mc.envelope_gabor(fx, fy, ft, sf_0=sfL, B_sf=BsfL, B_V=BvL, V_X=vL, B_theta=np.inf))) - 1 fx, fy, ft = mc.get_grids(szR, szR, nFrames) grtCol = mc.envelope_color(fx, fy, ft) grtR = 2*mc.rectif(mc.random_cloud(grtCol * mc.envelope_gabor(fx, fy, ft, sf_0=sfR, B_sf=BsfR, B_V=BvR, V_X=vR, B_theta=np.inf))) - 1 # Creating a mask, which is fixed for a given trial: curMask = combinedMask(fovGap, fovFade, periGap, periFade) # Using the mask to assign both the greyscale values and the mask for our color masks: colMaskL.tex = (curMask + 1)/2 colMaskL.mask = curMask
print(info) info['timeStr'] = time.strftime("%b_%d_%H%M", time.localtime()) fileName = 'data/discriminating_v2_' + info['observer'] + '_' + info['timeStr'] + '.pickle' #save to a file for future use (ie storing as defaults) if dlg.OK: misc.toFile(fileName, info) else: print('Interrupted gui... quitting') core.quit() #user cancelled. quit print('generating data') alphas = [-1., -.5, 0., 0.5, 1., 1.5, 2.] fx, fy, ft = mc.get_grids(info['N_X'], info['N_Y'], info['N_frame_total']) colors = [mc.envelope_color(fx, fy, ft, alpha=alpha) for alpha in alphas] slows = [2*mc.rectif(mc.random_cloud(color * mc.envelope_gabor(fx, fy, ft, V_Y=0., V_X = 1.1, B_sf = 10.))) - 1 for color in colors] fasts = [2*mc.rectif(mc.random_cloud(color * mc.envelope_gabor(fx, fy, ft, V_Y=0., V_X = 0.9, B_sf = 10.))) - 1 for color in colors] print('go! ') win = visual.Window([info['screen_width'], info['screen_height']], fullscr=True) stimLeft = visual.GratingStim(win, size=(info['screen_width']/2, info['screen_width']/2), pos=(-info['screen_width']/4, 0), units='pix', interpolate=True, mask = 'gauss', autoLog=False)#this stim changes too much for autologging to be useful stimRight = visual.GratingStim(win,
def create_stimulus(info, return_env=False): control(info) import numpy as np fx, fy, ft = mc.get_grids(info[height], info[width], info[frame]) env_color = 1 env_orientation = 1 env_radial = 1 env_speed = 1 if (info[color] == True): if (info[ft_0] == True): ft_0_color = np.inf else: ft_0_color = 1 env_color = mc.envelope_color(fx, fy, ft, alpha=info[alpha], ft_0=ft_0_color) if (info[orientation] == True): env_orientation = mc.envelope_orientation(fx, fy, ft, theta=info[theta], B_theta=info[B_theta]) if (info[radial] == True): if (info[ft_0b] == True): ft_0_radial = np.inf else: ft_0_radial = 1 env_radial = mc.envelope_radial(fx, fy, ft, sf_0=info[sf_0], B_sf=info[B_sf], ft_0=ft_0_radial, loggabor=info[loggabor]) if (info[speed] == True): env_speed = mc.envelope_speed(fx, fy, ft, V_X=info[V_X], V_Y=info[V_Y], B_V=info[B_V]) env = env_color * env_orientation * env_radial * env_speed if (info[random_cloud] == True): if (info[seed] == 'None'): seed_t = None else: seed_t = int(info[seed]) env = mc.random_cloud(env, seed=seed_t, impulse=info[impulse], do_amp=info[do_amp]) env = mc.rectif(env, contrast=1.) env = env * 255 if (return_env == True): return (env) stimulus = np.zeros([info[height], info[width], info[frame], 3]).astype(int) if (info[isoluminance] == True): stimulus[:, :, :, 0] = env stimulus[:, :, :, 1] = 255 - env stimulus[:, :, :, 2] = 127 else: for i in range(3): stimulus[:, :, :, i] = env[:, :, :] return (stimulus)
""" Testing differently colored noises. """ try: if mc.notebook: print('we are in the notebook') except: import os import MotionClouds as mc import numpy as np name = 'color' fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame) z = mc.envelope_color(fx, fy, ft) mc.figures(z, name) # explore parameters for alpha in [0.0, 0.5, 1.0, 1.5, 2.0]: # resp. white(0), pink(1), red(2) or brownian noise (see http://en.wikipedia.org/wiki/1/f_noise name_ = name + '-alpha-' + str(alpha).replace('.', '_') z = mc.envelope_color(fx, fy, ft, alpha) mc.figures(z, name_) for ft_0 in [0.125, 0.25, 0.5, 1., 2., 4., np.inf]:# time space scaling name_ = name + '-ft_0-' + str(ft_0).replace('.', '_') z = mc.envelope_color(fx, fy, ft, ft_0=ft_0) mc.figures(z, name_) for contrast in [0.1, 0.25, 0.5, 0.75, 1.0, 2.0]: