Skip to content

neural-reckoning/cosyne-tutorial-2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cosyne Tutorial 2022

DOI

These are the exercises for the COSYNE 2022 Tutorial, Spiking Neural Network Models in Neuroscience, by Dan Goodman.

The exercises are in Python, in the Jupyter Notebook format. You can run these notebooks either locally, or in the cloud (via Google Colab or Kaggle). We recommend following the installation instructions for running locally (found below) before the conference: the on-site Wi-Fi might be flaky and not able to handle all participants simultaneously.

Slides are available here.

Run in the cloud ☁

If you have a Google account, you can launch with Colab. If you are in a country that blocks Google, such as China, use Kaggle. (To have the notebook kernel on Kaggle persist more than 15 minutes, register for a Kaggle account). If you are on mobile and want to just read the notebooks: Colab offers a better experience than Kaggle or the GitHub notebook renderer.

Part 1 • "Classical" spiking neural networks

  • Leaky integrate-and-fire neuron: Open in Colab Open In kaggle
  • Coincidence detection (and exercise): Open in Colab Open In kaggle

Part 2 • (Machine) learning with SNNs

  • Surrogate sound localisation (and exercise): Open in Colab Open In kaggle
Solutions
  • Coincidence detection (and exercise): Open in Colab Open In kaggle
  • Surrogate sound localisation (and exercise): Open in Colab Open In kaggle

Run locally 💻

Follow the instructions below to install the software that is necessary to run the exercise notebooks on your own computer.

More detailed instructions are provided further below.

In short, if you already use conda: download this repository, and in this directory, run:

conda env create -f environment_brian.yml
conda activate cosyne22_brian
jupyter notebook

This is for the first part (which uses Brian).

For the second part (which uses PyTorch), you need to create a second environment:

conda env create -f environment_torch.yml
conda activate cosyne22_torch
jupyter notebook

Detailed instructions

Click on a section to expand it.

1. Install Conda
  • If you do not have conda already installed, download and run the latest Miniconda installer for your OS over at https://docs.conda.io/en/latest/miniconda.html#latest-miniconda-installer-links.

  • On Windows: in step 5 of the installer ("Advanced Options"), tick the checkbox next to "Add Miniconda3 to my PATH environment variable".

  • On MacOS, Ubuntu, etc, go to 'Terminal' and run chmod +x on the downloaded .sh file, then run it with ./Miniconda3-latest-{os}-{arch}.sh. On Mac, you can also download the .pkg file and install that by double-clicking.

2. Download the exercises
  • Here on GitHub, at the top of the page, click the green "Code" button, then "Download ZIP". Uncompress the downloaded .zip to a location of your choosing.

  • Alternatively, if you use Git, you can git clone this repository (or even a new GitHub fork of it, if you think you might contribute in the future).

3. Open a terminal in the exercise directory
  • On Windows, either search the Start menu for the built-in 'Command Prompt', or install the more modern Windows Terminal from the Microsoft Store (link).

  • On MacOS or e.g. Ubuntu, run 'Terminal'.

  • To run the commands in the following steps, either type or copy-paste them into the terminal, and hit Enter.

  • After starting the terminal, you can use the cd command to point it to the exercise directory. For example, if you extracted the .zip contents to C:\Users\jane\Desktop, run

    cd C:\Users\jane\Desktop\cosyne-tutorial-2022-main\
    

    (If you git cloned the repository, the directory is just called cosyne-tutorial-2022, without the branch name -main).

  • Alternatively, you can directly open a terminal in the right directory using your OS's file explorer (Explorer on Windows, GNOME on Ubuntu, …), by right clicking in the directory.

    • If you've installed Windows Terminal or are e.g. on Ubuntu, simply select "Open in (Windows) Terminal" from the right-click menu.
    • This is not applicable to vanilla Windows. (You could hold Shift while right clicking, and then select "Open PowerShell window here", but the jupyter notebook command below does not work by default in PowerShell).
  • Your final directory should be the one where this README.md and the environment_{brian|torch}.yml files are located. Use ls (or dir in Windows' Command Prompt) to see a list of the files in the current directory.

4. Install dependencies
  • With your Terminal pointing to the exercise directory, run the following command:

    conda env create -f environment_brian.yml
    

    This will download and install all dependencies. It will take a while.

  • If any errors pop up, retry the command with elevated privileges.

    • On Windows, close the terminal and reopen it with "Run as Administrator".
    • On most other OSes (including MacOS), prepend sudo to the command; i.e. sudo conda env create …, and enter the password when prompted.
  • When the installation was succesful, run

    conda activate cosyne22_brian
    

    This makes sure that all future commands ran in this terminal will use the installed software.

5. Run the notebook server
  • Still in this terminal in the exercise directory, with the cosyne22_brian conda environment activated, run

    jupyter notebook
    

    After a short while, this should open your browser, showing a list of the files in the current directory.

  • Click on one of the exercise notebook files to open it. Try running some of the cells using Shift-Enter. If no errors apear below these cells: congratulations! The installation was succesful.

  • Some more information on how to work with a Jupyter Notebook can be found e.g. here.

  • When you are done with the notebooks, you can exit the notebook server application that is still running in your terminal with Ctrl-C

6. Repeat for Part 2 of the tutorial
  • For Part 2, repeat steps 4 & 5, but replace environment_brian.yml with environment_torch.yml, and cosyne22_brian with cosyne22_torch.

  • The reason we need two separate environments is that PyTorch is difficult to install in the same environment as Brian.

Citing this

Please cite the Zenodo DOI.

DOI