def run(): defaults = PaperDefaults() #David's globals _DEFAULT_TILTEFFECT_DEGPERPIX = .25 # <OToole77> _DEFAULT_TILTEFFECT_SIZE = 51 #101 _DEFAULT_TILTEFFECT_CSIZE = iround(2. / _DEFAULT_TILTEFFECT_DEGPERPIX) _DEFAULT_TILTEFFECT_SSIZE = iround(8. / _DEFAULT_TILTEFFECT_DEGPERPIX) _DEFAULT_TILTEFFECT_CVAL = .5 _DEFAULT_TILTEFFECT_SVALS = np.linspace(0.0, 0.5, 10) _DEFAULT_TILTEFFECT_SCALES = {'ow77': 0.40, 'ms79': 0.60} #0.45 _DEFAULT_TILTEFFECT_NPOINTS = 25 #100 _DEFAULT_TILTEFFECT_DECODER_TYPE = 'circular_vote' _DEFAULT_TILTEFFECT_CSV = { 'ow77': os.path.join(defaults._DATADIR, 'OW_fig4_Black.csv'), 'ms79': os.path.join(defaults._DATADIR, 'MS1979.csv'), } # experiment parameters cpt = (_DEFAULT_TILTEFFECT_SIZE // 2, _DEFAULT_TILTEFFECT_SIZE // 2) spt = (_DEFAULT_TILTEFFECT_SIZE // 2, _DEFAULT_TILTEFFECT_SIZE // 2 + _DEFAULT_TILTEFFECT_CSIZE) dt_in = _DEFAULT_TILTEFFECT_CVAL - _DEFAULT_TILTEFFECT_SVALS # simulate populations im = sp.array([[ stim.get_center_nfsurrounds(size=_DEFAULT_TILTEFFECT_SIZE, csize=_DEFAULT_TILTEFFECT_CSIZE, nsize=_DEFAULT_TILTEFFECT_CSIZE, fsize=_DEFAULT_TILTEFFECT_SSIZE, cval=_DEFAULT_TILTEFFECT_CVAL, nval=_DEFAULT_TILTEFFECT_CVAL, fval=sval, bgval=sp.nan) ] for sval in _DEFAULT_TILTEFFECT_SVALS]) # get shifts for model for both papers, and from digitized data sortidx = sp.argsort(dt_in) # re-order in increasing angular differences # O'Toole and Wenderoth (1977) _, ds_ow77_paper_y = sp.genfromtxt(_DEFAULT_TILTEFFECT_CSV['ow77'], delimiter=',').T extra_vars = {} extra_vars['scale'] = _DEFAULT_TILTEFFECT_SCALES['ow77'] extra_vars['decoder'] = _DEFAULT_TILTEFFECT_DECODER_TYPE extra_vars['npoints'] = _DEFAULT_TILTEFFECT_NPOINTS extra_vars['npoints'] = _DEFAULT_TILTEFFECT_NPOINTS extra_vars['cval'] = _DEFAULT_TILTEFFECT_CVAL extra_vars['sortidx'] = sortidx extra_vars['cpt'] = cpt extra_vars['spt'] = spt extra_vars['sval'] = sval extra_vars['kind'] = 'circular' extra_vars['figure_name'] = 'f3a' extra_vars['return_var'] = 'O' extra_vars['hp_file'] = os.path.join(defaults._FIGURES, 'best_hps.npz') optimize_model(im, ds_ow77_paper_y, extra_vars, defaults)
def run(): defaults = PaperDefaults() #David's globals _DEFAULT_KW97_TILTEFFECT_DEGPERPIX = .45 # <OToole77> _DEFAULT_TILTEFFECT_SIZE = 101 #101 _DEFAULT_KW97_TILTEFFECT_CSIZE = iround(3.6 / _DEFAULT_KW97_TILTEFFECT_DEGPERPIX) _DEFAULT_KW97_TILTEFFECT_NSIZE = iround(5.4 / _DEFAULT_KW97_TILTEFFECT_DEGPERPIX) _DEFAULT_KW97_TILTEFFECT_FSIZE = iround(10.7 / _DEFAULT_KW97_TILTEFFECT_DEGPERPIX) _DEFAULT_TILTEFFECT_CVAL = .5 _DEFAULT_TILTEFFECT_SVALS = np.linspace(0.0, 0.5, 10) _DEFAULT_KW97_TILTEFFECT_SCALE = 1.25 _DEFAULT_TILTEFFECT_NPOINTS = 25 #100 _DEFAULT_TILTEFFECT_CIRCULAR = True _DEFAULT_TILTEFFECT_DECODER_TYPE = 'circular_vote' csvfiles = [ os.path.join(defaults._DATADIR, 'KW97_GH.csv'), os.path.join(defaults._DATADIR, 'KW97_JHK.csv'), os.path.join(defaults._DATADIR, 'KW97_LL.csv'), os.path.join(defaults._DATADIR, 'KW97_SJL.csv'), ] # experiment parameters cpt = (_DEFAULT_TILTEFFECT_SIZE // 2, _DEFAULT_TILTEFFECT_SIZE // 2) spt = (_DEFAULT_TILTEFFECT_SIZE // 2, _DEFAULT_TILTEFFECT_SIZE // 2 + _DEFAULT_KW97_TILTEFFECT_CSIZE) dt_in = _DEFAULT_TILTEFFECT_CVAL - _DEFAULT_TILTEFFECT_SVALS # simulate populations im = sp.array([[ stim.get_center_nfsurrounds(size=_DEFAULT_TILTEFFECT_SIZE, csize=_DEFAULT_KW97_TILTEFFECT_CSIZE, nsize=_DEFAULT_KW97_TILTEFFECT_NSIZE, fsize=_DEFAULT_KW97_TILTEFFECT_FSIZE, cval=_DEFAULT_TILTEFFECT_CVAL, nval=sp.nan, fval=sval, bgval=sp.nan) ] for sval in _DEFAULT_TILTEFFECT_SVALS]) # get shifts for model for both papers, and from digitized data sortidx = sp.argsort(dt_in) # re-order in increasing angular differences # O'Toole and Wenderoth (1977) n_subjects = len(csvfiles) ds_kw97_paper_x = sp.zeros((n_subjects, 9)) ds_kw97_paper_y = sp.zeros((n_subjects, 9)) for sidx, csv in enumerate(csvfiles): ds_kw97_paper_x[sidx], ds_kw97_paper_y[sidx] = \ sp.genfromtxt(csv, delimiter=',').T ds_kw97_paper_x = (ds_kw97_paper_x + 360.) % 360. - 45. ds_kw97_paper_y = 45. - ds_kw97_paper_y for sidx in range(n_subjects): ds_kw97_paper_x[sidx] = ds_kw97_paper_x[sidx][sp.argsort( ds_kw97_paper_x[sidx])] extra_vars = {} extra_vars['scale'] = _DEFAULT_KW97_TILTEFFECT_SCALE extra_vars['decoder'] = _DEFAULT_TILTEFFECT_DECODER_TYPE extra_vars['npoints'] = _DEFAULT_TILTEFFECT_NPOINTS extra_vars['npoints'] = _DEFAULT_TILTEFFECT_NPOINTS extra_vars['cval'] = _DEFAULT_TILTEFFECT_CVAL extra_vars['sortidx'] = sortidx extra_vars['cpt'] = cpt extra_vars['spt'] = spt extra_vars['sval'] = sval extra_vars['kind'] = 'circular' extra_vars['figure_name'] = 'f3b' extra_vars['return_var'] = 'O' extra_vars['hp_file'] = os.path.join(defaults._FIGURES, 'best_hps.npz') adjusted_gt = signal.resample(np.mean(ds_kw97_paper_y, axis=0), 10) optimize_model(im, adjusted_gt, extra_vars, defaults)
def run(): defaults = PaperDefaults() #David's globals size = 51 mpp = 0.76 # 0.76 # 1.11 scale = 0.23 # 0.23 # 0.22 csv_file_x = os.path.join(defaults._DATADIR, 'WL1987_corrected_X.csv') csv_file_y = os.path.join(defaults._DATADIR, 'WL1987_corrected_Y.csv') # experiment parameters dd = (-150., 150.) # in seconds of arc sec2u = lambda s: (s - dd[0]) / (dd[1] - dd[0]) u2sec = lambda u: u * (dd[1] - dd[0]) + dd[0] min2pix = lambda m: iround(m / float(mpp)) npoints = 50 ndists = 10 dists = sp.linspace(0.0, 12., ndists) lh, lw = 1, 4. ph, pw = 2., 2. center_disp = 0.0 flanker_disp = -33.3 mp0 = size // 2 # Need to scale up the ecrfs defaults._DEFAULT_PARAMETERS[ 'srf'] = defaults._DEFAULT_PARAMETERS['srf'] * 2 - 1 defaults._DEFAULT_PARAMETERS[ 'ssn'] = defaults._DEFAULT_PARAMETERS['ssn'] * 2 - 1 defaults._DEFAULT_PARAMETERS[ 'ssf'] = defaults._DEFAULT_PARAMETERS['ssf'] * 2 - 1 # simulate populations im = get_wl87_stim(size=size, dists=min2pix(dists), cval=sec2u(center_disp), sval=sec2u(flanker_disp), ch=min2pix(lh), cw=min2pix(lw), sh=min2pix(ph), sw=min2pix(pw)) # Get ground truth data paper_data_x = sp.genfromtxt(csv_file_x, delimiter=',') paper_data_y = sp.genfromtxt(csv_file_y, delimiter=',') * -1 paper_fit_y = sfit(sp.linspace(dists.min(), dists.max(), 100), paper_data_x, sp.nanmean(paper_data_y, axis=0), k=2, t=[5.]) paper_fit_y = paper_fit_y[np.round( np.linspace(0, paper_fit_y.shape[0] - 1, ndists)).astype(int)] extra_vars = {} extra_vars['scale'] = scale extra_vars['kind'] = 'gaussian' extra_vars['decoder'] = 'circular_vote' extra_vars['npoints'] = npoints extra_vars['cval'] = sec2u(center_disp) extra_vars['sval'] = sec2u(flanker_disp) extra_vars['figure_name'] = 'f5' extra_vars['u2sec'] = u2sec extra_vars['min2pix'] = min2pix extra_vars['dists'] = dists extra_vars['flanker_disp'] = flanker_disp extra_vars['mp0'] = mp0 extra_vars['lh'] = lh extra_vars['pw'] = pw extra_vars['size'] = size extra_vars['gt_x'] = paper_data_x extra_vars['return_var'] = 'O' extra_vars['hp_file'] = os.path.join(defaults._FIGURES, 'best_hps.npz') optimize_model(im, paper_fit_y, extra_vars, defaults)
def run(make_stims=False): defaults = PaperDefaults() #David's globals test_colors = ['orange', 'turquoise'] size = 77 csize = 3 ssize = None _MINPERPIX = 2. _DEFAULT_SM2003_CSIZE_MIN = 6.0 _DEFAULT_SM2003_SIZE_MIN = 153.0 _DEFAULT_SM2003_CPDS = sp.array([0., 1., 2., 3.3, 5., 10.]) # <from paper> _DEFAULT_SM2003_CPMS = _DEFAULT_SM2003_CPDS / 60. _DEFAULT_SM2003_CPSS = iround(1 + _DEFAULT_SM2003_CPMS * \ (_DEFAULT_SM2003_SIZE_MIN - _DEFAULT_SM2003_CSIZE_MIN)/2.0) # <realistic> _DEFAULT_SM2003_CSIZE = iround(_DEFAULT_SM2003_CSIZE_MIN / _MINPERPIX) cpss = _DEFAULT_SM2003_CPSS #Use color parameters defaults._DEFAULT_PARAMETERS['continuous'] = False defaults._DEFAULT_PARAMETERS['srf'] = _DEFAULT_SM2003_CSIZE csvfiles = { 'ObsML': { 'PL': defaults._DATADIR + '/SM2003_Fig5_ObsML_PL.csv', 'LP': defaults._DATADIR + '/SM2003_Fig5_ObsML_LP.csv', }, 'ObsPM': { 'PL': defaults._DATADIR + '/SM2003_Fig5_ObsPM_PL.csv', 'LP': defaults._DATADIR + '/SM2003_Fig5_ObsPM_LP.csv', }, } _DEFAULT_SM2003_COLORS_RGB = { 'orange': sp.array([.99, .65, .47]), 'purple': sp.array([.65, .54, .77]), # adjusted to have Y=.30 #sp.array([.60, .49, .71]), 'purple_alt': sp.array([.60, .48, .70]), 'lime': sp.array([.56, .60, .49]), # adjusted to have Y=.30 #sp.array([.61, .65, .53]), 'lime_alt': sp.array([.51, .61, .53]), 'turquoise': sp.array([.44, .78, .73]), 'neutral': sp.array([.66, .66, .66]), 'lilac': sp.array([.89, .62, .80]), 'citrus': sp.array([.67, 1.0, .50]), 'EEW': sp.array([.58, .58, .58]) } # O'Toole and Wenderoth (1977) # load digitzed data from original paper ######################################## shift_phase_paper = sp.array([ sp.genfromtxt(csvfiles['ObsML']['PL'], delimiter=',').T[1], sp.genfromtxt(csvfiles['ObsPM']['PL'], delimiter=',').T[1] ]) shift_anti_paper = sp.array([ sp.genfromtxt(csvfiles['ObsML']['LP'], delimiter=',').T[1], sp.genfromtxt(csvfiles['ObsPM']['LP'], delimiter=',').T[1] ]) shift_phase_paper = np.mean(shift_phase_paper, axis=0) #double check this shift_anti_paper = np.mean(shift_anti_paper, axis=0) gt = np.vstack((shift_phase_paper, shift_anti_paper)) #Also preload regs for postprocessing regpath = os.path.join(defaults._WORKDIR,\ 'ShevellMonnier2003.reg.pkl.std.srf%issn%issf%i' \ % (defaults._DEFAULT_PARAMETERS['srf'], defaults._DEFAULT_PARAMETERS['ssn'], defaults._DEFAULT_PARAMETERS['ssf'])) reg_X_SO = joblib.load(regpath)['reg_X_SO'] reg_Y_SO = joblib.load(regpath)['reg_Y_SO'] reg_Z_SO = joblib.load(regpath)['reg_Z_SO'] scaler_SO = joblib.load(regpath)['scaler_SO'] reg_X_SX = joblib.load(regpath)['reg_X_SX'] reg_Y_SX = joblib.load(regpath)['reg_Y_SX'] reg_Z_SX = joblib.load(regpath)['reg_Z_SX'] scaler_SX = joblib.load(regpath)['scaler_SX'] so2image = cutils.get_XYZ2RGB_predictor(reg_X_SO, reg_Y_SO, reg_Z_SO, scaler_SO) sx2image = cutils.get_XYZ2RGB_predictor(reg_X_SX, reg_Y_SX, reg_Z_SX, scaler_SX) #Add to a dictionary extra_vars = {} extra_vars['n_cps'] = len(cpss) extra_vars['cpss'] = cpss extra_vars['test_colors'] = test_colors extra_vars['_DEFAULT_SM2003_COLORS_RGB'] = _DEFAULT_SM2003_COLORS_RGB extra_vars['size'] = size extra_vars['csize'] = csize extra_vars['ssize'] = ssize extra_vars['kind'] = 'circular' extra_vars['so2image'] = so2image extra_vars['sx2image'] = sx2image extra_vars['n_col'] = len(test_colors) extra_vars['figure_name'] = 'f7' extra_vars['return_var'] = 'O' extra_vars['hp_file'] = os.path.join(defaults._FIGURES, 'best_hps.npz') # measure shift for phase & antiphase inducers, for each test if make_stims: create_stimuli(gt, extra_vars, defaults) else: optimize_model(gt, extra_vars, defaults)
def sfit(ptx_eval, ptx, pty, s=1., k=3, t=None): """ Fit a bunch of points and return an evaluation vector """ assert len(ptx) == len(pty) if t is None: return UnivariateSpline(x=ptx, y=pty, s=s, k=k)(ptx_eval) else: return LSQUnivariateSpline(x=ptx, y=pty, t=t, k=k)(ptx_eval) """ Better with center size = 7 and gamma = .25 """ #Figure 3c _DEFAULT_TILTEFFECT_DEGPERPIX = .25 # <OToole77> _DEFAULT_TILTEFFECT_SIZE = 51 #101 _DEFAULT_TILTEFFECT_CSIZE = iround(2. / _DEFAULT_TILTEFFECT_DEGPERPIX) _DEFAULT_TILTEFFECT_SSIZE = iround(8. / _DEFAULT_TILTEFFECT_DEGPERPIX) _DEFAULT_TILTEFFECT_CVAL = .5 _DEFAULT_TILTEFFECT_SVALS = sp.linspace(0.0, 0.5, 10) _DEFAULT_TILTEFFECT_SCALES = {'ow77': 0.40, 'ms79': 0.60} #0.45 _DEFAULT_TILTEFFECT_NPOINTS = 25 #100 _DEFAULT_TILTEFFECT_CIRCULAR = True _DEFAULT_TILTEFFECT_DECODER_TYPE = 'circular_vote' _DEFAULT_TILTEFFECT_CSV = { 'ow77': os.path.join(DATADIR, 'OW_fig4_Black.csv'), 'ms79': os.path.join(DATADIR, 'MS1979.csv'), } _DEFAULT_VALUE_BW3DS_SIZE = 31 _DEFAULT_VALUE_BW3DS_CSIZE = 8 _DEFAULT_VALUE_BW3DS_CVAL = .5