Making MATLAB pretty

Alright all y’all haters, it’s MATLAB time.

For better or worse, MATLAB is the language that is used for scientific programming in neuroscience. But it, uh, has some issues when it comes to visualization. One major issue is the clusterfuck that is exporting graphics to vector files like eps. We have all exported a nice-looking image in MATLAB into a vectorized format that not only mangles the image but also ends up somehow needing thousands of layers, right?  Thankfully, Vy Vo pointed me to a package on github that is able to clean up these exported files.

Here is my favorite example (before, after):

If you zoom in or click the image, you can see the awful crosshatching in the before image. Even better, it goes from 11,775 layers before to just 76 after.

On top of this, gramm is a toolbox to add ggplot2-like visualization capabilities to MATLAB:

(Although personally, I like the new MATLAB default color-scheme – but these plotting functions are light-years better than the standard package.)

Update: Ben de Bivort shared his lab’s in-house preferred colormaps. I love ’em.

Update x2: Here’s another way to export your figures into eps nicely. Also, nice perceptually uniform color maps.

Advertisements

Why does the eye care about the nose?

The ear, the nose, the eye: all of the neurons closest to the environment are doing on thing: attempting to represent the outside world as perfectly as possible. Total perfection is not possible – you can only only make the eye so large and only need to see so much detail in order live your life. But if you were to try to predict what the neurons in the retina or the ear are doing based on what could provide as much information as possible, you’d do a really good job. Once that information is in the nervous system, the neurons that receive this information can do whatever they want with it, processing it further or turning it directly into a command to blink or jump or just stare into space.

Even though this is the story that all of us neuroscientists get told, it’s not the full thing. Awhile back, I posted that the retina receives input from other places in the brain. That just seems weird from this perspective. If the retina is focused on extracting useful information about the visual world, why would it care about how the world smells?

One simple explanation might be that the neurons only want to code for surprising information. Maybe the nose can help out with that? After all, if something is predictable then it is useless; you already know about it! No need to waste precious bits. This seems to be what the purpose of certain feedback signals to the fly eye are for. A few recent papers have shown that neurons in the eye that respond to horizontal or vertical motion receive signals about how the animal is moving, so that when the animal moves to the left it should expect leftward motion in the horizontal cells – and so only respond to leftward motion that is above and beyond what the animal is causing. But again – what could this have to do with smells?

Let’s think for a second about some times when the olfactory system uses non-olfactory information. The olfactory system should be trying to represent the smell-world as well as it can, just like the visual system is trying to represent the image-world. But the olfactory system is directly modulated depending on the needs of an animal at any given moment. For instance, a hungry fly will release a peptide that modifies how much a set of neurons that respond to particular odors can signal the rest of the brain. In other words, how hungry an animal is determines how well it can smell something!

These two stories – how the eye interacts with the motion of the body, how the nose interacts with hunger – might give us a hint about what is happening. The sensory systems aren’t just trying to represent as much information about the world as possible, they are trying to represent as much information about useful stuff as possible. The classical view of sensory systems is a fundamentally static one, that they have evolved to take advantage of the consistencies in the world to provide relevant information as efficiently as possible*. But the world is a dynamic place, and the needs of an animal at one time are different from the needs of the animal at another.

Take an example from tadpoles. When the tadpole is in a very dim environment, it has a harder time separating dark objects from the background. The world just has less contrast (try turning down the brightness on your screen and reading this – you’ll get the idea). One way that these tadpoles control their ability to increase or decrease contrast is through a neuromodulator that changes the resting potential of a cell (how responsive it is to stimuli), but only over relatively long timescales. This is not fast adaptation but slow adaptation to the changing world. The end result of this is that tadpoles are better able to see moving objects – but presumably at the expense of being worse at seeing something else. That seems like a pretty direct way of going from a need for the animal to code certain visual information more efficiently to the act of doing it. The point is not that this is driven by a direct behavioral need of the animal – I have no idea if this is due to a desire to hunt or avoid objects or what-have-you. Instead, it’s an example of how an animal could control certain information if it wanted to.

This kind of behavioral gating does occur from retinal feedback. Male zebrafish use a combination of smell and sight when they decide how they want to interact with other zebrafish. Certain olfactory neurons that respond to a chemical involved in mating signal to neurons in the retina – making certain cells more or less responsive in the same way that tadpoles control the contrast of their world (above). It appears as if the olfactory information sends a signal to the eye that either gates or enhances the visual information – the stripe detection or what-have-you – that the little fishies use when they want to court another animal.

The sensory system is not perfect. It must make trade-offs about which information is important to keep and which can be thrown away, about how much of its limited bandwidth to spend on one signal or another. A lot of the structure comes naturally from evolution, representing a long-term learning of the structure of the world. But animals have needs that fluctuate over other timescales – and may require more computation than can be provided directly in the sensory area. How else would the eye know that it is time to mate?

What this doesn’t answer is why the modulation is happening here; why not downstream?

 

* This is a major simplification, obviously, and a lot of work has been done on adaptation, etc in the retina.

 

Monday Open Question: what do you need to do to get a neuroscience job? (Updated)

Awhile back I asked for help obtaining information on people who had gotten a faculty job in 2016 – 2017. And it worked! With a lot of help, I managed to piece together a list with more than 70 people who had gotten faculty jobs during this last year! I am sure it is incomplete (I keep getting new tips as of ten minutes ago…) but it is time to discuss some of the interesting features of the data.

First, the gender ratio: there are 44 men on the list to 33 women (57%). Over at the neurorumblr, 62% of the people on the Postdoc List were men which is roughly the same proportion.

To get more data, I focused on faculty hires who had a Google Scholar profile – it made it much easier to scrape data. It was suggested that people in National Academy of Sciences or HHMI labs may have a better chance of getting a faculty job. Out of the 51 people with a Google Scholar profile, 4 were in both NAS/HHMI labs, 8 were in HHMI-only labs, and 4 were in NAS-only labs.  Only one person who as in a HHMI/NAS lab in grad school went to a non-HHMI/NAS lab. People also suggested that a prestigious fellowship (HHWF, Damon Runyon, Life Sciences, etc.) It is hard to tell, but there didn’t seem like a huge number of these people gaining a job last year.

The model organisms they use are:

(15) Humans

(13) Mouse

(6) Rat

(4) Monkey

(3) Drosophila

(3) Pure computational

+ assorted others

Where are they all from? Here is the distribution of institutions the postdocs came from (update: though see the bottom of the post for more information):

 

In case you hadn’t noticed, this is a pretty geographically-concentrated pool of institutions. Just adding up schools that are in the NYC+ area (NYC-itself, plus Yale and Princeton), the Bay Area, Greater DC (Hopkins + Janelia), and ‘those Boston schools’. I’m not sure this accurately represents the geographic distribution of neuroscientists.

What about their publications? They had a mean H-index of 11.98 (standard deviation ~ 4.21).

We always hear that “you need a Cell/Nature/Science paper in order to get a job”. 29.4% (15/51) of this pool have a first- or second-author CNS paper. 68% (35/51) have a first- or second-author Nature Neuroscience/Neuron/Nature Methods paper. 78% (40/51) have some combination of these papers. It’s possible that faculty hires have CNS papers in the pipeline, but unless every single issue of CNS is dedicated to people who just got a faculty job this probably isn’t the big deal it’s always made out to be.

There’s a broader theory that I’ve heard from several people (outlined here) that the underlying requirement is really the cumulative impact factor. I have used the metric described in the link, where the approximate impact factor is taken from first-author publications and second-author publications are discounted 75% (reviews are ignored). Here are the CIFs for all 51 candidates over the past 7 years (red is the mean):

I thought there might be a difference by model organism, but within imaginary error bars it looks roughly the same:

In terms of absolute IF of the publications, there is a clear bump in the two years prior to the candidate getting their job (though note all of the peaks in individual traces prior to that):

So far as I can tell, there is no strong signal in terms of publications that you had as a Grad Student. Basically, graduate work or lab don’t matter, except as a conduit to get a postdoc position.

To sum up: you don’t need a CNS paper, though a Nature Neuroscience/Neuron/Nature Methods paper or two is going to help you quite a bit. Publish it in the year or two before you go on the job market.

Oh, and live in New York+ or the Bay Area.

 

Update: the previous city/institution analysis was done on a subset of individuals that had Google Scholar profiles. When I used all of the data, I got this list of institutions/cities:

Updated x2:

I thought it might be interesting to see which journals people commonly co-publish in. It turns out, eh, it is kind and it isn’t kind of. For all authors, here are the journals that they have jointly published in (where links represent the fact that someone has published in both journals):

And here are the journals they have published in as first authors:


Behavioral quantification: mapping the neural substrates of behavior

A new running theme on the blog: cool uses of behavioral quantification.

One of the most exciting directions in behavioral science are the advances in behavioral quantification. Science often advances by being able to perform ever more precise measurements from ever-increasing amounts of data. Thanks to the increasing power of computers and advances in machine learning, we are now able to automatically extract massive amounts of behavioral data at a level of detail that was previously unobtainable.

A great example of this is a recently published paper out of Janelia Farm. Using an absolutely shocking 400,000 flies, the authors systematically activated small subsets of neurons and then observed what behaviors they performed. First, can you imagine a human scoring every moment of four hundred thousand animals as they behaved over fifteen minutes? That is 12.1 billion frames of data to sort through and classify.

Kristan Branson – the corresponding author on the paper – has been developing two pieces of software that allows for efficient and fast estimation of behavior. The first, Ctrax, tracks individual animals as they move around a small arena and assigns a position, an orientation, and various postural features (for instance, since they are fruit flies we can extract the angle of each wing). The second, JAABA, then uses combinations of these features, such as velocity, interfly distance, and so on, in order to identify behaviors. Users annotate videos with examples of when an animal is performing a particular behavior, and then the program will generate examples in other videos that it believes are the same behavior. An iterative back-and-forth between user and machine gradually narrows down what counts as a particular behavior and what doesn’t, eventually allowing fully-automated classification of behavior in new videos.

Then once you have this pipeline you can just stick a bunch of animals into a plate under a camera, activate said neural populations, let them do whatever they feel like doing, and get gobs and gobs of data. This allows you to understand at neural precision which neurons are responsible for any arbitrary behavior you desire. This lets you build maps – maps that help you understand where information is flowing through the brain. And since you know which of these lines are producing which behaviors, you can then go and find even more specific subsets of neurons that let you identify precise neural pathways.

Here are two examples. Flies sometimes walk backwards (moonwalking!). If you look at the image below, you can see (on the bottom) all the different neurons labeled in a fly brain that had an effect on this backward locomotion, and in the upper-right the more specific areas where the neurons are most likely located. In fruit fly brains, the bulbous protrusions where these colors are found are the eyes of the animal, with a couple flecks in the central brain.

This turns out to be incredibly accurate. Some of this moonwalking circuit was recently dissected and a set of neurons from the eye into the brain was linked to causing this behavior. The neurons (in green below) are in exactly the place you’d expect from the map above! They link to a set of neurons known as the ‘moonwalker descending neurons’ which sends signals to the nerve (spinal) cord that cause the animal to walk backwards.

Of course, sometimes it can be more complicated. When a male fly is courting a female fly, he will extend one wing and vibrate it to produce a song. Here are the neurons related to that behavior (there are a lot):

There are two key points from this quantification. First, the sheer amount and quality of data it is possible to gain access to and score these days is allowing us to have immense statistical precision on when and in which contexts behaviors are occurring. Second, the capacity to find new things is increasing because we can be increasingly agnostic to what we are looking for (so it is easier to find surprises in the data!).

References

Mapping the Neural Substrates of Behavior. Robie et al 2017.

See also: Big behavioral data: psychology, ethology and the foundations of neuroscience. Gomez-Marin et al 2014.