Ten days of code

25 October 2011 1 comment

Open code in academic computational science should be the standard. After all, the scientific ideal is to share information toward progress. This is at least an idealistic view of why we publish so competitively, with standards that demand we share our findings with our peers and with the public. And while the computational methods of my most recent joint experimental/computational paper far exceeded the length of our experimental methods explanation, the rather large step of implementation of our model into a numerical scheme is non-trivial (at least I’d like to think so).

But at the moment, I’ve decided it’s not time for me yet to fallback on the simple solution of just “releasing the source code”, because there is a right and wrong way of doing this. The right way includes clean up, documentation and licensing, and investigating these are both time consuming and difficult. In the world of commercial software, there is also a great deal of platform-dependent testing that is required, and I do not have the resources or time to do all of that. Will my MATLAB code run on another MATLAB? It might, but it might not unless several things are written in a platform-aware way, such as the writing of files. I’ve noticed variations of MATLAB behavior on Mac OS X versus Linux, largely with figure handles and GUIs. Will these elements of my program translate appropriately? How can I ensure this?

While these are certainly not MATLAB-specific software issues, there is a greater issue at play regarding who can run this code. MATLAB is not free (gratis) software; in fact it is quite expensive. Its free (gratis and libre) and open source alternative, Octave, could not handle my early attempts at rewriting this project due to memory and stability issues. Additionally, its performance is behind MATLAB.

But as I prefer open-access journals for their ability to be reached without a privileged gateway by any human being on the planet with an Internet connection, I would also like my code to be able to be run on virtually any machine in the world, for free. Granted, the number of people who would be interested in my codes may be limited to at least one of my officemates, but there’s something about the idea that a poor but gifted child halfway across the world could possibly use my code to understand my bit of science better than I.

I tried to move from MATLAB to Octave once, and I failed. For so many reasons — openness, consistency, stability, performance — I’ve wanted to move away from proprietary software into the realm of free, open source software with a lower level language. I’m finally making my first real steps toward doing that.

In the past two weeks, I’ve learned how to implement my network in C++ using many of its powerful constructs short of classes. I’ve learned how to implement a gamma frequency generating Hodgkin-Huxley network, for which I wrote a general numerical solver, learned how to optimize memory, used a pretty cool makefile, and passed around pointers like cigars while celebrating a newborn. I’ve stumbled upon SegFaults with gigantic 2D arrays, I’ve cursed at the Mersenne twister random number generator, and I’ve forgotten more than one ampersand or asterisk. Two weeks ago, I didn’t know how to use arrays of structures, header files, or a linker. Now, implementing features that get me closer to my mature MATLAB codebase is getting faster each day.

But unfortunately, I don’t have a lot of leisure time to be spending on getting everything just right. I’m trying to graduate very soon, and I need to be job hunting, thesis writing, and most importantly, finishing my research. I believe this is an important and necessary detour for that, since I became memory-bound by my MATLAB code at 10 GB of RAM (while my machines have from 2 GB to 10 GB each). The best solution for my memory problems is not more silicon; it’s better code. My ideal simulation environment is going to be a combination of tools from C++, python, GNU tools such as make, and vim. Don’t worry; I already know my trusty vim.

I have given myself 10 days to finish the coding of this project. On day 1, I wasted most of the morning trying to figure out whether or not I could use regex to read my parameter file. I then learned about strings and figured out how to use all the class methods to do what I needed to do. I wrote and tested all of the functions necessary to read parameters and place them in the appropriate variables. I also figured out how to use dynamic arrays, which will be useful when I need to parameterize the numbers of elements in my arrays. It turns out, my obsession with using pointers paid off, as nearly all of my dynamic arrays were a simple matter of changing the syntax of the creation slightly. I think there might be the added benefit of moving several large arrays from the stack to the heap, though I don’t fully understand what that means yet.

It’s 1:37 am on Day 2. I have to figure out my priorities, but I need to finish my conductance implementation for n x m cells, get my output right (and flexible), find spike times, learn python and matplotlib, write my analysis code, scale up my network, test everything, and get back to where I was with my research.

I have ten nine days.

Neuroethics

2 March 2011 Leave a comment

I often like to say that, in my line of work in computational neuroscience, they don’t let me deal directly with other humans. This is jokingly said to reflect the fact that I have no interpersonal skills or rather to suggest that the results from my mathematical models are narrow in scope and likely not to have direct implications on human health, for a variety of reasons. One reason for this is because the data I use to constrain my models comes primarily from experiments from animals and are often used in a qualitative fashion. This is because I am often more interested in general dynamical principles of networks that may exist in the brain, since the real problem of full understanding is quite a bit less tractable (but not necessarily impossible). Another reason is that all computational models — from neuroscience to genetics to economics — have numerous simplifying assumptions that must be understood carefully in order to interpret the model results appropriately. There is a great deal of responsibility that accompanies the communication of model results, since these explicit and implicit assumptions must be carefully specified.

Yet, despite these reasons for not marketing my work in a way that suggests it has direct implications for human health, I recognize that the study of brains and nervous systems has wide ranging implications on so many issues that will impact human health fundamentally. Perhaps even moreso than genetics, brain science is widely believed to be addressing many secrets of who we are as humans and as individuals. While both are complex molecular machines, the implications of altering brains seems to have an immediacy that may be unique. I believe that neuroscientists have a professional responsibility to understand how the greater public, policy makers, health care providers, businesses, and the law will use and interpret our findings and to help ensure that these societal decisions are supported by science. Since we admittedly know so little (as a field, we are full of factoids), we currently need to be clear when there is not enough evidence to support these decisions.

Among the issues, some of which are unique to neuroscience, include cognitive enhancement, incidental findings of maladies that might come up in a subject who is involved as a research participant, implications on neuroscience-based evidence in court, predispositions for a profile of a person’s brain toward certain decisions or actions, rights and access of a patient’s brain-related health care records, and a host of other privacy issues that may speak to core personality issues that may be exploited one day for marketing. This is not at all an exhaustive list.

There is an emerging field of neuroethics that helps to address many of these issues, with organizations that are attempting to establish guidelines that help researchers and the public make good decisions. In fact, there exists a Presidential Commission For The Study Of Bioethical Issues that in part focuses specifically on neuroscience-specific issues. They just finished up a meeting that facilitated discussion of several of these issues. My hope is that all of us as professionals take this responsibility seriously and that we engage our friends and the public in discussing these important issues openly in order to educate each other.

Love in the time of swine flu

30 January 2011 2 comments

I have an unabashed love for the city of Boston. I’ve explored its neighborhoods intimately on foot, weaving through the city on long, ambling runs. I wander the MFA and MOS regularly and use the Boston Public Library’s main branch at Copley Square as a source of much of my non-work related reading. Today I was spending some time with a friend EF while taking photos of our town; I wanted a picture of the snow-caked frozen river, which is the most pristine expanse of snow I’ve really ever seen. As we made our way down by the river to the Arthur Fiedler footbridge and through the Commons, I was reminded that EF hadn’t seen the library at Copley, which is one of my favorite things to show to visitors to Boston, since its grandeur is contrasted only by its decidedly democratic accessibility to education. Never before had anyone been underwhelmed by the magnificence of the architecture and art of the original McKim building.

To heighten the effect, one enters from Boylston Street through the relatively modern revolving doors set into the generic façade of the 1970′s library extension. Walking quickly through reveals several floors of stacks, which is what one pictures in any completely impassive book lender. However, as you walk up a set of short stairs and through the perpetually opened double doors, you walk through a vestibule into a section that immediately exudes a heightened sense of purpose and presentation. Through another set of doors lies the atrium, and on the other side of the atrium is the beautiful old McKim building that is the foundation of our magnificent public resource. In the summer, the atrium is teeming with readers and researchers who opted for sunlight and fresh air to the artificial fluorescents and musty stacks that can be found indoors. But there are far more table vacancies in the cold parts of winter, especially on grayer days like today.

As we made our way into the atrium from the industrial side of the library headed toward the enlightened side, several people as if on cue cleared the area and disappeared into one building or the other. There was one couple remaining, however, of whom EF and I immediately took notice. It was slightly conspicuous, since the guy was — did we see that right — down on one knee. Since I was still playing photojournalist from the rest of our day’s excursions, a brief conference with EF prodded me into action, and I employed the full length of the zoom in order to try and capture this rare moment onto silicon. I admit that I don’t often use people as subjects for photos out of respect for their privacy, but clearly we were hoping to share these photos with this particular couple. As I fumbled around with the camera attempting to coax clear photos out of it, I advanced my position not enough to be intrusive but enough to improve my angle. As they embraced in a clear sign of the engagement’s consummation, we recorded the events from afar.

We wanted them to enjoy their moment alone, so we waited off to the side for a moment to avoid interruption. As soon as there was a free moment, we sheepishly interrupted to explain ourselves, take a proper photo of the lovely couple, and offer to email the results, which they happily accepted.

As we continued our tour, we noted that no building could really usurp the moment we’d just witnessed, so we thought back on the happy couple and realized that through our vantage point into the atrium from the second floor, we could get a nice photo, so we did. I wish them a prosperous and loving life together, and I’m thankful that we were able to be a small part of their happy occasion.

Categories: Stories

Shackleton’s Endurance

28 December 2010 Leave a comment

I’m reading the classic book Endurance by Alfred Lansing, on loan from a friend CT. I had to laugh aloud when I read this poignant line that reminded me of the deceptively simple allure of ultrarunning:

“And in the space of a few short hours, life had been reduced from a highly complex existence, with a thousand petty problems, to one of the barest simplicity in which only one real task remained–the achievement of the goal.”

Categories: Running Tags: ,

LaTeX modernization challenge

27 December 2010 Leave a comment

For those in technical fields, the LaTeX typesetting system is only slightly more invaluable than infuriating, not to mention shady to search for appropriately on the internet. As they say, LaTeX makes very difficult tasks easy and very easy tasks difficult. Though there are several excellent GUIs that address many of these shortcomings, there’s a problem in compiling efficiency that I think can be addressed. Every time you make a change and run the LaTeX command on a file, it recompiles the entire document, soup to pie. This is obviously useful when you have references that need updating throughout the entire file, but I bet there’s a way to implement a system in which LaTeX compiles only what changes, and beyond.

Let’s take a simple example. Let’s say I have a beamer presentation in LaTeX that has 10 slides. If I change information on slide 3 that has NO bearing on slides 1-2, I should be able to compile the document so that it only compiles slides 3-10, since potentially pagination on slide 3 changes the slides that follow. (In fact, beamer slides should be such that most changes made to slide 3 will not affect any other slide, so in that case LaTeX should retypeset page 3 and then maintain the other pages.)

Pitfalls of this are pretty clear: there are several scenarios, including references and labels, in which the entire document may need to be recompiled, and it may seem like considering these exceptions is cumbersome/inelegant. But I think that modern computing is easily capable of handling these challenges in a fairly efficient manner. It doesn’t even have to be all-inclusive for a first try.

It’s also not clear to me whether or not such a thing exists. I haven’t spent enough time on LaTeX community boards or mailing lists to really know. The reason for this is partly time, of course, but mostly because I don’t have the technical acumen to actually help solve these problems. But here I’m throwing out the challenge to do so, if it hasn’t been done already. It’s clearly not in the mainstream LaTeX distributions, but it’s a sorely needed feature that would save enormous amounts of time in preparing these manuscripts in LaTeX.

Categories: Geekery (Tech) Tags:

Faces

30 October 2010 Leave a comment

Just wanted to share this Kahlil Gibran poem. There’s a memorial outside of the Boston Public Library for Gibran, a beloved writer and one of my favorites. I don’t always understand his writing, but his poem “Faces” resonates with me.

I have seen a face with a thousand countenances, and a face that was but a single countenance as if it held in a mould.

I have seen a face whose sheen I could look through to the ugliness beneath, and a face whose sheen I had to lift to see how beautiful it was.

I have seen an old face much lined with nothing, and a smooth face in which all things were given.

I know faces, because I look through the fabric my own eye weaves, and behold the reality beneath.

Categories: The World Tags:

BP oil spill in the Gulf

2 May 2010 1 comment

The BP oil well that sprung a leak has led to one of the most concentrated environmental disasters, especially for the Gulf Coast region of the Southeastern United States and surrounding coastal areas. The majorly oversimplified problem is that there is a leak in the well far below the water surface, and it’s hemorrhaging oil into the ocean. No one seems sure of how to fix it.

While I am ignorant with respect to almost anything beyond what I’ve stated above, the overwhelming complexity of the problem reminded me of another problem that I once read about as a child. In that case, there was a sunken ship or something that was submerged in the ocean, and someone had recalled an old comic where they put a lot of ping pong balls into a submerged ship in order to raise it. The idea is very simple: increasing the buoyancy in a closed system should exert a force on the object and raise it to the surface of the water.

In the case with the oil well, while the specifics of such a notion would need to be worked out, here’s one of my simplistic ideas. Because we cannot get to the source of the leak easily, perhaps we can try and contain the leak in another way, by placing a sleeve over the entire well. If sealed properly at the ocean floor, this could conceivably fill the sleeve with oil and give us a chance to contain it from the top instead of dumping into the ocean.

Another simplistic idea is to increase the size of the aperture at the surface, again where we can perhaps control the oil a bit better. Because there is pressure being exerted into the pipe, at the moment it is flowing out of the break. But if another aperture is created, perhaps the pressure is enough to push oil beyond the break and toward the surface. Consider a straw that has a hole in its side. Now actively push water through. If the pressure is relatively low, water will flow out of the side hole and little if none will reach the top, depending on several factors such as aperture size relative to the diameter of the straw and pressure. If the pressure is higher, however, this will send more of the flow past the side hole, since the side hole is oriented orthogonally to the flow of the fluid. Essentially, create another break at the top in order to lessen the impact of the lower break.

Obviously these two notions are very simplistic, but they could conceivably lead to a solution to containing the growing problem in the Gulf.

Follow

Get every new post delivered to your Inbox.