tutorial : modeling synaptic plasticitymgraupe/beirut...python – modern objectoriented programming...

20
 “Computational Neuroscience by the Mediterranean” Winter School, Jan 20 th , 2016 Michael Graupner Université Paris Descartes – CNRS UMR 8118, Paris, France [email protected] slides & scripts: http://www.biomedicale.univ-paris5.fr/~mgraupe/beirut_python  tutorial : modeling synaptic plasticity

Upload: others

Post on 21-Jun-2020

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

   

“Computational Neuroscience by the Mediterranean” 

Winter School, Jan 20th, 2016

Michael Graupner

Université Paris Descartes – CNRS UMR 8118, Paris, France

[email protected] & scripts: http://www.biomedicale.univ­paris5.fr/~mgraupe/beirut_python

 tutorial : modeling synaptic plasticity

Page 2: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

2. First steps

3. Brian introduction

1. General introductionwhy python, installation, running python 

syntax, modules and functions

(interactive IPython Notebook)

simulating a spiking recurrent network

(interactive IPython Notebook)

Outline

4. Modeling calcium­based synaptic plasticitybuilding a model simulation in python ­ exercises 

(interactive IPython Notebook)

Page 3: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Python – modern object­oriented programming language  

The Top Programming Languages 2015

[Source : IEEE Spectrum]

Page 4: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Python – very clear, readable syntax   → easy to learn

Page 5: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Python – extensive standard libraries, “Batteries included”  

­ conceptual entry cost + 

­ fis

cal e

ntry

 cos

t + 

Page 6: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Python – third party extensions for virtually every task:  

e.g. Python bindings for GUI toolkit 

Page 7: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Python modules for Neuroscience

simulators and simulator interfaces

data collection and analysis

sharing, re­use, storage and databasing of models and data

stimulus generation

parameter search and optimization

visualization

VLSI (very­large­scale integration) hardware interfacing

Page 8: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Py in Neuroscience : simulators and simulator interfaces 

e.g. Brian – the spiking neural network simulator

e.g. Python interface for NEURON 

recurrent, randomly connected network 

Page 9: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Py in Neuroscience : data collection and analysis

e.g. ACQ4

Page 10: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Py in Neuroscience : stimulus generation

e.g. Vision EGG, or PsychoPy

Page 11: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Py in Neuroscience : visualization 

e.g. matplotlib library 

Page 12: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Getting started : Python installation

Debian + Ubuntu Linux

Windows, Mac OS X (distributions for package handling) 

­ Enthought Python :  https://www.enthought.com/

­ Anaconda from Continuum Analaytics : https://www.continuum.io/downloads

­ Python(x,y) 

Alternative for Mac OS X : Install Fink, then

http://python­xy.github.io/

apt-get install python-numpy python-scipy python-matplotlib \ ipython

fink install scipy-core-py25 scipy-py25 matplotlib-py25 ipython-py25

Page 13: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Getting started : interpreters and IDEs

ipython 

­ An interactive shell for with enhanced introspection, code highlighting 

  and tab completion

Jython 

­ Another Python interpreter, written in Java instead of C

IronPython

­ a python implementation for the .NET framework

­ integrates nicely with other .NET languages

Spyder : Scientific PYthon Development EnviRonment

IPython Notebook 

­ interactive shell in the browser 

­ combines code execution, rich text, mathematics, plots and rich media 

Page 14: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

Spyder screenshot 

Page 15: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Introduction          

IPython Notebook

Page 16: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Executing Python programs 

Python programs can be run either interactively or as scripts stored in a file

The interpreter is started by calling python

Scripts are supplied as arguments to the interpreter

python ­i gives an interactive prompt after the script

 

mgraupe@thinkpadx1:~> pythonPython 2.7.10 (default, Oct 14 2015, 16:09:02) Type "help", "copyright", "credits" or "license" for more information.>>> print 'Hello world!'Hello world!>>> x = 3>>> print x+58

mgraupe@thinkpadx1:~> python hello_world.pyHello world!

Page 17: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Python scripts

The default extension for Python files is .py

Scripts start with the interpreter they should use

Optionally, you can specify the file encoding in line 2

Scripts have to be executable : chmod u+x <file>

Execute scripts as standalone programs 

#! /usr/bin/env pythonprint 'Hello world!'

mgraupe@thinkpadx1:~> ./hello_world.pyHello world!

#! /usr/bin/env python# * coding: utf 8 * print 'Total: 42 €'

Page 18: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Online Resources ­ General 

The Python documentation index : 

Python library reference : 

Dive into Python

Activestate Python cookbook : 

The Python Tutorial : 

Tentative Numpy Tutorial :

Scipy Reference  :

https://docs.python.org/2/tutorial/index.html

http://www.time.mk/trajkovski/teaching/imi/2010-fall/NumPy/Tentative%20NumPy%20Tutorial%20-.html

http://docs.scipy.org/doc/scipy/reference/genindex.html

https://docs.python.org/2.7/

http://aspn.activestate.com/ASPN/Cookbook/Python

https://docs.python.org/2.7/library/

http://www.diveintopython.net/

Page 19: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Online Resources ­ Neuroscience 

Front Neuroinform 2015 – Python in Neuroscience :

Lk

BCCN/FACETS Student Workshop ­ Using Python for Computational

BCCN course ­ Advanced Scientific Programming in Python :

Brian simulator :

http://neuralensemble.org/cookbook/wiki/FacetsPythonCourse2008

http://briansimulator.org/

https://python.g-node.org/wiki/schedule

http://journal.frontiersin.org/article/10.3389/fninf.2015.00011/full

Page 20: tutorial : modeling synaptic plasticitymgraupe/beirut...Python – modern objectoriented programming language ... Python library reference : Dive into Python ... Dive Into Python (3)

Books

Learning Python, 5th Edition

Mark Lutz

ISBN : 978­1­4493­5573­9

Dive Into Python (3)

Mark Pilgrim

ISBN: 978­1590593561 (978­1430224150)

Python for Scientists

John M. Stewart

ISBN: 978­1107686427