Memories and the feelings associated with them are not set in stone. You may have happy memories about your family’s annual ski vacation, but if you see a tragic accident on the slopes, those feelings may change. You might be afraid to ski that mountain again.

Using a technique in which light is used to switch neurons on and off, neuroscientists at the Massachusetts Institute of Technology (MIT) appear to have unlocked some secrets about how the brain attaches emotions to memories and how those emotions can be adjusted.

Their research, published Wednesday in the journal Nature, was conducted on mice, not humans, so the findings cannot immediately be translated to the treatment of patients. But experts said the experiments may eventually lead to more effective therapies for people with psychological problems such as depression, anxiety or post-traumatic stress disorder.

“Imagine you can go in and find a particular traumatic memory and turn it off or change it somehow,” said David Moorman, an assistant professor of psychological and brain sciences at University of Massachusetts, Amherst, who was not involved in the research. “That’s still science fiction, but with this we’re getting a lot closer to it.”

The MIT scientists labeled neurons in the brains of mice with a light-sensitive protein and used pulses of light to switch the cells on and off, a technique called optogenetics. Then they identified patterns of neurons activated when mice created a negative memory or a positive one.

A negative memory formed when mice received a mild electric shock to their feet; a positive one was formed when the mice, all male, were allowed to spend time with female mice.

Later, mice that had been shocked were put in the company of females — a positive experience — while scientists used the light to activate the memory of the shock. As a result, the negative memory became less negative; the mice became less fearful in the place where they had been conditioned to remember the shock.

The mice that originally spent time with the females later received mild electric shocks while scientists activated the neurons associated with this positive memory. The memory became less enticing, the scientists concluded: The mice froze more and sniffed less, standard measures of fear and reward in rodents.

The study’s senior author, Susumu Tonegawa, a professor of biology and neuroscience at MIT, said the findings provided a neurological basis for psychotherapy in which patients are encouraged to unearth a good memory to “reduce the feelings of a bad memory they have or stress they have had.”

Roger Redondo, a postdoctoral student and one of the study’s lead authors, said the experiments showed it was possible to alter the emotional perception of a memory “without any drugs and without the mice being brought back to the area where the memory occurred.”

The scientists also discovered important differences in the way neurons work in two key brain areas, the hippocampus and the amygdala. The hippocampus is involved in forming new memories and encoding factual details such as where, what and when. The amygdala helps link emotions to memory.

The experiments found that neurons in the hippocampus can be changed to make a bad memory less negative, and vice versa. But neurons in the amygdala did not change, leading scientists to conclude that these neurons are prewired to reflect positive or negative emotions.

Joshua Johansen, a neuroscientist at Riken Brain Science Institute in Japan who was not involved in the research, said the findings “provide clues as to how we go about tackling things like anxiety disorder.”

He cautioned that this research is in its infancy and that it involved normal behaviors, not disorders. But, Johansen said, “if we can figure out how to associate bad experiences with neutral or pleasurable experiences,” it could guide development of drugs, gene therapy or other treatments for mental illness.