CNV: Assignment 1


4pm Thursday, 27 February, 2014


In this assignment, you will explore simulations for the development of retinotopy and the function of an orientation map.

You are strongly encouraged to work in pairs of your choosing, in which case you should submit one copy of the assignment, listing your partner, and the mark will be allocated equally to each. Please note, however, that pairs are expected to work on each part together, helping each other understand and figure things out, NOT dividing up the sections to be done separately. Dividing most of the work rather than working jointly will be considered scholastic dishonesty, with the appropriate corresponding penalties.

The assignment uses the Topographica simulator. For this course, we have installed Topographica in /group/teaching/cnv/topographica. To make it simple to run this copy of Topographica, open a terminal window in your home directory (or a location of your choosing), and run the command:


If you follow the prompts, this script will set up a subdirectory for you to work in for CNV, with links to the site-wide installation.

Topographica can be used together with IPython Notebook, which provides a nice command-line interface with plotting and animation support. This year for the first time we have provided Part 1 of this assignment in IPython Notebook form, and we hope that we will soon be able to do part 2 as well. If you have trouble or if you prefer a more traditional but far less powerful GUI interface, you can follow the instructions from last year instead, which are based on the older GUI tutorial covering exactly the same material.

Part 1: SOM retinotopy

First, you will need the IPython Notebook tutorial file /group/teaching/cnv/topographica/som_retinotopy.ipynb, a copy of which will be in the folder ~/topographica/ if you ran the dice_setup script from your home directory. Now start the Topographica IPython Notebook server from inside the ~/topographica/ folder:

cd ~/topographica
./topographica -n

You will see some messages printed to the terminal. In particular, make a note of the stated port number, typically a number in the range 88XX. In your browser (e.g. Chrome or Firefox), navigate to localhost:88XX where 88XX is this port number. You should now be able to select the notebook som_retinotopy from the list.

An IPython notebook is a set of cells that each may contain text, images, code, etc. Run the notebook by clicking on the first bit of text on the page and pressing Shift+Enter. Continue pressing Shift+Enter to run the cells in sequence.

Once you run cell In [4], a plot should be generated in the cell Out [4]. You should consider what aspect of the model each plot represents and you can look at the results here for comparison. Note that data shown in the static webpage were generated from a SOM model using higher retinal and cortical densities than the defaults you are using, but you should find analogous results.

Continue reading each bit of text and then executing the cells, making sure not to skip or overlook any steps, right up until you reach the final section Exploring the parameters of the SOM. Your notebook will now be running an instance of the SOM model for retinotopy, along with results from that model over the course of development. Note that everything you can see on that web page will be saved automatically with the notebook on disk for later inspection, so you don't need to keep track of it separately, although running new analyses when you load the notebook later will require re-running the cells from the start.

  1. As described in general in Exploring the parameters of the SOM, now try varying these specific parameters for this assignment:

    Random set of weight patterns
    Initial neighborhood radius
    Initial learning rate
    Retina density

    Investigate the effect of changing the four parameters mentioned above, to answer these questions:

    1. What is the effect of varying the parameter?
    2. How sensitive is SOM to that parameter? If there are changes, are they dramatic, or relatively minor? Explain.
    3. Explain why the behavior you observe occurs, referring to specific equations (by number) in chapter 3 of the CMVC text, or to the Euclidean distance activation function from the class notes.

    To observe how the development of the model is affected when a parameter is varied, it is good to start by making a clean copy of the som_retinotopy notebook. You can do this by selecting File -> Make a Copy... from the menu at the top of the som_retinotopy notebook in the browser. You can now click on the notebook name (displayed at the top of the page), which is normally something like "som_retinotopy-Copy0". You should edit the name to something meaningful that will help you keep track of all your notebooks as you change the different parameters of the SOM. Specify your chosen values in cell In [2] and restart the kernel (Kernel -> Restart from the menu). This will clear the active Python environment so that when you click on Cell -> Run All, the whole notebook will be run from scratch with your new parameters.

    Once you have a number of notebooks with different parameters for the SOM, you can start examining the differences between them. You can compare results across browser tabs, or by opening two browser windows side by side. Once you're ready to write your report, you can collect images from the notebooks using right-click and your browser's "Save Image As" function.

    Note that you usually won't need to run all the way to 40000 iterations to see what's happening, as it should be clear by about 10000 iterations whether it is going to organize properly or not. You can also omit any of the visualizations you are not interested in; you don't need to run every plot and every animation for every different parameter (since only a small subset will end up in your report).

    Also note that changing any density effectively also changes the weight_seed, because the number and thus pattern of weights will differ for different sizes.

  2. Create a new copy of the original som_retinotopy notebook, rename it to 'som_modified_input_pattern' and look at cell In [3]. You should see the definition of a variable called input_pattern. Add these lines before this variable is defined:

    import random
    def xfn():
       return random.gauss(0,0.2)
    def yfn():
       if (random.uniform(0,1)>0.5):
           return random.gauss(-0.25,0.1)
           return random.gauss(+0.25,0.1)
    Now replace the lines specifying x and y in the definition of input_pattern with:
        x = xfn, y = yfn)

    Here random.uniform returns a uniform random number in the given range, while random.gauss returns a normally distributed (i.e., Gaussian) random number with the given (mean,stddev). What topographic grid pattern do you expect the SOM to develop in this case? Describe and briefly justify your expectations. Please do this part before the next question; what's important is that you try to reason out what the network will do, not that your prediction actually matches what you find in practice. Your mark will be based on how you are reasoning about it, not on whether what you expect to occur does happen.

  3. Try self-organizing using the different input distribution. Is it developing as you expected? If not, what is different? How do your results compare to those from CMVC figure 3.7b (for a simulation described in CMVC Appendix E) -- if they differ, why do they? Do the parameters need to be changed to give a good representation for this type of input? If so, determine which one(s), and create and re-run new notebooks as necessary. In any case, save an example of a Center-of-Gravity grid plot from your final organized network, in .png format.

The overall goal of this part is to demonstrate that you understand how the SOM algorithm works, and particularly how the behavior is determined by the parameters and the distribution of input patterns, so be sure to make this clear in your responses.

Part 2: Self-organized Gaussian OR map

NOTE: As of February 18th, these instructions have been updated to use the new IPython Notebook version of the tutorial. The content covered by this new notebook version is the same as before. You are encouraged to switch to the notebook format but if you have already started this section already and wish to carry on with the Tk GUI, you may continue following last year's instructions for Part 2.

If you have already run the dice_setup script, you will need to copy the notebook from /group/teaching/cnv/topographica/GCAL_tutorial.ipynb to your topographica folder. Otherwise, this file will be found in your topographica directory after running the setup script. The two snapshot files gcal_10000.typ and lissom_oo_or_10000.typ are also available in /group/teaching/cnv/topographica/ in case you have trouble generating your own snapshots later on.

As described in Part 1, you can start the Topographica IPython Notebook server from inside the ~/topographica/ folder as follows:

cd ~/topographica
./topographica -n

Adjust the cd command appropriately if your topographica folder is not located in your home directory.

Open the notebook GCAL_tutorial in your browser, after noting the port number and navigating to localhost:88XX as described in the introduction to Part I of the assignment. In code cell of the section titled (Optional) Exploring the older LISSOM model set the model variable to the string 'LISSOM', replacing the default string 'GCAL'. Now run every cell from the top of the notebook to the bottom by pressing Shift+Enter, executing each cell in turn.

Note that the first time you run through the notebook, you may to need to wait a couple of minutes for a new snapshot to be generated in the section titled Loading the model. If you have trouble generating the snapshot (e.g if it takes much longer than expected) you can try using the lissom_oo_or_10000.typ snapshot available in group/teaching/cnv/topographica/ by copying it into your topographica folder.

  1. For a Line stimulus, systematically vary the following input parameters and observe the V1 response (and LGN response, if appropriate) following the example in the section Presenting a test stimulus:

    Brightness of the line
    Brightness of the background
    vertical location of the line
    Orientation of the line
    line thickness
    edge smoothing

    Make sure to consider the effect of modifying each parameter independently. For each parameter, report your observations on how the LISSOM map responds:

    1. Is the value of that parameter encoded in a useful way in the map activity? Explain.
    2. How sensitive is LISSOM to that parameter? If there are changes, are they dramatic, or relatively minor? Explain.
    3. Do you think the LISSOM response is biologically realistic, based on the biological background presented in this course? Why or why not?
    4. Explain why the behavior you observe occurs, referring to specific equations (by number) in chapter 4 of the CMVC text, and to the self-organized weights shown in the section titled The weights to a V1 neuron.

    Note that when varying the scale or offset, it is very easy to get confused by the plots. The highest activity is shown as 100% white and zero activity is shown as 100% black. You should always be able to see the overall pattern of activity but the absolute activity values are obscured. The best way to evaluate the underlying activity values is to get the raw numpy array as shown in the Activity statistics subsection of Presenting a test stimulus.

  2. Explain why the LGNOnAfferent weights to V1 neurons in the section The weights to a V1 neurons look very similar to each other, yet very different from the LGNOffAfferent weights to V1. What effect will this have on the ability to respond to lines that are brighter than the mean luminance? What effect will it have for darker lines? What does this indicate about the suitability of the chosen training pattern as a model for natural images?
  3. For any of the cases where you argued that the behavior was not biologically realistic, compare the LISSOM results to those from a model we recently developed called GCAL (in examples/gcal.ty). You can explore GCAL by restarting the kernel (Kernel -> Restart) and restoring the default variable assignment model = 'GCAL' in the section titled (Optional) Exploring the older LISSOM model) before re-running the notebook.

    A static reference of what the notebook should look like when exploring the GCAL model may be found here. As when you loaded the LISSOM model, you may need to wait a few minutes for a new GCAL snapshot to be generated (gcal_10000.typ is available if you have any issues). Does GCAL provide more realistic results? Can you see any obvious problems?

    For the purposes of this assignment, you can just treat the trained GCAL map as the same as LISSOM except for adding contrast gain control (similar to the afferent normalization discussed in the text), but if you want to see more about GCAL, it is described in Stevens et al. J. Neuroscience 2013.

Preparing your assignment

Although your assignment need not be as polished as a publication, the guidelines described in Topographica's section on generating high-quality figures can be helpful. If you are using results generated in a notebook, you can simply save images with right-click and your browser's "Save Image As" function. If you are using the Tk GUI, instead of awkwardly grabbing screenshots, you can save plots using Python commands like:

More information about saving output from the Tk GUI using Python commands is available in the Preparing your assignment portion of last year's instructions.

If you care to get into it, there is a command called run_batch that does this all automatically, making it simple to override parameters, run a set of analyses at a list of specified iterations, and automatically put the parameter changes into every filename. If you're even more ambitious, you can use our Lancet package to run big sets of batch simulations together covering different parameters and conditions, automatically collecting the results together as described in our 2013 Frontiers in Neuroinformatics paper. But none of that is required for the CNV course; it's just mentioned here to make sure that no one goes off and tries to duplicate this functionality themselves.


Your work must be submitted by the deadline using the submit command on Informatics DICE machines (type man submit for more details). To allow me to work with these files efficiently, you must follow these guidelines:

  1. Submit only one PDF file, named asst1.pdf.
  2. On the first page, include the student ID number(s) for any student who worked on this assignment.
  3. Do not include the names of any students anywhere in the document, to allow anonymous marking.
  4. Each problem (1.1, 1.2, 1.3, 2.1, 2.2, and 2.3) must be on a separate page; otherwise I am very likely to miss bits that you'll want me to count towards a particular problem.

Standard late policies will apply as described in your course guide, namely that late coursework is not accepted without good reason, which must be discussed with the ITO, not the lecturer. Similarly, standard academic misconduct policies apply as described in the University guidelines; in particular; students must clearly label any aspect of their submission that is not their own independent work (or that of their named partner).

Example of submit command:

submit cnv 1 asst1.pdf

Tips for getting a good mark

Be sure that you provide evidence that you did each part of this assignment. I can only judge what is actually submitted, so you should make sure that the files you submit make it clear that you have done everything, and thought about everything.

Be sure to cite any information that you use that is not from the course material or your own experience. Including such information is encouraged, but it must be properly cited. You can use the CMVC book Bibliography database for citation information for any paper cited in the CMVC text.

Submissions MUST use PDF, so that I can be sure to be able to read them and so that I can process all submissions from all students uniformly. Other formats like .doc or .sxw have a certain probability of working, but the probability is far from 1.0, and they cause a lot of problems. Naming and formatting the files as I require will make my job a lot easier and will make sure you get credit for everything you do, because I will be able to see exactly what you are submitting for each problem.

Please read and follow my list of writing tips.

Last update: assignment1.html,v 1.21 2014/02/18 15:43:40 s0787336 Exp

Home : Teaching : Courses : Cnv : 2013-2014 : Coursework 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail:
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh