
Code for replicating the results of:

		Pattern adaptation and normalization reweighting
		Zachary M. Westrick, David J. Heeger & Michael S. Landy
		Journal of Neuroscience 2016

Directories:

	code - contains most of the model code
	figureCode - generates most of the figures
	naturalEnv - code for Figure 6
	condVar - code for Figure 7

Instructions for use:

(1) The code requires Eero Simoncelli’s matlabPyrTools, which is obtainable from

	http://www.cns.nyu.edu/~lcv/software.php

Download that code, place it someplace convenient and add it to your Matlab path, e.g., by typing

	addpath ‘pyrtoolsdirectory’

(2) The code for Figure 6 requires one of Bill Geisler’s databases of natural images. 

Go to:

	http://natural-scenes.cps.utexas.edu/db.shtml#campus_scene_collection

Click on the array of campus scene images and save the images locally. Unpack the database (it is a zip file requiring some 6 GB). Move the set of .ppm images into directory "NaturalImages" inside of directory “naturalEnv”.

(3) Most of the scripts require the functions in the code directory. So, e.g., if MatLab is currently in directory ‘figureCode’, type:
	addpath ../code

(4) In directory figureCode:

	figure1N.m - corresponds to Figure 1. In addition it includes the response covariances (Figure 3G and 3H)

	figure2N.m - corresponds to Figure 2

	figure3N.m - corresponds roughly to Figure 3A-F

	figure4N_2.m - generates Figures 3I, 4J-L and 5

	figure5N - generates Figure 4B-D and 4F-H

	figure1SN - generates results for the recurrent model (Figure 4A, 4E and 4I; this takes several minutes to run)

	figure2SN - generates Figure 8

	make_tuning_video shows a video of the model running with online updates

(5) In directory naturalEnv:

	natural_env_fig_revise generates Figure 6 (and takes several minutes to run)

(6) In directory condVar:

	show_adj_cond_var3 generates Figure 7

The code is by Zachary Westrick.

contact: Michael Landy - landy@nyu.edu


