An operating theater isn't somewhere you'd normally expect to see someone belt out a saxophone solo, and even if you did, you wouldn't peg the player to be the patient lying on the table with their brain exposed. But that's exactly what musician Dan Fabbio did, as surgeons worked to remove a tumor from his brain without disrupting his professional skills.

The story begins in 2015, when Fabbio, a musician and music teacher, suddenly began to experience hallucinations, dizziness and nausea. He was taken to hospital where doctors performed a CAT scan and found a large tumor in his brain – in an unfortunate coincidence, it happened to be right in a region that's been linked to musical processing and ability.

To help in instances such as this, researchers at the University of Rochester have developed a Translational Brain Mapping program. Before patients go in for surgery, they're put through a series of tests while their brains are being scanned, to highlight which areas are related to which functions, such as motor control and language processing.

"Removing a tumor from the brain can have significant consequences depending upon its location," says Web Pilcher, a neurosurgeon at Rochester and co-author of the new study. "Both the tumor itself and the operation to remove it can damage tissue and disrupt communication between different parts of the brain. It is, therefore, critical to understand as much as you can about each individual patient before you bring them into the operating room so we can perform the procedure without causing damage to parts of the brain that are important to that person's life and function."

But compared to language and motor skills, which are relatively straightforward to test, musical function is a different beast altogether. So in this case the scientists consulted Music Theory professor Elizabeth Marvin to help them develop new musical cognitive tests that Fabbio could perform while lying in an fMRI scanner. The patient was instructed to listen to a series of musical snippets and then hum them back. The end result was a three-dimensional map of Fabbio's brain, complete with the location of the tumor and the area associated with musical function.

"Everybody's brain is organized in more or less the same way," says Brad Mahon, co-developer of the Translational Brain Mapping program and co-author of the study. "But the particular location at a fine grain level of a given function can vary sometimes up to a couple centimeters from one person to another. And so it's really important to carry out this kind of detailed investigation for each individual patient."

The neurosurgeons were then able to use the map of Fabbio's brain to guide them through the surgery. Fabbio was awake throughout the operation, and while the doctors poked and prodded at his brain, he was tasked with the same kinds of tests, humming back melodies he was played. To test how accurate their scan had been, the surgeons sent mild electrical signals into the brain to disrupt small segments temporarily. If Fabbio's humming became out of tune – as judged by professor Marvin, who was present in the operating theater – the doctors would know that section was related to musical processing, and could avoid it.

When the tumor had been removed, it was time for Fabbio's headline act. To make sure he'd retained his former musical talent, the doctors gave Fabbio his saxophone and had him play a preselected piece of music, right there in the operating room.

As you'd expect, there were several challenges involved in this unorthodox gig. For one, it's difficult to play the sax while lying on your side – and did we mention that his brain was still open to the air? Apparently, the pressure of taking deep breaths to blow into the instrument could cause his brain to actually pop out of his skull, so the selected song had to be one that could be played using short and shallow breaths. And by all reports, Fabbio nailed it.

"It made you want to cry," says Marvin. "He played it flawlessly and when he finished the entire operating room erupted in applause. The whole episode struck me as quite staggering that a music theorist could stand in an operating room and somehow be a consultant to brain surgeons. In fact, it turned out to be one of the most amazing days of my life because if felt like all of my training was suddenly changing someone's life and allowing this young man to retain his musical abilities."

After the procedure, Fabbio went on to fully recover and return to teaching within a few months. Not only did the study help fine-tune the Translational Brain Mapping program for other patients, but it has improved our understanding of which sections of the brain are responsible for processing music.

The study was published in the journal Current Biology, and Dan Fabbio's mid-surgery performance can be seen in the video below.