By 35, Dr. Alice W. Flaherty had led a life of traditional overaccomplishment: undergraduate and medical degrees from Harvard, a Ph.D. in neuroscience from M.I.T., research in movement disorders, articles in leading neurological journals.

Then, in 1998, she delivered stillborn twin boys. In the grief that followed, she grew manic: poetic, metaphorical and long-winded. She wrote everywhere, up and down her arm, over and under any serviceable piece of paper. She also wrote more traditionally, producing neurology handbooks, autobiographical meditations and, in 2004, a best-selling book, The Midnight Disease: The Drive to Write, Writer's Block and the Creative Brain (Houghton Mifflin).

Her grief eventually subsided. Her newly uncovered bipolar disorder did not - to the benefit of her patients.

Dr. Flaherty, now 45, is director of the movement disorders fellowship at Massachusetts General Hospital and an assistant professor of neurology at Harvard Medical School. But those technical descriptors do not begin to capture the way she uses the racing mind of her manic phases to drive her ideas into forceful, highly personal treatments.

"Doctors tend to see patients with an overtone of category," said the writer Rose Styron, whose husband, the late novelist William Styron, was a patient of Dr. Flaherty's. "Alice never did. She understood Bill's depression and his movement problems. But she really understood his needs, appetites, moods, guilts, sadnesses and potential pleasures."

These days, Dr. Flaherty is preoccupied with the neuroanatomy of empathy - especially the mirror neuron system in the insula, cingulate and inferior frontal parts of the brain, which become active when one person witnesses another experiencing emotion. The routes to her interest were interconnected and highly personal.

"What made me empathic was my depressions," she said recently. "People's emotions were pounding me in the face. The mania is like wasps under the skin, like my head's going to explode with ideas. But the depressions help the doctor aspect of me."

When Dr. Flaherty lost her first set of twins (she and her husband, a book editor, are now rearing healthy twin daughters), she experienced a natural yearning for empathy from her own doctor. But as a scientist she wondered, was she yearning for his empathy or an appearance of empathic actions?

Years later, she consulted on a pilot for a television drama based on her life: doctor develops mania after personal catastrophe. Although the show never got off the ground, the experience became a roomful of mirrors and mirror neurons, for who better to teach empathy to a doctor than an actor?

"The actress playing me was trying to pick up my mannerisms. At the same time," she said, recalling professional lessons learned, "I was trying to pick up hers, because she was much more convincing than I am - she had a little smile that was triumphant, but also just so happy for the patient. I was imitating her imitating me."

The office in which Dr. Flaherty writes is one floor down from her movement disorders clinic at Massachusetts General - filled with fossils and masks, neurological instruments pinned to a corkboard, books by Darwin, Mann and Virginia Woolf, posters of seminars and art exhibits based on The Midnight Disease.

Letters run up the back of her wrist. They are one consequence of hypergraphia, the overwhelming urge to write; she writes during manias and edits during depressions. (She keeps the illness under control with medication.) Dr. Jerrold F. Rosenbaum, chief of psychiatry at Mass General, says he used to get notes from Dr. Flaherty on napkins.

"I save everything she sends me, which I don't do with anyone else," he said. "She has enhanced theories of the mind - enhanced in quantity, quality, volume and intensity."

The wrist notes could be on any of a dozen topics. They may be more thoughts on empathic pain, or about research she is conducting on the side about light boxes and creativity in Harvard undergraduates.

Maybe they are about the informal consultation she made several years ago to an Off Broadway adaptation of A Doll's House, directed by Lee Breuer, a former colleague of hers at the Radcliffe Institute at Harvard, where they were both fellows in 2005.

When weeping during a scene, the actress who played Nora was alarmed upon noticing that the mascara ran from her left eye more quickly than from her right. Dr. Flaherty reassured her that the neurology was normal: the right brain, which controls the opposite side of the body, also controls negative emotions. Therefore, one side seems, and is, sadder than the other. This will go in Dr. Flaherty's next book, which will be about the neurobiology of illness behaviors ranging from hysteria to stoicism, and, of course, empathy.

In the movement disorders clinic, she follows about 130 patients - the stable ones annually, the still suffering every few weeks. She specializes in deep brain stimulation; electrodes are implanted in the brain to treat Parkinson's disease, tremors, dystonias and depressions. Within this specialty, she has developed a subspecialty appropriate to someone still struggling with her own moods.

"People can become manic or depressed as a side effect of deep brain stimulation," said Dr. Anne B. Young, director of the Institute for Neurodegenerative Disease at Mass General. "Alice is a master at managing this."

Dr. Flaherty's explanation was simple. "Neurology and psychiatry should be treating the same organ," she said.

At a recent clinic day, she managed to look professional in ski pants and a Spandex top, without a white coat. The patient who arrived was far more elegantly dressed.

For years, the woman suffered intractable depression. Brain stimulators were implanted in both frontal lobes, near an area called the anterior cingulate cortex. So far the treatment, augmented with medications, has been more successful than drugs alone or electroconvulsive therapy.

On this day, though, she was not feeling hopeful. "There's a parasite eating my brain," she said. "I'm dull, dumb, mindless."

Dr. Flaherty leaned forward. "The one thing I can say is, I believe you," she said. "I believe you used to be smarter, and your brain worked better."

"It took you eight years to feel your brain was intact, didn't it?" the patient asked with longing.

"For me," Dr. Flaherty replied, "it wasn't memory, but getting my brain to feel right. The psychiatrists said, 'You should get used to this as your new normal,' but I never did. It was always alienating when people said, 'Oh, that's just bipolar illness talking.' No, hello - that's me."

The woman held a programmer, a device that looked like an electronic toll tag, to each side of her chest. "Stimulator's still on, everything looks good," Dr. Flaherty said. She made notes in the chart before changing the parameters - volts, microseconds per pulse, hertz - that are the map of this world.

"Feel any tingling?" Experimentally, she turned both batteries off.

"Did you turn them back on?" the patient asked anxiously.

Afterward, Dr. Flaherty reflected on the anxiety. "It's no fun feeling your thoughts are being controlled by an electrode, and someone else is holding the clicker," she said. "I love the sensation of giving people their own clickers. I say, 'Here, you can have your own, I'll teach you how to use it, and within this safe range you can adjust it yourself.' "

It was an example of physician empathy, but also of identification. For Dr. Flaherty, each day holds reminders of her dual citizenship. Recently, she was interviewing someone with a rare brain lesion when her cellphone rang. She was needed for another interview across town in front of a class of Harvard Medical psychiatry students. She was the patient.