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.

Have we reached the end of science writing?

In 1992, Francis Fukuyama published a book titled, “The End of History and the Last Man.” Although everyone laughed at the title, the book wasn’t suggesting that history had ended. Rather, it was wondering whether we had reached the peak of political philosophy. Was there anything actually better than liberal democracy?

Reading science writing often leaves me wondering something similar. Have we reached the peak of science writing? The internet has led to an explosion in fantastic science writing, with people such as Ed Yong, Virginia Hughes, and David Dobbs repeatedly putting out sophisticated pieces on scientific discoveries. In conjunction with this trend has been a rise in magazines specializing in this writing, such as Aeon and Nautilus. But recently I’ve found myself being incredibly bored every time I read these articles.

Oh, I don’t mean I’m actually bored; the writing is still gripping and full of interesting facts and anecdotes. Yet when I start each article I can practically close my eyes, point at a paragraph, and tell you what’s going to be in it. It’s somewhat formulaic. That’s not necessarily bad: if it ain’t broke, don’t fix it. But I’m the kind of guy that loves reading Faulkner and Nabakov and such: writing that is presented in a different structure than you are used to. Obviously, I don’t read that all the time – frankly, it’s mostly wizards and dragons and spaceships that cover the books in my hand – but it’s nice to have a change or a surprise.

Experimentation in form is not just for people like me that are easily bored. It is a way to push against boundaries and try to find new ways to say things that you couldn’t before. Let me give a couple of examples.

First, we are all familiar with the ubiquitous Malcolm Gladwell or New Yorker style of reporting (I apologize, I’m afraid I don’t know who actually started writing this way). If you read reporting a hundred years ago, it was a straightforward explanation of events: this then this then this. The Gladwell structure is different; look at How David Beat Goliath. It begins with a few paragraphs about a children’s soccer team, then continues with a few paragraphs of David and Goliath, then turns to a story about a software company on wall street. Slowly, it weaves the stories together. The structure utilizes several distinct outlooks on the same topic to shed more light on it than you would otherwise be able to get. It’s actually pretty complex for the reader, who is asked to follow several different stories as they shift in and out of focus. Think of it like the difference between I Love Lucy and Lost.

Another example is the New Journalism of the 60s and 70s. Instead of writing in a typical reporting style, people like Truman Capote and Tom Wolfe wrote in a manner that seemed like fiction (quote shamefully stolen from this blog post):

Ten o’clock Sunday morning in the hills of North Carolina. Cars, miles of cars, in every direction, millions of cars, pastel cars, aqua green, aqua blue, aqua beige, aqua buff, aqua dawn, aqua dusk, aqua aqua, aqua Malacca, Malacca lacquer, Cloud lavender, Assassin pink, Rake-a-cheek raspberry. Nude Strand coral, Honest Thrill orange, and Baby Fawn Lust cream-colored cars are all going to the stock-car races, and that old mothering North Carolina sun keeps exploding off the windshields. Mother dog!

Working mash wouldn’t wait for a man. It started coming to a head when it got ready to and a man had to be there to take it off, out there in the woods, in the brush, in the brambles, in the muck, in the snow. Wouldn’t it have been something if you could have just set it all up inside a good old shed with a corrugated metal roof and order those parts like you want them and not have to smuggle all that copper and all that sugar and all that everything out here in the woods and be a coppersmith and a plumber and a cooper and a carpenter and a pack horse and every other goddamned thing God ever saw in this world, all at once.

It is possible to experiment with form in order to understand an idea in a different way. But what about in science writing? I was called out on Twitter for the title of one of my previous posts; “Study: Men smell and that will stress you out.” It was something that I had meant as a tongue-in-cheek in-joke, but from the perspective of someone who doesn’t know my dry style of humor it really, really didn’t come across, sounding instead like linkbait. As they put it: “It’s a science blog. It has references. We use objective descriptions for accuracy, even if that requires repetition.” Which, honestly, is a great point. What is required of someone who writes about science? Does their intended audience matter? Should we be playing around if it might cause confusion?

Virginia Hughes passed along a great article on the desire to write about science beautifully. The article warned against playing too much:

Nonfiction arranges facts into a story, it finds the story in the facts. Readers are in it less for evocation of someone else’s world than for understanding the facts and nature of our own. Without facts, nonfiction is unreliable and readers’ understanding of the world is correspondingly untrustworthy. Untrustworthy authors/narrators in fiction are charming; in nonfiction, they’re worse than useless, they’re a betrayal, they’re at best a waste of time.

…So my note of caution is this: as science writers, we should go ahead and treat our scientists as characters and their discoveries as plots; and find pretty analogies; and control the rhythms of our sentences; and look for the central conflicts and the narrative arcs; and write with our own peculiar voices. But our readers have a different covenant with is. They trust us, they think we’ll tell them the truth; they think they can put that truth into their worlds and rely on it. And if we betray them, they’ll be pissed. So if you want beauty in science writing? Find the beauty in the facts, in reality, and write about that.

But does that mean there is no room for growth? Are there no other forms that people covering science should write in? While there has not been a ton of experimentation in form – that I can discover – there certainly is some. Adam Jasper and Nadia Wagner wanted to write an article on scent. Instead of a typical historical introduction, they introduced facts through disconnected paragraphs with tangential connections found at long distance. Bret Victor presented a scientific paper as a beautiful sequence of illustrations – and no, I don’t mean like an infographic. Aatish Bhatia (among others) has frequently mixed reporting with his own additional analysis of the data.

Again, I don’t want to sound like I’m attacking the way people write now; there’s a reason that I will read literally anything that Ed Yong posts. There are many ways to write, and we don’t want everyone going off and experimenting for the sake of experimenting – that way is studded with the problems that plague contemporary art. Yet we should examine what other ways there are to write about science. Just like any scientific experiment, most of the time it won’t work. But sometimes it will.

Please feel free to comment with any examples of science reporting that you think has played with the structure of the writing.

Pyramidal neurons

pyramidal neuronsvia neuroimages, by  Alexandre William Moreau/ Institute of Neurology/ Nikon Small World Competition


Science is an aesthetic practice


One of my friends recently hired – or had foisted upon her – an undergraduate to help her do research. “How do you stay motivated?” he asked her. “Uhh” she responded.

We’ve all been there. Doing science really sucks, a lot of the time. Add to that the common list of other deficits with this career: little money, tons of work, no real respect, etc. So why do we do it?

While I was on the microscope I was thinking these very thoughts, and decided to write an article about it on Medium. One of the points of writing this blog is to get better at writing, so I used the chance on Medium to do something a bit different.

The point of the article is that, while there are many reasons one could do science – and I know the reasons are probably pretty heterogeneous among my peers – the reason that I in particular do science is for aesthetic reasons. Essentially, the impulse to do science is the same impulse that drives someone to an appreciation of art. It is a cultivation of an appreciation of the beauty of the world. I’m not sure what motivates an Artist to create Art, though it seems that my few vain attempts have been about creating something beautiful for other people. But to me science is more like stumbling through an art gallery: it isn’t about creating something for other people, but rather finding something beautiful for myself. Once found, I can fit it into my mental blueprints of the world and reflect on it as I would a fine work of art. Perhaps that’s a bit selfish, but it’s what keeps me going.

Go read it, and please feel free to send any constructive criticism on it my way!