Friday, January 20, 2012

Filtering images in Matlab

Given image stored in matrix M:

%build the filter to convolve with the image
imFilt=fspecial('gaussian',10,10);
%convolve them
smoothed=imfilter(K,imFilt,'symmetric','conv');

Monday, November 07, 2011

Prepping for SFN

Alone in Bryan Research Building. Surprised there aren't more people here furiously getting their posters ready...

Monday, July 25, 2011

Catterall's group cracks the (closed) sodium channel

I haven't read it yet, so have no comments, just wanted to get the abstract here so I don't forget to take a closer look.

Reference
Payandeh, Scheuer, Zheng, Catterall (2011) The crystal structure of a voltage-gated sodium channel. Nature 475: 353-358.
Pubmed link

Abstract
Voltage-gated sodium (NaV) channels initiate electrical signalling in excitable cells and are the molecular targets for drugs and disease mutations, but the structural basis for their voltage-dependent activation, ion selectivity and drug block is unknown. Here we report the crystal structure of a voltage-gated Na+ channel from Arcobacter butzleri (NavAb) captured in a closed-pore conformation with four activated voltage sensors at 2.7 Å resolution. The arginine gating charges make multiple hydrophilic interactions within the voltage sensor, including unanticipated hydrogen bonds to the protein backbone. Comparisons to previous open-pore potassium channel structures indicate that the voltage-sensor domains and the S4–S5 linkers dilate the central pore by pivoting together around a hinge at the base of the pore module. The NavAb selectivity filter is short, ~4.6 Å wide, and water filled, with four acidic side chains surrounding the narrowest part of the ion conduction pathway. This unique structure presents a high-field-strength anionic coordination site, which confers Na+ selectivity through partial dehydration via direct interaction with glutamate side chains. Fenestrations in the sides of the pore module are unexpectedly penetrated by fatty acyl chains that extend into the central cavity, and these portals are large enough for the entry of small, hydrophobic pore-blocking drugs. This structure provides the template for understanding electrical signalling in excitable cells and the actions of drugs used for pain, epilepsy and cardiac arrhythmia at the atomic level.

Tuesday, April 19, 2011

Port is not line configurable?

This post is for people who get the following error in Matlab when using the data acquisition toolbox:
Warning: Port is not line configurable. All line directions on the port have been set
It took a long time for me to find an online discussion of this problem.

This is a bit of a bummer, no independent control of lines allowed by drivers for most of the newer National Instruments data acquisition cards. Thank goodness after a lot of searching, I found a thread here that describes the situation.

I'm presently trying to downgrade my NI driver to see if that fixes the problem. Will update this post once I know what's going on.

Update You can find a list of devices that support line-configuration here. Unfortunately my device is not on the list.

Exciting post about neuroscience, eh?

Thursday, June 03, 2010

Consciousness (15): Opening the time capsule

Table of Contents of posts on consciousness.
-------------------------------------

Below you'll find a series of quotations that highlight the topics we have been discussing in the last nine posts. I chose them for their exceptional eloquence, clarity, and influence. They are not in chronological order, but are roughly in ascending order of specificity of the claims. This will be the final post in this narrative arc.

The quotes
[V]ision is the process of discovering from images what is present in the world, and where it is.
     -David Marr (1982)
We may define visual perception as attributing objects to images.
     -Richard Gregory (2009)
Visual perception involves coordination between sensory sampling of the world and active interpretation of the sensory data. Human perception of objects and scenes is normally stable and robust, but it falters when one is presented with patterns that are inherently ambiguous or contradictory. Under such conditions, vision lapses into a chain of continually alternating percepts, whereby a viable visual interpretation dominates for a few seconds and is then replaced by a rival interpretation. This multistable vision, or ‘multistability’, is thought to result from destabilization of fundamental visual mechanisms, and has offered valuable insights into how sensory patterns are actively organized and interpreted in the brain…
     -Nikos Logothetis (2002)
[The Necker cube] has an interesting property. Look at it fairly steadily for a while, and the cube will invert, as if it were being viewed from another angle. After a time the percept switches back to the original one, and so on. In this case there are two equally plausible 3D interpretations of the image, and the brain is uncertain which it prefers. Notice that it only chooses one at a time, not some odd mixture of both of them…

The reason you normally see without ambiguity is that the brain combines the information provided by the many distinct features of the visual scene (aspects of shape, color, movement, etc) and settles on the most plausible interpretation of all these various visual clues taken together…[W]hat the brain has to build up is a many-leveled interpretation of the visual scene, usually in terms of objects and events and their meaning to us.
     -Francis Crick (1995)
We don’t directly experience what happens on our retinas, in our ears, on the surface of our skin. What we actually experience is a product of many processes of interpretation—editorial processes, in effect. They take in relatively raw and one-sided representations, and yield collated, revised, enhanced representations, and they take place in the stream of activity occurring in various parts of the brain. This much is recognized by virtually all theories of perception…
     -Dan Dennett (1991)
The mental activities that lead us to infer that in front of us at a certain place there is a certain object of a certain character, are generally not conscious activities, but unconscious ones. In their result they are equivalent to a conclusion, to the extent that the observed action on our senses enables us to form an idea as to the possible cause of this action; although, as a matter of fact, it is invariably simply the nervous stimulations that are perceived directly, that is, the actions, but never the external objects themselves. But what seems to differentiate them from a conclusion, in the ordinary sense of that word, is that a conclusion is an act of conscious thought… Still it may be permissible to speak of the mental acts of ordinary perception as unconscious conclusions, thereby making a distinction of some sort between them and the common so-called conscious conclusions.
     -Hermann von Helmholtz (1866)
Perception consists of interpreting two-dimensional retinal images of a three-dimensional world. The process of projecting a three-dimensional scene onto a two-dimensional retina necessarily discards information about the three-dimensional structure of the scene. This makes it impossible, in principle, to deduce all of the three-dimensional structure of a scene…However, even though such problems cannot be solved by deduction, acceptable solutions can be found using statistical inference.
     -JV Stone (2009)
Our visual experience evidently is the product of highly sophisticated and deeply entrenched inferential principles that operate at a level of our visual system that is quite inaccessible to conscious introspection or voluntary control. We do not first experience a two-dimensional image and then consciously calculate or infer the external three-dimensional scene that is most likely, given that image. The first thing we experience is the three-dimensional world—as our visual system has already inferred it for us on the basis of the two-dimensional input. Hermann von Helmholtz, the great nineteenth century scientist who more than any other single individual laid the foundations for our present understanding of visual and auditory perception, expressed this by characterizing perception as “unconscious inference.”
     -Roger Shepard (1991)
[T]he brains’ representations are hypotheses, predictive like the hypotheses of science. Like science, perception bets from available evidence on what is likely to be true…For perception, there is always guessing and going beyond available evidence. On this view, the closest we ever come to the object world is by somewhat uncertain hypotheses, selected from present evidence and enriched by knowledge from the past. Some of this knowledge is inherited—learned by the statistical processes of natural selection and stored by the genetic code. The rest is brain-learning from individual experience, especially important for humans.
     -Richard Gregory (2009)
It is the business of the brain to represent the outside world. Perceiving is not just sensing but rather an effect of sensory input on the representational system. An ambiguous figure provides the viewer with an input for which there are two or more possible representations that are quite different and about equally good, by whatever criteria the perceptual system employs. When alternative representations or descriptions of the input are equally good, the perceptual system will sometimes adopt one and sometimes another. In other words, the perception is multistable.
     -Fred Attneave (1971)
We have suggested that the biological usefulness of visual consciousness in humans is to produce the best current interpretation of the visual scene in the light of past experience, either of ourselves or of our ancestors (embodied in our genes), and to make this interpretation directly available, for a sufficient time, to the parts of the brain that contemplate and plan voluntary motor output, of one sort or another, including speech.
     -Francis Crick and Christof Koch (1998)

References
Attneave, F (1971) Multistability in perception. Sci Am. 6: 63-71.

Crick, Francis (1995) The Astonishing Hypothesis: The Scientific Search for the Soul. Scribner.

Crick, F, and Koch, K (1998) Cerebral Cortex, 8:97-107.

Dennett, D (1991) Consciousness Explained. Back Bay Books.

Gregory, RL (2009) Seeing Through Illusions. Oxford University Press.

Helmholtz, H. von 1866 Concerning the perceptions in general. In Treatise on physiological optics, vol. III, 3rd edn (translated by J. P. C. Southall 1925 Opt. Soc. Am. Section 26, reprinted New York: Dover, 1962).

Leopold, Wilke, Maier, and Logothetis (2002) Stable perception of visually ambiguous patterns. Nature Neuroscience 5: 605-609.

Marr, D (1982) Vision. WH Freeman, NY.

Shepard, RN (1991) Mind Sights, W.H.Freeman & Co Ltd.

Stone, JV, Kerrigan, IS, and Porrill, J (2009) Where is the light? Bayesian perceptual priors for lighting direction. Proc R Soc B 276: 1797-1804.

-------------------------------------
Table of Contents of posts on consciousness.

Friday, May 28, 2010

Consciousness (14): Interpretation Mechanics

Number fourteen in my series of posts on consciousness. Table of Contents is here.
-------------------------------------

The perception-as-interpretation view, summarized in the previous post, is useful as an informal ordinary-language hypothesis about consciousness. However, it is obviously a long shot from a final literal scientific theory. While it seems to be a useful way of speaking, I think we should look at it as an interesting suggestion, or perhaps even an inspiration that will lead us toward a more specific and fleshed-out theory.

There is a diverse range of theories that turn out to be special cases of the perception-as-interpretation hypothesis. These theories describe the interpretation-building mechanism alternatively as neuronal ‘model building’, ‘emulation,’ ‘virtual reality construction,’ ‘simulation of a world’, or ‘unconscious inference.’ Each specific theory carries slightly different assumptions about how the brain constructs experience, but most of them share two or more of the general features of the interpretation view delineated in previous posts.

Among psychologists, the most influential of these views is that the brain uses an unconscious inference procedure to construct a hypothesis about the source of a retinal projection. Because this theory of perception is so interesting, influential, and useful, I’ll describe it in a little bit of detail before stepping back to speak more generally about all of these theories.

Marty the Brain Scientist
To help us understand this theory, let’s imagine a tiny scientist, Marty, who lives and works in your brain (Figure 1). His sole occupation, every moment, is to monitor the movies playing on your retinae, and to build a hypothesis about their source in the world. Our conscious experience is identical to the specific hypotheses that Marty generates. For instance, if Marty’s best hypothesis about the source of the stimuli is that there is a red ball three feet to your left, that is precisely what you will see. Marty is fairly motivated to generate hypotheses accurately and quickly: after all, if you die, he dies. The more accurate his hypotheses, the better you will be able to interact with the world.

Figure 1: Marty the brain scientist.


Retinal movies are Marty’s primary source of evidence. He uses such evidence, along with various assumptions and background knowledge about how the world works, to generate hypotheses about the source of the observed projections (that is, he makes an inference about the source of the stimuli). We are only conscious of the outputs of Marty’s vocation, not any details of his inference-generating procedures. Hence the hypothesis that perception is unconscious inference.

Hypothesis formation is a special case of inference. It is a type of inference that doesn't enjoy the level of certainty granted to deductive inferences (as you’d find in mathematical proofs). Rather, when we form a hypothesis we are often throwing out our best hunch, an educated guess based on limited evidence and previous assumptions about the way the world works. Philosophers sometimes call this type of inference an ‘inference to the best explanation’ or ‘abductive inference.’

For instance, say the evidence we wish to explain includes late-night scratching sounds in the cupboard and small fecal nuggets deposited in the pantry. We could use such evidence, and our general understanding of how the world works (mice are nocturnal, etc), to construct a hypothesis that would best explain the evidence. In this case, we would likely hypothesize that there are mice living in our kitchen. Perhaps Marty settles on his hypotheses about visual stimuli using a similar process of abductive reasoning.

Obviously, Marty is merely a useful fiction. Nobody thinks there is literally a little man in your head viewing your retinal movies. Advocates of this theory believe that we will ultimately be able to give a more literal story that describes how brains construct hypotheses based on information coming in from the retinae. In the meantime, I should spell out why the unconscious inference theory appeals to psychologists.

The appeal of the theory
There are three main reasons for the theory’s appeal (aside from its impressive intellectual pedigree since Helmholtz (1866)). For one, the theory would explain how certain illusions are generated. For instance, recall Shepard’s Monsters (Figure 2) from post eleven. Shepard explains the illusion as follows:
[T]he linear perspective of the subterranean tunnel (along with other depth cues, such as the relative heights of the projections of the two monsters on our retinas) supports the automatic perceptual inference that one of the two monsters is farther back in depth. The two monsters, nevertheless being exactly the same size in the drawing, subtend the same visual angle at the eye [i.e., their projections occupy the same surface area on the retinae]. The visual system therefore makes the additional inference that in order to subtend the same visual angle, the monster that is farther back in depth must also be larger.
Notice how the idea of inference-making is built into multiple layers of Shepard’s explanation of the illusion. The brain makes inferences about which monster is further away, and then uses this information to make further inferences about which monster is larger, which explains why one monster looks bigger than the other. Note the claim isn’t that the brain only uses inferences in cases of illusions (how would the brain know if it were seeing an illusion or not?), but that illusions help reveal the underlying inferential machinery of normal perception.

Figure 2: Terra Subterranea, or Shepard’s Monsters


A second appeal is that the theory finds a mathematical home in probability theory and statistics. The brain lives in an uncertain world, and even the brain’s own responses to identical stimuli are not the same every single time (that is, the brain itself is a “noisy” processor). In mathematics, the principles of sound inference in such uncertain contexts are provided by statistics. Couching theories of brain function in the language of probability and statistics allows psychologists to state their theories with more rigor than can be done in ordinary language. Perhaps most importantly, such theories allow them to generate quantitative predictions that can be tested against the data.

Figure 3: The eye lives between a noisy brain and an uncertain world.


The third appeal applies to the ‘unconscious’ side of the ‘unconscious inference’ thesis. That is, it seems pretty clear that the processes which generate our perceptual experiences are not consciously accessible to us (as discussed in post ten and post thirteen).

Hopefully this gloss on the unconscious inference theory of perception was half as fair as it was brief. At this point I don’t want to push too hard against it (for instance, you would be right to ask what it means for the brain to perform an inference). Rather, my goal was to showcase the most prominent species of the perception-as-interpretation thesis. More than one-hundred years after Helmholtz initially suggested the hypothesis that perception is unconscious inference, Fodor and Pylyshyn were able to describe the theory, without much overstatement, as the ‘Establishment theory' of perception.

Representations within interpretations
Enough with unconscious inferences: what about all the other theories I mentioned above, such as the view that the brain builds a ‘simulation’ of the world? I am going to avoid jumping down the historical rabbit hole of comparing/contrasting the often subtle differences in this panoply of psychological-level theories of perception. Rather, it will be more productive to extract a common denominator shared by all of these theories, something all of the advocates would agree upon. If such a common factor turns out to be useful and correct, then great. If not, then we will have eliminated an entire class of models of perception with one parsimonious swing of the blade. This seems much easier than starting by contrasting every such theory pair in detail.

The one theoretical commitment shared by all these theories of perception is that the brain constructs representations of the world, and the contents of such neuronal representations are the contents of experience. Our first priority will be to analyze this idea of neuronal ‘representation’: what the heck does it mean, and how far can it take us in our quest to understand visual experiences?

While I won’t analyze the notion yet, the notion of a ‘representation’ should be intuitively familiar to most of us. Three squiggly lines on a map represent water. A photograph of someone represents the person. I’ve already sneaked in the claim that the brain constructs a ‘portrait’ of the world: a portrait of something is one type of representation. The claim we will evaluate is that one component of the brain’s interpretation of a stimulus is an internal representation of the world constructed partly based on that stimulus.

Before heading into brains, however, in the next post I will finish this chapter by posting a broad range of quotations from the literature on the topics we have explored in the last eight posts. This will help us to see how these ideas of interpretation, simulation, representation, etc are used in practice.

References
Fodor, JA, and Pylyshyn ZW (1981) How direct is visual perception? Cognition 9: 139-196.

Helmholtz, H. von 1866 Concerning the perceptions in general. In Treatise on physiological optics, vol. III, 3rd edn (translated by J. P. C. Southall 1925 Opt. Soc. Am. Section 26, reprinted New York: Dover, 1962).

Shepard, RN (1991) Mind Sights, W.H.Freeman & Co Ltd.

-------------------------------------
Table of Contents of my posts on consciousness.

Friday, May 07, 2010

How to run R code in Matlab

R (site here) is a great open-source environment for statistical analysis. But I'm a Matlab user. Luckily, it is pretty easy to run R code from Matlab. Since I just set it up in my Matlab environment, I thought I'd write out the recipe I followed. I have only done the following in Windows XP, and I used Matlab version 7.8. I think it will only work in Windows. It assumes you already have R and Matlab properly installed on your computer.

Of course, this doesn't mean I don't have to learn how to use R, it just means I get to do it all in Matlab (and note for fellow Matlab users, there is a great cheat sheet that shows how to translate between the two).

1. Install the R package rscproxy.
In R, enter:
>install.packages("rscproxy")
to install the package.

2. Install the R(D)Com server.
Download it here. The server allows Matlab to talk with R. I installed it using the default settings without checking or unchecking any boxes. Note this server is built for Scilab, which is an open source version of Matlab, but it seems to work for Matlab too.

3. Download the Matlab R-Link toolbox
Get MATLAB_RLINK.zip here, unzip the contents, and paste MATLAB_RLINK in Matlab's toolbox folder (or whatever folder you want). Be sure to add MATLAB_RLINK to your Matlab path.

4. Restart your computer.

5. Is it working?
To see if the toolbox is working, start Matlab and enter 'Rdemo' at the command prompt. This should evoke:
b =
1 4 9 16 25 36 49 64 81 100

c =
2 5 10 17 26 37 50 65 82 101

6. Have fun!
If Rdemo worked, you are ready to go!

For instance, enter the following in Matlab:
openR; %Open connection to R server
x=[1:50]; %create x values in Matlab
putRdata('x',x); %put data into R workspace
evalR('y<-sqrt(x)'); %evaluate in R
evalR('plot(x,y)') %plot in R
To close the connection to R, and the graphs opened from R, enter:
closeR;

7. Problems?
If the above doesn't work, go to C:\Program Files\R, open the (D)COM Server folder, go to 'bin', copy 'sciproxy.dll', and paste it in C:\Program Files\MATLAB\R2009a\bin (obviously you may have a different path to Matlab's binary folder). Close Matlab, and restart your computer.

If that doesn't help, I probably won't be able to help, but go ahead and ask as someone might know. The site where you downloaded R-Matlab has some useful Q&A so you might inquire there.

8. Acknowledgments
This is basically an updated version of Kevin Murphy's site. Please let me know if anything here becomes obsolete.