(CNN) Fingers graze a keyboard, poised to play. A trumpet rises to the lips. Drumsticks perch in the air, ready to fall. The improv begins, and this combo of jazz musicians instantly creates a piece of music that has never been heard before.

As each instrument hijacks the melody, the song is reinvented in ways even the musician doesn't understand.

Revered jazz trumpeter Miles Davis put it this way: "I'll play it first and tell you what it is later."

"When you hear great jazz, like John Coltrane or Miles Davis, it has this jaw-dropping quality to it, and what's been described as 'a sound of surprise' takes place," Limb said. "And you think to yourself, 'Wow, that's not just phenomenal music, that's phenomenal neurobiology.' "

Could jazz improvisation be a key to understanding how the brain invents? Could that creativity be studied? An accomplished jazz musician himself, Limb was the perfect scientist to tackle the project.

"I had always intuitively understood that the creative process in jazz improvisation is very different than the process of memorization," he explained. "That is immediately apparent when you play."

JUST WATCHED Why a song gets stuck in your head Replay More Videos ... MUST WATCH Why a song gets stuck in your head 01:32

He decided to ask jazz musicians to play a memorized song while their brains were scanned inside a functional MRI and then to have them riff a bit during the scan to compare the differences.

"You say 'go,' and jazz players can improv at drop of a hat, so from an experimental perspective, it's really easy to study, as compared, to say, a novelist," said Limb, chief of the Division of Otology, Neurotology and Skull Base Surgery at the University of California, San Francisco. "Just imagine I want you to write a novel on the spot, and every 60 seconds, I'm going to have you switch modes between something original and something you've memorized. it's jarring and not how novelists normally work."

Jazz musicians do work that way, but there was one major issue: the magnetic field of the MRI. The pull is so powerful that any metal in the room would be rocketed to the machine's core, destroying the item in the process.

To solve the problem. Limb commissioned a non-magnetic piano with plastic keys, which could be played on the musician's lap while in the scanner. The work began, and the results, published in 2008 , were fascinating.

While the musicians improvised, the parts of the brain that allow humans to express ourselves -- the medial prefrontal cortex or "default network" -- became more active.

At the same time, the part of the brain responsible for self-inhibition and control, the dorsolateral prefrontal cortex, became dormant.

The medial prefrontal cortex, parts of the brain that allow humans to express ourselves, is shown in yellow. The part responsible for self-inhibition and control, the dorsolateral prefrontal cortex, is blue.

By inhibiting the part of the brain that allows self-criticism, the musicians were able to stay in their creative flow, known as "in the zone."

"I view this as a neurological description of letting go," Limb said. "If you're too self-conscious, it's very hard to be free creatively."

Not just jazz

It's not just all that jazz. Limb also scanned the brains of rap artists as they freestyled.

"If you look at the history of jazz and rap, you can make an argument that rap is today's jazz," he said. "Jazz was a radical American-born art form, and rap has a lot of parallels to jazz, because so much of it is created on the spot and is sort of a music of the street."

Before long, Limb was also peering inside the noggins of improvisational comedians and caricature artists.

Scans of musicians' brain as they play scales vs improvisational music.

"In 30 seconds, that artist can sketch any face he is seeing as a caricature," he said, adding that improv comedians function similarly. "I realized that was analogous to what is happening in a freestyle jazz solo. The brain is taking a known structure and deviating from it in intentional ways that are not pre-planned.

"Jazz is a great model to begin with, but I don't want to end there," Limb continued. "If you look at artists at creative experts of our time, and you believe you can learn how human creativity operates by looking at art, you realize that each type of art represents a unique piece of human thinking."

In the past decade, the field of improvisational neuroscience has exploded. Researchers have peered inside the brains of classical musicians, non-musicians, writers and "divergent" thinkers, those who can quickly come up with novel ways to use everyday objects, such as a brick.

One of the first myths to be debunked: "Right-brain people" are not more creative. In fact, networks in both the left and right sides of the brain are intimately involved in creativity and change depending on the type of endeavor and the stage of the creative process.

"We're looking at networks of creative brain function, the interplay of these networks and the role of aptitude," said Rex Jung , a professor of neurosurgery at the University of New Mexico who studies aptitude, intelligence and creativity. "Everyone is creative; it's just a matter of degree. We have this prototypical idea of artistic creativity, but we are creative in our relationships, our work, our cooking or even arranging our homes in a different way."

Follow CNN Health on Facebook and Twitter See the latest news and share your comments with CNN Health on Facebook and Twitter.

For the arts, at least, successful creative improvisation also appears to be related to expertise, a mastery generated by a lot of hard work. Research finds that musicians who have devoted hundreds, perhaps thousands, of hours to practice seem to more easily get into "the flow."

"What the trained experts who are so creative are always revealing is that it was practice -- a lot of effort and practice -- that gave them the creative edge," Limb said, "rather than the genius, talent or aptitude they were born with.

"So one of the take-home points is if you want to build a more creative society, there is no substitute for just trying and doing it," he continued. "We see the creative brain evolve over time. It's not just fixed at birth. By practicing these behaviors we add to our creative abilities."

Jung agrees: "The more raw material you have, the more time you devote to developing a skill set, the easier it is to improvise. It takes expertise to have enough material to draw on to be creative. So find an area that interests you, develop an expertise in that area, and then start creating and develop something extraordinary."