New research suggests that a diet loaded with fat and sugar "may be hurting not only our physical health," but also our ability to think, The Huffington Post reported.

Researchers at Oregon State University found that both a high-fat and a high-sugar diet, compared to a normal diet, cause changes in gut bacteria that appear related to a significant loss of "cognitive flexibility," or the power to adapt and adjust to change. These diets can also impair learning for both long-term and short-term memory.

The study confirmed previous findings about the impact of fat and sugar on cognitive function and behavior, and it also suggests that "some of these problems may be linked to alteration of ... a complex mixture in the digestive system of about 100 trillion microorganisms," researchers wrote in the study.

"We've known for a while that too much fat and sugar are not good for you," Dr. Kathy Magnusson, principal investigator of the study, said in a statement. "This work suggests that fat and sugar are altering your healthy bacterial systems, and that's one of the reasons those foods aren't good for you. It's not just the food that could be influencing your brain, but an interaction between the food and microbial changes."

For the study, researchers experimented on mice that consumed various diets then faced a variety of tests that of "cognitive and motor tasks," such as water maze testing, to monitor changes in their mental and physical function, CTV News reported.

They found that after just four weeks on a high-fat or a high-sugar diet, the performance of mice on various tests of mental and physical function began to drop, compared to animals on a normal diet. One of the most pronounced changes was in their cognitive flexibility.

"The impairment of cognitive flexibility in this study was pretty strong," Magnusson said. "Think about driving home on a route that's very familiar to you, something you're used to doing. Then one day that road is closed and you suddenly have to find a new way home."

The findings are detailed in the journal Neuroscience.