lecture 2 basic neurobiology & machine learning for brain...

24
1 R. Rao, IISc course: Lecture 2 Lecture 2 Basic Neurobiology & Machine Learning for Brain-Computer Interfacing 2 R. Rao, IISc course: Lecture 2 Today’s Roadmap PART I: Basic Neuroscience for BCI The neuron doctrine (or dogma) Neuronal signaling Action Potentials (= spikes) Synapses Brain organization and function PART II: Basic Machine Learning for BCI Supervised Learning Regression: Linear, polynomial Radial Basis Functions Artificial Neural Networks

Upload: others

Post on 20-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

1R. Rao, IISc course: Lecture 2

Lecture 2

Basic Neurobiology & Machine Learning for Brain-Computer Interfacing

2R. Rao, IISc course: Lecture 2

Today’s Roadmap

PART I: Basic Neuroscience for BCIThe neuron doctrine (or dogma)Neuronal signaling

Action Potentials (= spikes)Synapses

Brain organization and function

PART II: Basic Machine Learning for BCISupervised Learning

Regression: Linear, polynomialRadial Basis FunctionsArtificial Neural Networks

Page 2: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

3R. Rao, IISc course: Lecture 2

Our 3-pound Universe

Pons

Medulla

Spinal cord

Cerebellum

Cerebrum/Cerebral CortexCerebrum/Cerebral Cortex

Thalamus

4R. Rao, IISc course: Lecture 2

Enter…the neuron (“brain cell”)

Pons

Medulla

Spinal cord

Cerebellum

Cerebrum/Cerebral CortexCerebrum/Cerebral Cortex

Thalamus

A Pyramidal Neuron

~40 μm

Page 3: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

5R. Rao, IISc course: Lecture 2

The Neuron Doctrine/Dogma

From Kandel, Schwartz, Jessel, Principles of Neural Science, 3rd edn., 1991, pg. 21

CerebralCortex Neuron

Neuron from theThalamus

Neuron from theCerebellum

Neuron Doctrine: “The neuron is the appropriate basis for understanding the computational and functional properties of the brain”First suggested in 1891 by Waldeyer

6R. Rao, IISc course: Lecture 2

The Idealized Neuron

Input (axons

from other neurons)

Output Spike

(EPSP = Excitatory Post-Synaptic Potential)

Page 4: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

7R. Rao, IISc course: Lecture 2

What is a Neuron?

A “leaky bag of charged liquid”

Contents of the neuron enclosed within a cell membrane

Cell membrane is a lipid bilayerBilayer is impermeable to charged ion species such as Na+, Cl-, K+, and Ca2+

Embedded ionic channels or “gates” allow ions in or out From Kandel, Schwartz, Jessel, Principles of

Neural Science, 3rd edn., 1991, pg. 67

8R. Rao, IISc course: Lecture 2

The Electrical Personality of a Neuron

Each neuron maintains a potential difference across its membrane

Inside is –70 to –80 mVrelative to outside

Ionic pump maintains -70 mV difference by expelling Na+ out and allowing K+ ions in

[Na+], [Cl-], [Ca2+][K+], [A-]

[K+], [A-][Na+], [Cl-], [Ca2+]

Outside

Inside-70 mV

0 mV

Page 5: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

9R. Rao, IISc course: Lecture 2

The Output of a Neuron: Action Potentials

Voltage-gated channels cause action potentials (spikes)1. Rapid Na+ influx causes

rising edge2. Na+ channels deactivate3. K+ outflux restores

membrane potential

From Kandel, Schwartz, Jessel, Principles of Neural Science, 3rd edn., 1991, pg. 110

Action Potential (spike)

10R. Rao, IISc course: Lecture 2

Propagation of a Spike along an Axon

From: http://psych.hanover.edu/Krantz/neural/actpotanim.html

Page 6: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

11R. Rao, IISc course: Lecture 2

Communication between Neurons: Synapses

Synapses are the “connections”between neurons

Electrical synapses (gap junctions)Chemical synapses (use neurotransmitters)

Synapses can be excitatory or inhibitory

Synapse Doctrine: Synapses are the basis for memory and learning

12R. Rao, IISc course: Lecture 2

Distribution of synapses on a real neuron…

Page 7: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

13R. Rao, IISc course: Lecture 2

Organization of the Nervous System

CentralNervous System

Brain Spinal Cord

PeripheralNervous System

Somatic Autonomic

14R. Rao, IISc course: Lecture 2

Autonomic and Central Nervous System

Autonomic: Nerves that connect to the heart,blood vessels, smooth muscles, and glands

CNS = Brain + Spinal CordSpinal Cord:

• Local feedback loops control reflexes• Descending motor control signals from

the brain activate spinal motor neurons• Ascending sensory axons transmit

sensory feedback information from muscles and skin back to brain

Page 8: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

15R. Rao, IISc course: Lecture 2

Major Brain Regions: Cerebral Hemispheres

Consists of: Cerebral cortex, basal ganglia, hippocampus, and amygdala

Involved in perception and motor control, cognitive functions, emotion, memory, and learning

Corpuscollosum

rebral Cor

Pons

Medulla

Spinal cord

Cerebellum

Cerebrum/Cerebral CortexCerebrum/Cerebral Cortex

16R. Rao, IISc course: Lecture 2

Cerebral Cortex: A Layered Sheet of Neurons

From Kandel, Schwartz, Jessel, Principles of Neural Science, 3rd edn., 1991, pgs.

Cerebral Cortex: Convoluted surface of cerebrum about 1/8th

of an inch thick

Six layers of neurons

Approximately 30 billion neurons

Each neuron makes about 10,000 synapses: approximately 300 trillion connections in total

Page 9: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

17R. Rao, IISc course: Lecture 2

Specialization of Function in Cerebral Cortex

VisualProcessing

somatosensorycortex

Motor Planning,Higher cognitive

functions

Visual and auditoryrecognition

Spatial reasoning and motion

18R. Rao, IISc course: Lecture 2

Hierarchical Organization of Visual Cortex

Page 10: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

19R. Rao, IISc course: Lecture 2

The Visual ProcessingHierarchy

20R. Rao, IISc course: Lecture 2

Tuning Curve of a Visual Cortical Neuron

Spike trains as a function of bar orientation

Gaussian Tuning Curve

Page 11: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

21R. Rao, IISc course: Lecture 2

The Motor Hierarchy

Supplementarymotor area

Premotorarea

M1 (Primary motor cortex) Posterior

parietal cortex

Prefrontal cortex

Brainstem Cerebellum

22R. Rao, IISc course: Lecture 2

Tuning Curve of a Neuron in M1

Spike trains as a function of hand reaching direction

Cosine Tuning Curve

Preferred direction

Page 12: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

23R. Rao, IISc course: Lecture 2

Movement Direction can be Predicted from a Population of M1 Neurons’ Firing Rates

Population vector = sum of preferred directions weighted by their firing rates

Population vectors (decoded movement direction)

Actual arm movement direction

Actual arm movement direction

24R. Rao, IISc course: Lecture 2

SomatotopicOrganization of M1 (a.k.a. the “homunculus”)

Page 13: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

25R. Rao, IISc course: Lecture 2

Electrically stimulating M1 elicits primitive movements

Electrically stimulating PremotorArea elicits more complex movements

26R. Rao, IISc course: Lecture 2

Activity in Motor Hierarchy during Reaching

Page 14: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

27R. Rao, IISc course: Lecture 2

Summary: Brain versus Digital ComputingDevice count:

Human Brain: 1011 neurons (each neuron ~ 104 connections)Silicon Chip: 1010 transistors with sparse connectivity

Device speed:Biology has 100µs temporal resolutionDigital circuits approaching 100ps clock (10 GHz)

Computing paradigm:Brain: Massively parallel computation & adaptive connectivityDigital Computers: sequential information processing via CPU with fixed connectivity

Capabilities:Digital computers excel in math & symbol processing…Brains: Better at solving ill-posed problems (speech, vision)?

28R. Rao, IISc course: Lecture 2

Part II: Basic Machine Learning for BCI

Input neural activity over time

Output over time(hand position)

Learn mapping

Page 15: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

29R. Rao, IISc course: Lecture 2

Why machine learning for BCIs?

In most BCI applications, we have example inputs and outputs

Inputs = Neural data; Outputs = Position of hand or robot, class of imagined movement etc.

We wish to learn a function mapping arbitrary inputs to outputs

Supervised learning

Dominant paradigms in BCI literatureMap neural activity to continuous outputs (e.g., hand position) ⇒ regression (Invasive BCIs).Classify brain patterns into one of several classes, and use this to select action ⇒ classification (EEG BCIs)

30R. Rao, IISc course: Lecture 2

Outline

RegressionLinear, polynomialRBFs, perceptrons, multilayer neural networks

ClassificationLinear classifiers, support vector machinesMulti-class classifiers

Cross-validationModel selection, preventing overfitting

Page 16: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

31R. Rao, IISc course: Lecture 2

Linear Regression

x y1 3.1

2 6.43.1 8.90.9 2

y

x

Assumption: Output is a linear function of input, i.e., yi= wxi + noise

where noise is independent, gaussian, unknown fixed variance

input

output

32R. Rao, IISc course: Lecture 2

Linear Regression

Given: Data (yi, xi) where yi are drawn from N(wxi, σ2)

Likelihood of data (yi, xi) for a given w is:

Πi p(yi | w, xi) which is equal to

Πi exp( -0.5 (yi– wxi))2/σ2 (ignoring constants)

Goal: Maximize the likelihood of data given w

i.e., maximize: Σi -0.5(yi-wxi)2/σ2

i.e., minimize: Σi (yi –wxi)2

Easy to show that w = Σ xi yi / Σ (xi)2

Page 17: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

33R. Rao, IISc course: Lecture 2

But…typically, inputs in BCIs are vectors of multiple neurons’

activities, multiple EEG measurements, etc.

Need Multivariate Regression

Input vector

Output(hand position)

34R. Rao, IISc course: Lecture 2

Multivariate regression

Suppose inputs xi are n-element vectors: yi =wTxi + noise

Write the m data points as:

Then, Y = Xw + noise

Maximum likelihood w is

w = (XTX)-1(XTY)

⎥⎥⎥⎥

⎢⎢⎢⎢

=

mnmm

n

n

xxx

xxxxxx

L

MMMM

L

L

21

22221

11211

X

⎥⎥⎥⎥

⎢⎢⎢⎢

=

my

yy

M2

1

Y

Page 18: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

35R. Rao, IISc course: Lecture 2

Linear regression: constants

What if data does not go through origin?

x y

1 8.1

2 11.4

3.1 13.7

0.7 7

36R. Rao, IISc course: Lecture 2

Linear Regression: constants

Solution: Add a dummy input fixed at 1 and learn its coefficient (constant offset)

Learn w for the new function y = wTz + noise = w1x + w0 + noise

x y

1 8.1

2 11.4

3.1 13.7

0.7 7

z0 z1 (= x) y

1

1

1

1

1 8.1

2 11.4

3.1 13.7

0.7 7

z

Page 19: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

37R. Rao, IISc course: Lecture 2

What if the data looks like this?

Need to generalize to non-linear regression…any ideas?

38R. Rao, IISc course: Lecture 2

Non-Linear Regression: Polynomials

Use same trick as for constants:Replace input x by modified input vector z

Learn the coefficients w from the model y = wTz + noisewhich is equivalent to: y = w0 + w1x1 + w2x2 + w3x1

2…

z0 z1 z2 z3 z4

1

(xi1)2

(xi2)2

……

xi2

z5 y

… …

xi1xi2

xi1 yi

… …

Example: Quadratic Regression with original input x = [x1 x2]

Page 20: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

39R. Rao, IISc course: Lecture 2

More Non-Linear Regression: Radial Basis Functions (RBFs)

Create features that are arbitrary “basis” functions (or kernel functions) of the input vector

e.g., zi = KernelFunction(|xi – ci|/γi) where ci s and γi s are constants to be learnedLearn the coefficients w from y = wTz + noise

Basis Functions z1, z2, z3

Data Points yi

Function: y = 2z1 + 3.8z2 + 2.3z3

c1 c2 c3 zi = exp(-(|xi – ci|/γi)2)

40R. Rao, IISc course: Lecture 2

Artificial Neural Networks: Perceptrons

Input nodes aeag β−+

=1

1)(

a

Ψ(a)1

The most commonactivation function:

Sigmoid function:

Squashes wTu to be between 0 and 1. The parameter β controls the slope.

g(a)

)()(

332211 uwuwuwggv T

++== uw

u = (u1 u2 u3)T

w

Outputv

Want to learn a mapping from inputs to outputs, given training data (um,dm).

How is w learned?

Page 21: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

41R. Rao, IISc course: Lecture 2

Learning the Weights: Gradient Descent

Given training examples (um,dm) (m = 1, …, N), define an error function (cost function or “energy” function)

2)(21)( m

m

m vdE −= ∑w

)( mTm gv uw=where

42R. Rao, IISc course: Lecture 2

Learning the Weights: Gradient Descent

Would like to estimate w so that error E(w) is minimizedGradient Descent: Change w in proportion to –dE/dw(why?)

mmTmm

m

mmm

m

gvdddvvd

ddE

ddE

uuwww

www

)()()( ′−−=−−=

−→

∑∑

ε

Derivative of sigmoid

Page 22: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

43R. Rao, IISc course: Lecture 2

Multilayer Networks

One layer networks can only learn a limited class of functions. E.g., cannot learn XOR function

To learn arbitrary functions, need multiple layers

How do we learn these weights?

Input u = (u1 u2 … uK)T

Output v = (v1 v2 … vJ)T; Desired = d

44R. Rao, IISc course: Lecture 2

Idea: “Backpropagation” Learning Rule

2)(21),( i

ii vdE −= ∑wW

Start with random weights {W, w}

Given input u, network produces output v

Find W and w that minimize total squared output error over all output units (labeled i):

))(( kk

kjj

jii uwgWgv ∑∑=

ku

Page 23: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

45R. Rao, IISc course: Lecture 2

Backpropagation: Output Weights

jj

jjiiiji

jijiji

xxWgvddWdE

dWdEWW

)()( ∑′−−=

−→ ε

)( jj

jii xWgv ∑=

ku

jx

Learning rule for hidden-output weights W:

2)(21),( i

ii vdE −= ∑wW

{gradient descent}

46R. Rao, IISc course: Lecture 2

)( jj

jimi xWgv ∑=

mku

⎥⎦

⎤⎢⎣

⎡ ′⋅⎥⎦

⎤⎢⎣

⎡′−−=

⋅=−→

∑∑∑ mk

mk

kkjji

j

mjji

mi

mi

imkj

kj

j

jkjkjkjkj

uuwgWxWgvddwdE

dwdx

dxdE

dwdE

dwdEww

)()()(

:But

,

ε {chain rule}

)( mk

kkj

mj uwgx ∑=

Learning rule for input-hidden weights w:

2)(21),( i

ii vdE −= ∑wW

Backpropagation: Hidden Weights

Page 24: Lecture 2 Basic Neurobiology & Machine Learning for Brain ...math.iisc.ernet.in/~imi/downloads/Lecture2.pdf · More Non-Linear Regression: Radial Basis Functions (RBFs))Create features

47R. Rao, IISc course: Lecture 2

Example Application in BCI

(Nicolelis, 2001)

We examine this type of BCIs on Friday…

48R. Rao, IISc course: Lecture 2

Outline

Supervised Learning: RegressionLinear, polynomial.RBFs, perceptrons, multilayer networks.

Supervised Learning: ClassificationLinear classifiers, support vector machinesMulti-class classification

Cross-validationModel selection, preventing overfitting

Next Lecture

will cover

this

plus

Non-Invasive BCIs

See you tomorrow!