Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Visual DMS simulation

Antonio Ulloa edited this page Jun 25, 2015 · 28 revisions

The following tutorial will show you how to install LSNM and perform a visual Delayed Match-to-Sample (DMS) simulation. As shown in the figure below, the DMS experiment to be simulated consists of a visual stimulus (S1) being presented to a subject, followed by a delay period during which time no stimulus is presented. At the end of the delay period, a second visual stimulus (S2) is presented to the subject, after which the subject must respond whether S1 and S2 are the same or different (Response).

Because the input module to our visual neural network (LGN) is composed of 81 units in the form of a 9x9 matrix, we need to organize our visual inputs in a 9x9 grid. We will initialize the units of our grid to zero and, in order to turn on selected units within the grid, we will assigning values of 0.92 to those units. For this tutorial, we will make use of the following three input files representing two-dimensional object shapes, all of them arranged in 9x9 grids and located in the directory $LSNM/inputs:

We will simulate three trials by making use of three script files: pethi1.s, pethi2.s, and pethi3.s. Those files are located within the directory $LSNM and they define the modules of the neural network as well as make reference to their respective connecting weight files and experimental script files. You can go ahead and visually inspect pethi1.s, pethi2.s, and pethi3.s: You will notice how each individual module of the neural network is defined as a 9x9 rectangle. The experimental script files that pethi1.s, pethi2.s, and pethi3.s refer to are, respectively, pethi1.rsb, pethi2.rsb, and pethi3.rsb (located in $LSNM/inputs). Our first experimental trial, defined in pethi1.rsb, uses input1.inp as both first stimulus and second stimulus, so we are expecting to get a match as a response at the end of trial 1. Our second trial, defined in pethi2.rsb, uses input2.inp as first stimulus and input1.inp as second stimulus, so we are clearly expecting a mismatch as a response at the end of trial 2. Finally, our third trial, defined in pethi3.rsb, uses input3.inp as both first and second stimulus, so we do expect a match at the end of trial 3. Now, please go ahead and visually inspect pethi1.rsb, pethi2.rsb, and pethi3.rsb: You will notice the command Run being used with a number following it. The command Run executes n number of time steps with the currently defined neural network and for the visual model we are assuming that one second of real time corresponds roughly to 200 simulation time steps.

In this tutorial, we will simulate one single subject and three experimental trials. Please inspect the file mkbatchb.in, located in $LSNM/code, that defines the simulation parameters used in this tutorial.

NOTE: If you already have a working copy of LSNM, go directly to STEP 2

1. Download a copy of LSNM to your local workstation

  • Launch Firefox or another web browser available on your local Unix workstation and copy/paste the following internet address (or just click on the highlighted link if you are in a browser already): https://github.com/NIDCD/lsnm.

  • When the LSNM Github page displays, click on the button Download ZIP located on the right sidebar. Click on Save File to download the zip file containing the LSNM code to your Downloads folder.

  • Inspect your downloads folder to make sure you have downloaded the LSNM files. There should be a file called lsnm-master.zip in it.

  • Unzip the file in your preferred location:

      $ unzip lsnm-master.zip
    
  • Change the name of the lsnm directory (to keep the sim executable from having problems with the special character -:

      $ mv lsnm-master lsnm
    
  • NOTE: If you do not have access to an internet browser you can grab a copy of the LSNM repository by typing the following command on your local Unix workstation. Please note that at a directory called sim will be created in the directory where you are currently located:

      $ git clone https://github.com/NIDCD/lsnm.git
    

2. Initialize the Unix environment variable $LSNM

As LSNM makes reference to a directory path relative an environmental variable called $LSNM, one needs to declare and initialize that variable.

  • Launch a text editor (e.g., emacs) and open the file .bash_profile, located in your home directory:

      $ emacs ~/.bash_profile &
    
  • Add the following variable declaration at the end of .bash_profile. Please note that the following assumes that the LSNM directory structure was stored within the directory called lsnm-master just under your home directory, but please adjust the name if that is not the case:

      LSNM=$HOME/lsnm/visual/
      export LSNM
    
  • Save the file and exit

  • Upload the $LSNM variable to memory by typing the command below. Please note that you only need to do this once as it will be done automatically in the future every time you log in to your local workstation:

      $ source ~/.bash_profile
    
  • Double-check that the variable $LSNM has been successfully uploaded to the environment by printing out the contents of it:

      $ echo $LSNM
    

3. Recompile executables

  • Type the following in order to recompile the executables:

      $ cd $LSNM/code
      $ make altgenw
      $ make altgenw_L
      $ make crossws
      $ make crosswt_i
      $ make genw
      $ make mkattn
      $ make mkinput
      $ cd $LSNM/code/netgen
      $ make netgenC
      $ make netgenC_L
      $ cd $LSNM/code/sim
      $ make sim1
    

4. Create a batch file and run the simulation

  • Make the batch:

      $ cd $LSNM/code
      $ make mkbatchb
      $ cd $LSNM
      $ ./bin/mkbatchb
    
  • Now execute it!

      $ ./batchb
    

5. Plot your output

  • Verify that the output files have been created (you should be able to see a directory structure organizing output files by subject then by trial):

      $ cd $LSNM/RGC
    
  • Execute python code that plots simulated electrophysiological data from subject 1 / trial 1:

      $ cd $LSNM/RGC/subj1/b30/trial1
      $ gunzip *.gz
      $ python $LSNM/code/visualization/plotVisual.py &
    
  • Now go to matlab and execute an animation of the simulation (note that you will need to add $LSNM/code/visualization to your path in matlab before running the animation):

      $ matlab &
      fx> loadmovieB
    
Clone this wiki locally