In the summer of 2007, a team of Stanford graduate students dropped a mouse into a plastic basin. The mouse sniffed the floor curiously. It didn't seem to care that a fiber-optic cable was threaded through its skull. Nor did it seem to mind that the right half of its motor cortex had been reprogrammed.

One of the students flipped a switch and intense blue light shone through the cable into the mouse's brain, illuminating it with an eerie glow. Instantly, the mouse began running in counterclockwise circles as though hell-bent on winning a murine Olympics.

Then the light went off, and the mouse stopped. Sniffed. Stood up on its hind legs and looked directly at the students as if to ask, "Why the hell did I just do that?" And the students whooped and cheered like this was the most important thing they'd ever seen.

Because it was the most important thing they'd ever seen. They'd shown that a beam of light could control brain activity with great precision. The mouse didn't lose its memory, have a seizure, or die. It ran in a circle. Specifically, a counterclockwise circle.

Precision, that was the coup. Drugs and implanted electrodes can influence the brain, but they are terribly imprecise: Drugs flood the brain and affect many types of neurons indiscriminately. Electrodes activate every neuron around them.

This is bad for researchers, because practically every square millimeter of the brain contains a mess of different kinds of neurons, each specialized for a particular task. Drugs and electricity set off cascades of unwanted neural activity. Side effects.

It's bad for patients, too. Cochlear implants, which let the deaf hear by shocking the auditory nerves, produce fuzzy sound because the electricity spreads beyond the neurons it's aimed at. Deep brain stimulators for Parkinson's patients allow them to walk and speak but may cause seizures and muscle weakness. Electroshock can help depression but often results in memory loss.

In 1979, Francis Crick, codiscoverer of the double-helix structure of DNA, lamented the blunderbuss nature of existing technologies. What was needed, he wrote in Scientific American, was a way to control neurons of only one cell type in one specific location. Which, nearly 30 years later, was precisely what these students had achieved.

But how could they be using light? Neurons don't respond to light any more than muscles do. The idea sounds as crazy as trying to jump-start a car with a flashlight. The secret is that the mouse's neurons weren't normal. New genes had been inserted into them — genes from plants, which do respond to light, and the new genes were making the neurons behave in planty ways.

Genes are just instructions, of course. By themselves they don't do anything, just as the instructions for your Ikea desk don't make it leap together. But genes direct the assembly of proteins, and proteins make things happen. The weird new plant proteins in this mouse's brain were sensitive to light, and they were making the neurons fire.

The counterclockwise-running mouse was something new — a triple fusion of animal, plant, and technology — and the students knew it was a harbinger of unprecedentedly powerful ways to alter the brain. For curing diseases, to begin with, but also for understanding how the brain interacts with the body. And ultimately for fusing human and machine.

The story of this technology starts with a most unlikely creature: pond scum. In the early 1990s, a German biologist named Peter Hegemann was working with a single-celled bug called Chlamydomonas, or, less technically, algae. Under a microscope, the cell looks like a little football with a tail. When the organism is exposed to light, its tail wags madly, moving the cell forward.

Hegemann wanted to know how this single cell, with no eye or brain, responded to light. How did it "see"? What made it "act"?

Answers slowly emerged: Hegemann and his colleagues found that part of the cell's membrane is packed with coiled-up proteins. They theorized that when a photon hits one of those proteins, the molecule uncoils, creating a tiny pore in the membrane. Charged ions flow across the membrane, which makes the cell's flagella move. And the whole shebang swims forward.

This was good, solid cell research. Fascinating little machines! But completely useless fascinating little machines. It wasn't until the end of the decade that scientists figured out how they might be put to use.

In 1999, Roger Tsien, a biologist at UC San Diego, was heeding Crick's call for better ways to trigger neurons. When he read about Hegemann's work with Chlamydomonas, he wondered: Could that photosensitivity somehow be imported into neural cells? To do that, it would be necessary to figure out which gene made the light-sensitive protein in the Chlamydomonas cell wall. Then the gene could be inserted into neurons so that, Tsien hoped, they too would fire in response to light.

Now, using light to make neurons fire wouldn't be a huge deal; electricity could do that. But the exciting part was that a gene could be designed to affect only specific kinds of neurons. Scientists can mark a gene with a "promoter" — a cell-specific piece of DNA that controls whether a gene is used.

Here's what they do: Insert the gene (plus promoter) into a group of viral particles and inject them into the brain. The viruses infect a cubic millimeter or two of tissue. That is to say, they insert the new gene into every neuron in that area, indiscriminately. But because of the promoter, the gene will only turn on in one type of neuron. All the other neurons will ignore it. Imagine you wanted only the lefty in an outfield to catch. How would you do that? Distribute left-handed gloves to all the players. The righties would just stand there, fidgeting and calling their agents. The lefty would spring into action. Just as the lefty is "tagged" by his ability to use the glove, a neuron is "tagged" by its ability to use the gene. Bye-bye side effects: Researchers would be able to stimulate one kind of neuron at a time.

It was a dazzling idea. Tsien wrote to Hegemann asking for the Chlamydomonas light-sensitivity gene. Hegemann wasn't sure which one it was, so he sent two possibilities. Tsien and his graduate students duly inserted both into cultured neurons. But when exposed to light, the neurons did nothing at all. Tsien extracted two more genes from the algae and tried one of them, but that didn't work either. "After three strikes, you have to admit that you're out and try something else," Tsien says. So he moved on to another line of research and put the fourth gene back into the lab refrigerator, unexamined.

Tsien may have put his work on ice, but Hegemann and his colleagues continued searching; two years later, they inserted a gene into a frog egg and shone light on it. Voilè0! The egg responded with a flow of current.

When Tsien read their paper, he recognized the gene immediately. It was, of course, the one he'd put away. "Our error was not to put it in the fridge," Tsien says wryly, "but rather to fail to take it back out." That's science, though: "You win some, you lose some." (And he did end up winning some. For his new area of research, using genes to make cells glow by cell type, he won a Nobel Prize in 2008.)

Hegemann's team named the gene Channelrhodopsin-1. In 2003, they published a bold proposal about its variant, Channelrhodopsin-2: It "may be used to depolarize [activate] animal cells ... simply by illumination." Now someone had to find a practical use for this discovery.

Karl Deisseroth, a psychiatrist at Stanford, has seen many people with horrific brain diseases. But there are two patients, in particular, that drive his work. He once treated a bright college student ravaged by depression who had grown terrified by its assault on his mind. The other patient was frozen by Parkinson's. The disease had slowly destroyed the motor control areas of her brain until she was unable to walk, smile, or eat. "I couldn't save either of these patients," Deisseroth says. "My inability to treat them, despite our best efforts, has stayed with me."

Deisseroth, a compact man in his late thirties, is also a neuroscientist. He holds a psych clinic one day a week but spends the rest of his time running a lab. In 2003, he read Hegemann's paper and asked himself the same thing that Tsien had back in 1999: Could the brain's misbehaving cells be tagged genetically and controlled with light?

He took on several graduate students to research this, including Feng Zhang and Ed Boyden. Zhang had just graduated from Harvard. He is precisely spoken, his lean sentences tinged with a Boston accent overlaid on a Mandarin one. Boyden, on the other hand, talks so fast he swallows his words, as if his brain were perpetually outracing his mouth. He's a man in a hurry. He had graduated from MIT at age 19 with a thesis on quantum computation and was pursuing his doctorate in neuroscience.

In 2005, Zhang and Boyden repeated Tsien's experiment. This time, though, they had the right gene. They inserted it into a culture of neural tissue on a glass slide and poked a tiny electrode into one of the neurons so they would know when it fired. Then they aimed blue light at it. (Channelrhodopsin reacts most strongly to light at 480 nanometers on the spectrum, i.e., blue.)

Their apparatus looked like a microscope that spent its off-hours at the gym. It had a camera screwed into the eyepiece, a laser aimed at the slide, and big boxes of circuitry for amplifying the tiny current they hoped to see. If the cell fired, a huge in-your-face spike would appear on a screen. And that's exactly what happened. With every flash, another spike marched across the whiteness.

They now had an On switch for neurons. But in the brain, it's as important to inhibit neurons as it is to make them fire. As with computers, 0 is as crucial as 1; they needed an Off switch, too. When Boyden finished his PhD, he took an appointment at MIT and began hunting for it. He found there was a bacterial gene, halorhodopsin, that had properties suggesting it could do the opposite of channelrhodopsin. In 2006, Boyden inserted halorhodopsin into neurons and exposed them to yellow light. They stopped firing. Beautiful.

Over at Stanford, Deisseroth's team was making the same discovery, and soon they were stopping worms in their tracks with yellow light. Other labs were already making flies leap into the air when exposed to blue light. And on The Tonight Show, Jay Leno had even joked about the technology with a clip in which he pretended to steer a "remote control" fly into George W. Bush's mouth. The research was mushrooming, and dozens of labs were calling Deisseroth to ask for the genes. The new field was dubbed optogenetics: optical stimulation plus genetic engineering.

But neurons in petri dishes and in bugs were comparatively simple. Would optogenetics work in the staggeringly complex tangle of a mammalian brain? And could it be used to cure real brain illnesses?

By summer 2007, Deisseroth's group had answered the first question with their counterclockwise mouse. They put the channelrhodopsin gene into the mouse's right anterior motor cortex, which controls the left side of the body. When the light went on, the little guy went left.

Deisseroth immediately put his lab to work figuring out what part of the brain needed to be stimulated to cure Parkinson's. Optogenetics was the ideal tool because it let researchers test various types of neurons to find which one would make legs move again, hands grasp again, faces smile again.

But test after test failed. "This was a discouraging time," Deisseroth says. "The project was almost abandoned, because we had difficulty showing any therapeutic result."

Many experts had thought the cure was to stimulate certain kinds of cells within the subthalamic nucleus, which coordinates motion. But when they tried that, it had no effect whatsoever. Then two of Deisseroth's grad students began experimenting with a dark-horse idea. They stimulated neurons near the surface of the brain that send signals into the subthalamic nucleus — a much harder approach because it meant working at one remove. It was as if, instead of using scissors yourself, you had to guide someone else's hands to make the cuts.

Their idea worked. The mice walked. In their paper, published in April 2009, they wrote that the "effects were not subtle; indeed, in nearly every case these severely parkinsonian animals were restored to behavior indistinguishable from normal."

Over at MIT, Boyden was asking the obvious question: Would this work on people? But imagine saying to a patient, "We're going to genetically alter your brain by injecting it with viruses that carry genes taken from pond scum, and then we're going to insert light sources into your skull." He was going to need some persuasive safety data first.

That same summer, Boyden and his assistants began working with rhesus monkeys, whose brains are relatively similar to humans'. He was looking to see whether the primates were harmed by the technique. They triggered the neurons of one particular monkey for several minutes every few weeks for nine months. In the end, the animal was just fine.

The next step was creating a device that didn't require threading cables through the skull. One of Deisseroth's colleagues designed a paddle about one-third the length of a popsicle stick. It has four LEDs: two blue ones to make neurons fire and two yellow ones to stop them. Attached to the paddle is a little box that provides power and instructions. The paddle is implanted on the surface of the brain, on top of the motor control area. The lights are bright enough to illuminate a fairly large volume of tissue, so the placement doesn't have to be exact. The light-sensitizing genes are injected into the affected tissue beforehand. It's a far easier surgery than deep brain electrical stimulation, and, if it works, a far more precise treatment. Researchers at Stanford are currently testing the device on primates. If all goes well, they will seek FDA approval for experiments in humans.

Treating Parkinson's and other brain diseases could be just the beginning. Optogenetics has amazing potential, not just for sending information into the brain but also for extracting it. And it turns out that Tsien's Nobel-winning work — the research he took up when he abandoned the hunt for channelrhodopsin — is the key to doing this. By injecting mice neurons with yet another gene, one that makes cells glow green when they fire, researchers are monitoring neural activity through the same fiber-optic cable that delivers the light. The cable becomes a lens. It makes it possible to "write" to an area of the brain and "read" from it at the same time: two-way traffic.

Why is two-way traffic a big deal? Existing neural technologies are strictly one-way. Motor implants let paralyzed people operate computers and physical objects but are incapable of giving feedback to the brain. They are output-only devices. Conversely, cochlear implants for the deaf are input-only. They send data to the auditory nerve but have no way of picking up the brain's response to the ear to modulate sound.

No matter how good they get, one-way prostheses can't close the loop. In theory, two-way optogenetic traffic could lead to human-machine fusions in which the brain truly interacts with the machine, rather than only giving or only accepting orders. It could be used, for instance, to let the brain send movement commands to a prosthetic arm; in return, the arm's sensors would gather information and send it back. Blue and yellow LEDs would flash on and off inside genetically altered somatosensory regions of the cortex to give the user sensations of weight, temperature, and texture. The limb would feel like a real arm. Of course, this kind of cyborg technology is not exactly around the corner. But it has suddenly leapt from the realm of wild fantasy to concrete possibility.

And it all began with pond scum.

Michael Chorost (michael@chorost.com) wrote about his cochlear implant in issue 13.11.