In season four of the hit television show “Grey’s Anatomy,” Derek Shepherd — aka “McDreamy” — , “I perform awake brain surgery all the time.”

Since that episode aired in 2007, this type of “radical” brain surgery has become a common tool used by neurosurgeons in order preserve a patient’s brain function.

During awake brain surgery, a surgeon asks patients to perform a series of speaking, reading, and movement tests while stimulating the exposed brain. This enables surgeons to map the safest route to a tumor or an area causing epileptic seizures.

Some of the tests are even tailored to fit the patient’s work, hobbies, and life.

“Let’s say somebody’s a musician. You have to get to know who they are. Do they like to play the piano? How important is it to them?” Dr. Bernard Bendok, a neurosurgeon at the Mayo Clinic in Arizona, told Healthline. “And then you have them play the piano during that delicate part of the surgery to be sure you don’t affect that function.”

As it sounds, when people undergo awake brain surgery — also known as an awake craniotomy — they are awake, at least for part of it.

Even though the patient is conscious during surgery, they don’t feel any pain. The brain doesn’t have any pain receptors and a local anesthetic is used to numb the scalp.

The patient is also given a sedative before surgery. While the patient is asleep, the surgeon makes an incision and folds back a flap of scalp and muscle. The surgeon then removes a piece of skull, which provides access to the brain.

Once the brain is exposed, the patient is woken up — even though some would probably prefer to remain unconscious through the entire surgery.

But at this point, the patient has a big part to play in helping the surgical team do the best job possible.

“Once you tell the patient that what you’re trying to do is preserve that function that really matters to them, then all of a sudden that fear and anxiety turns into motivation,” said Bendok. “And they become an important part of their own healthcare team.”

Read more: Get the facts on brain surgery »

Mapping the patient’s brain

All brains share common features.

The speech, vision, and movement control centers can be found in the same general areas.

But no two brains are exactly alike. The pathways in a violinist’s brain are different from those of a surfer or a pianist.

With brain mapping, a surgeon can identify the areas of the brain that are most important to that patient — the ones that house the memories and control the functions that make that person unique.

Mapping can be aided by the use of a functional MRI (fMRI). A typical MRI provides a snapshot of the structure of the brain — and any tumors that are present. But an fMRI shows which areas of the brain are active while a patient does certain things like speaking or playing the piano.

The best clues, though, come from stimulating the brain during surgery and seeing how a patient’s functions are affected.

“Being able to map this during the operation is like the difference of having an old map of the city and a live satellite feed of a GPS,” said Bendok. “Then you overlay weather and maybe a live sporting event. And all of a sudden it becomes a three-dimensional live map.”

During surgery the surgeon uses a probe to temporarily stun parts of the brain while asking the patient to perform a series of tasks. This may involve asking the patient to move part of their body, identify pictures on a card, or in the case of a pianist, play the piano.

“When we’re taking out a tumor that’s near the area of the brain that controls right-hand function, we have [the patient] play the keyboard to see if that function is being affected,” said Bendok, “so we can make smart decisions about which ‘road’ to take to get to the brain tumor.”

If a patient stumbles while performing the task — such as stuttering or forgetting how to spell a word — then the surgeon knows that this stunned area is important. And one to avoid.

Read more: Brain scan can differentiate between PTSD and injury »

Finding what makes us human

New technologies — including brain mapping and new types of — are advancing the field of awake brain surgery.

Whether awake brain surgery is an option for patients depends on the location of the lesion or tumor.

“The closer that lesion or that tumor is in an area of the brain that is important to function, the more this operation makes sense,” said Bendok.

Patients also need to be able to stay calm during the surgery so the surgical team can map the brain.

Overall, awake brain surgery has given patients more options … and hope.

Now surgeons can access tumors that before would have appeared to be completely walled off by vital brain matter. They can even find alternate routes to a tumor in case one path doesn’t pan out.

A big shift for the field, though, is how it defines what makes up our humanity.

“Back in the 60s and 70s,” said Bendok, “if a patient could move their arms or legs and talk, that was considered a win.”

Today surgeons focus more on activities that are an integral part of a person’s life — playing the piano, solving mathematical equations, or answering questions about a recent family trip.

And along with this, awake brain surgery has shifted how surgeons interact with their patients.

Surgeons have a reputation for being the ones who come in after a patient is asleep, make a repair, or cut something out, and then leave.

But with awake brain surgery, surgeons spend more time getting to know patients, both before and during the surgery.

“It really humanizes healthcare in a way that, I think, is unprecedented,” said Bendok. “And that to me has been the biggest advance.”

Read more: Women’s brains more affected by drug abuse »