On a recent Friday morning, a gray-haired woman whom I will call Sally arrived for an appointment with Karl Deisseroth, a psychiatrist and a neuroscientist in the bioengineering department at Stanford University. Sally, now in her sixties, had suffered since childhood from major depression, and had tried the standard treatments: counselling, medication, even electroconvulsive therapy. Nothing helped. She had spent much of her adult life in bed, and had twice attempted suicide. Seven years ago, she was referred to Deisseroth, who uses a combination of unusual medications and brain stimulation to treat autism and severe depression. He accepts only patients for whom all other treatments have failed.

On Deisseroth’s advice, a surgeon implanted beneath Sally’s left collarbone a small, battery-powered device that regularly sends bursts of electricity into the vagus nerve, which carries the signal into a deep-brain structure that doctors think regulates mood. Originally developed for epilepsy, vagus-nerve stimulation (VNS) has been approved by the Food and Drug Administration for use in the kind of treatment-resistant depression from which Sally suffers, but the exact reason for its effectiveness is not understood. Sally says that VNS has transformed her life, and that, apart from one period of “going pancake,” she has experienced just a few “dips.”

She seemed to be in one of those dips when she took a seat facing Deisseroth. “There’s just so much going on,” she said. She had recently suffered a blackout, which her physician thought might be related to a drop in blood pressure, and she had decided, reluctantly, to stop driving until she understood why it had happened. Walking was hard, too; she was scheduled to have knee surgery soon, but it frightened her.

“Well, that’s a lot to think about,” Deisseroth said. He spoke quietly but with a positive lilt, countering the downward tug of Sally’s mood. “Not super-low blood pressure,” he said, scanning her chart. “So that’s actually not as concerning as I thought.” Of her decision to suspend driving, he said, “That is smart while it’s being figured out.” He added, “You’re still socializing, I see—which is very important.”

She was not mollified. “Mood’s been down,” she said. “Just spiralling down.” She mentioned insomnia, bad dreams, low appetite.

“No suicidal thoughts?” he asked.

“Mmm, no,” she said. With sudden urgency, she asked to have the VNS current increased: “Can we please go up to 1.5?” She had been receiving 1.2 milliamps every five minutes for thirty seconds, but was no longer able to feel the effects.

“You’re tolerating the device very well,” Deisseroth said, after some discussion. “I think we can go up a little.”

He handed her a programming wand, which looked a little like a Wii remote. She placed the broad, flat end against her left collarbone, over the implant. Deisseroth took from his desk what appeared to be a smartphone—a controller for the wand—and thumbed the screen as if tapping out a text. The wand emitted a trilling tone. “I can feel it,” she said.

“But you’re not coughing,” he said. “That’s good.”

Problems with the throat are not the only side effects of VNS. Cells outside the targeted treatment area can be roused, affecting cognition. After increasing the voltage, Deisseroth asked Sally that day’s date and the counties she’d travelled through to get to his office, and to count backward from a hundred by sevens. She performed all the tasks. “Good,” he said. “Flawless cognition.”

In the course of the next few minutes, Sally underwent a remarkable change. Her frown disappeared, and she became cheerful, describing the pleasure she’d had during the past Christmas holiday and recounting how she had recently watched some YouTube videos of Deisseroth. (“The N.I.H. in June—your demeanor behind the podium is, like, Wow! Very strong.”) She was still smiling and talking when the session ended and Deisseroth walked her out to the reception area.

Later, Deisseroth told me that Sally’s response to the treatment was good evidence for the efficacy of VNS. But it also provided valuable insight for Deisseroth in his work as a neuroscientist. “When I’m sitting in front of a patient and hearing what they’re feeling, it concentrates the mind wonderfully,” he says. “It’s a source of hypothesis, a source of ideas.”

For much of the history of brain research, it has been nearly impossible to accurately test ideas about how the brain works. “When we have the complexity of any biological system—but particularly the brain—where do you start?” Deisseroth says. Among scientists, he is best known for his development of optogenetics, a technology that renders individual, highly specific brain cells photosensitive and then activates those cells using flashes of light delivered through a fibre-optic wire. Optogenetics has given researchers unprecedented access to the workings of the brain, allowing them not only to observe its precise neural circuitry in lab animals but to control behavior through the direct manipulation of specific cells. Deisseroth, one of the rare neuroscientists who are also practicing psychiatrists, has made mental illness a major focus of his optogenetic research. Other scientists around the world are using the method to investigate some of the most stubborn riddles of neuroscience, including the fundamental question of how the physical brain—the nearly hundred billion neurons and their multitudinous connections—gives rise to the mind: thought, mood, behavior, emotion.

In the late seventeen-hundreds, the Italian physician Luigi Galvani noticed that static electricity could induce a dead frog’s leg to move. For the first time, scientists understood that the nervous system operates under the influence of electrical activity. But it was not until the nineteen-twenties that a Swiss researcher, Walter R. Hess, using implanted wires to stimulate the brains of cats, showed that emotion and behavior also arise from electrical impulses in the brain. By stimulating various brain regions, Hess induced different reactions: for example, a cat could be made to show the defensiveness it might otherwise display when confronted by a dog.

In the nineteen-fifties, a Spanish physiologist at Yale, José Manuel Rodriguez Delgado, conducted experiments with electrodes implanted in the brains of human subjects, using a device he had invented, called a “stimoceiver,” a half-dollar-size electrode operated by remote control. Delgado used the stimoceiver in some twenty-five patients, most of them epileptics and schizophrenics in a Rhode Island mental hospital, and reported that it was “possible to induce a large variety of responses, from motor effects to emotional reactions and intellectual manifestations.” The experiments sparked outrage when they were made public, and Delgado returned to Spain.

The ethical concerns inherent in implanting electrodes in human brains gave way, in the early nineteen-nineties, to the adoption of a wholly noninvasive brain-imaging technology: functional magnetic resonance imaging, or fMRI. It was instrumental in bolstering the theory that the brain is divided into discrete regions responsible for different aspects of behavior. The technology uses powerful magnets to detect changes in blood flow in the brain in subjects who are exposed to various stimuli—images, sounds, thoughts. Activated regions can be presented on a screen as luminous blobs of color. But fMRI has severe limitations. There is a time lag, and different neuronal events that happen a second or more apart can blur together when the excited area appears onscreen—a liability in studying an organ that works at millisecond speed. Nor can fMRI reveal what brain cells are actually doing. The technique registers activity only at the scale of hundreds of thousands of neurons, and a lit-up area might represent any number of neural processes. Given this lack of precision, even some of fMRI’s defenders offer faint praise. Nancy Kanwisher, of M.I.T., who has done groundbreaking work to isolate a brain region implicated in face recognition, says, “The real miracle of fMRI is that we ever see anything at all.”