When Software Engineering Meets Neuroscience: Advanced Programming Techniques Unlock the Neural Patterns Behind Fruit-Fly Love Songs

Monday, Mar 2, 2020
by Jenn Hall

For the average person, any rumination on the fruit fly ends with a distracted swat. Yet the hidden world of this diminutive species has potential to reveal surprising insights into the neural-generated behavior of species across the animal kingdom, including our own. 

For example, it may surprise the uninitiated to learn that fruit fly mating rituals include elements commonly associated with classic human romance, intricately patterned love songs among them. Smitten by a potential partner, a male plays a song using his fast-fluttering wings. As his prospective female partner responds, moving toward or away, he measures her proximity and speed and adjusts his tune in real time. If all goes well, he will convince her to become his mate. 

For Princeton Neuroscience Institute (PNI) Professor of Neuroscience Mala Murthy, the neural patterns that spark such songs can unlock insight into how the brain processes sensory information to inform behavior. With the addition of Research Software Engineer David Turner to PNI in 2017, her ability to explore this question has grown by leaps and bounds. 

Through a position jointly funded by PNI and the Office of Information Technology, Turner’s role points to a wider investment the University is making to bring expert software engineers to disciplines from statistics and machine learning to genomics. Their task: to bring advanced programming expertise to departments and create new research possibilities in the process. 

“The fruit fly, Drosophila melanogaster, is a great model system, because it has a number of genetic tools with which to manipulate the nervous system,” Professor Murthy explains of her work. “You can turn on neurons and turn off neurons. You can record activity from neurons. This allows us to get at what we call neural mechanism: how individual neurons that make up the brain contribute to behavior.” 

Romance aside, that query is deeply quantitative, necessitating a highly sophisticated research model. Using advanced microscopy, Murthy examines the fly’s brain in response to sensory stimuli, tracking 100s of firing neurons at a time. With Turner on board, Murthy has rapidly refined that methodology — including the recent implementation of a virtual reality experience that approximates the natural experience of males and females during courtship. 

“The fly can’t actually walk, because it’s fixed on a microscope,” Turner explains of the challenge on which he focused his attention. Yet motion is central to the experience that drives neural responses. The solution approximates the fly’s motion in a free environment by positioning it on an omnidirectional trackball during research sessions. Stimuli that flies would normally experience during courtship are presented relative to speed on the ball. These experiments will get at cognitive processes like learning and memory, decision-making, and sensory-guided behavior. 

“You can’t perform the neural recordings in a freely moving fly,” Murthy says. “This is the next best thing.” 

“This is precisely the kind of work that the Research Software Engineering program is designed to deliver,” explains Ian Cosden, manager of HPC software engineering and performance tuning for OIT’s Research Computing group. In the United Kingdom, he says, the pairing of researchers and software engineers has steadily gained steam over the last five years. Princeton is at the leading edge of its adoption in American universities. 

For computer scientists like Turner, who has a Ph.D. in mechanical engineering and a master’s and bachelor’s in computer science, it is an emerging career path well suited to those who wish to apply their programming skills in an applied environment. Turner chose to pursue his Ph.D. in mechanical engineering rather than computer science because he was driven to apply his software skills to applied research questions, he says. “As a research software engineer, I can adapt my skills to a different scientific domain.” 

At PNI, he contributes directly to Murthy’s work, while exposing the next generation of researchers to new levels of professionalism in software development — though he is quick to note the contributions of postdocs like David S. Deutsch, who built much of the hardware for the project. That’s a significant paradigm shift in an era when programming is fast becoming a core competency in research. It also solves a problem that has long challenged labs like Murthy’s. In the past, programming was tasked to graduate students who fit in development amid a myriad of other tasks and responsibilities. Then they took their knowledge with them when they left. That’s an unsustainable model in an era where funding agencies emphasize the creation of transferable methodologies of broad value to the research community. 

“Code is foundational to the work of the lab,” Murthy says. 

The Research Software Engineering program positions Princeton to support its faculty as that becomes a reality across disciplines. “When written by expert coders embedded in the research process, ‘good software can last forever,’” Cosden says. 

Murthy describes it as a game-changer. Not only does an engineer like Turner advance the work of faculty who are expected to share elegant research models with their peers; students receive a real-time education in leadingedge computational techniques that redefine the frontiers of disciplinary inquiry, whether it’s the mating rituals of fruit flies or the computational mechanisms underlying brain function and its expression in psychological processes and behavior. 

 two-photon microscope

Setup for imaging brain activity in a behaving fly, walking on an air suspended ball. Auditory or visual stimuli are presented to the fly while its behavior is monitored, using a camera to capture fly motion, and microphones for recording fly song. A two-photon microscope records brain activity. Software designed in collaboration with David Turner will control the presentation of stimuli relative to fly behavior, creating a virtual reality experience. This setup is used to understand how the brain of the fly enables social behaviors. Photo by Jonathan Halverson, PICSciE.

“How do flies learn to change their songs over time? How do the females integrate acoustic information to change their behaviors? How do flies make decisions about which song to sing at the right time? As a neuroscientist, these are the questions that really motivate me, and I want to understand them at the level of resolution of individual neurons,” Murthy explains. Her ability to explore these questions has been accelerated by Turner’s contributions, she says. 

The admiration is mutual. “Before I started working here at Princeton, I had no background in neuroscience,” Turner says. “Now I get to live vicariously through all of these really smart researchers and help them do this work. I certainly didn’t think about developing VR – and not fly VR. That was very unexpected, but very fortunate. It has been a blast.”