A new study suggests that not getting enough sleep has almost the same effect on our food choices as smoking cannabis. That’s right -- being sleep deprived could give you the munchies for sweet and fatty foods.

The connection between sleep patterns and unhealthy eating habits has been studied before, but this new study, published last week in eLife, looks specifically at the neural pathways that allow sleep deprivation to affect food intake.

Researchers found that the same type of molecules that influence food cravings in individuals who smoke marijuana were found to be enhanced in the systems of people who had gotten only four hours of sleep, as opposed to a full eight hours.

The sleep-deprived participants, when given the choice of what to eat, gravitated towards food that was higher in calories, the study says.

So what exactly is going on?

According to the study, it has to do with two things: your nose and your endocannabinoid system.

The endocannabinoid system (ECS) -- named because it was discovered while scientists were studying how THC, the active ingredient in cannabis, affects the human body -- refers to substances similar to cannabis that are naturally produced in the body and help balance biological processes such as appetite, sleep and temperature regulation, among other things.

Cannabis causes an artificial boost in food cravings, particularly for sweeter foods high in fat, because it can stimulate this natural network of receptors. And now this study suggests that sleep deprivation could affect the ECS in much the same way.

But how does your sense of smell come into it?

The olfactory senses have long been linked to food intake and appetite -- we’ve all experienced getting hit with a sudden desire to eat a certain food after a delicious smell goes wafting past our noses. The new study in eLife said that previous studies had established that the olfactory region of the brain experiences more activity when we’re hungry, and reduced activity when we’re not, and that the ECS could be involved in modulating this, but researchers wanted to take a closer look at that idea.

The study involved 25 participants. Researchers first had them undergo a week of sleeping seven to nine hours a night to see what their brains and behavior looked like when they were getting a regular amount of sleep. After that, participants were randomly assigned to sleep for only four hours on certain nights.

Researchers would then unleash the sleepy, hungry people on a buffet-style smorgasbord of food, which was when they observed their preference for fattier, high-energy snacks over other options.

One curious finding of the study was that sleep-deprivation did not seem to increase the level of hunger participants felt, only what type of food they were hungry for.

“Importantly, effects of sleep deprivation on dietary behavior persisted into the next day (after a night of unrestricted recovery sleep), with a higher percentage of calories consumed,” the study said.

When researchers specifically looked at the ECS, they found that there were indeed higher levels of specific endocannabinoids proportional to the increase in high energy food consumption.

By doing fMRIs throughout the study, researchers also tracked brain activity in the olfactory regions. They exposed participants to food scents and non-food scents, and when participants were sleep deprived, they reacted much more strongly to food odors than the rest of the odors.

However, there was a breakdown of communication observed between the piriform cortex and the insular cortex -- two different sections of the brain -- when sleep deprivation and levels of endocannabinoids were high, which researchers believe could have played a part in participants instinctively choosing the high calorie foods over other options.

Researchers say the aim of studies such as this is to “help scientists to develop new drugs or behavioral therapies for conditions like obesity.

“In the United States alone, one in three people sleep less than six hours a night,” the study says.

As the study was limited in scope, more research needs to be done to really clarify exactly how sleep deprivation works with the ECS and the sense of smell to affect food cravings.

But in the meantime, this study suggests that if you want to convince your body to crave muffins over donuts, getting some extra hours of shut eye might be a good start.