Understanding how sex affects your brain can improve your roll in the hay, and it may also shed light on other parts of your health, said Barry R. Komisaruk, distinguished professor of psychology at Rutgers University in Newark, New Jersey. It's not the easiest subject to study—test subjects might have to masturbate in an MRI machine—so research is still developing. But scientists are starting to unravel the mystery. Here's what we know so far about your brain on sex.

Sex is like a drug
Sex makes us feel good. That's why we want it, like it, and spend so much time hunting for mates. The pleasure we get from sex is largely due to the release of dopamine, a neurotransmitter that activates the reward center of the brain. Dopamine is also one of the chemicals responsible for the high people get on certain drugs.

"Taking cocaine and having sex don't feel exactly the same, but they do involve the same [brain] regions as well as different regions of the brain," said Dr. Timothy Fong, associate professor of psychiatry at UCLA's David Geffen School of Medicine.

Caffeine, nicotine, and chocolate also tickle the reward center, said Komisaruk.

RELATED: 13 Reasons to Have More Sex

Sex can act like an antidepressant
A 2002 study out of the University at Albany looked at 300 women and found that those who had sex without a condom had fewer depressive symptoms than women who did use a condom. The researchers hypothesized that various compounds in semen, including estrogen and prostaglandin, have antidepressant properties, which are then absorbed into the body after sex. (They corrected for other things that might affect both mood and condom use, such as being in a serious relationship or use of oral contraceptives.) This is good news for anyone who is in a committed relationship, but if you're still playing the field, then you shouldn't give up condoms. There are other ways to boost mood, but really no other way to prevent sexually transmitted diseases.

Sex can (sometimes) be a downer
Those feel-good chemicals may be going full blast during the act, but after? According to researchers, there is such a thing as post-sex blues (technical term: postcoital dysphoria). About one-third of the women participating in one study reported having experienced sadness after sex at some point in time. While it's possible that regret or feeling coerced might be the reason why, researchers can't explain the connection at this point for sure.

RELATED: 10 Reasons You're Not Having Sex

Sex relieves pain
Don't skip sex when you have a headache. Research shows that doing the deed may relieve your symptoms. In a 2013 German study, 60 percent of participants who had migraines and 30 percent of cluster-headache sufferers who had sex during a headache episode reported partial or total relief. Other studies have found that women who stimulated an area of the G spot had an elevation in pain threshold.

"It took greater pain stimulus for them to feel the pain," said Beverly Whipple, a professor emerita at Rutgers University who has conducted some research on the topic.

Whipple didn't study why this was so, but other researchers have attributed the effect to oxytocin, the so-called bonding hormone that helps mothers and babies bond and which also has pain-relieving properties.

Sex can wipe your memory clean
Each year, fewer than 7 people per 100,000 experience "global transient amnesia," a sudden but temporary loss of memory that can't be attributed to any other neurological condition. The condition can be brought on by vigorous sex, as well as emotional stress, pain, minor head injuries, medical procedures, and jumping into hot or cold water. The forgetfulness can last a few minutes or a few hours. During an episode, a person cannot form new memories or remember very recent events. Fortunately, there seem to be no lasting effects.

RELATED: 20 Weird Facts About Sex and Love

Sex may boost your memory
Or at least it might if you're a rodent. A 2010 study found that, compared with rats who were allowed only one one-night stand, rodents who engaged in "chronic" sex (once a day for 14 consecutive days) grew more neurons in the hippocampus, a region of the brain associated with memory. The findings were backed up by a second study, also in mice. It remains to be seen if regular sex also has this effect in humans (but you can always tell yourself it does).

Sex calms you down
The same study that linked frequent sex to a brain boost in rats also found that the rats were less stressed. This works for humans, too. One study found that people who'd just had sexual intercourse had better responses to stressful situations like public speaking than people who had not, or who had engaged in other types of sexual activity. How did sex ease stress? In this case, by lowering blood pressure.

Sex makes you sleepy
Sex is more likely to make men sleepy than women, and scientists think they know why: The part of the brain known as the prefrontal cortex winds down after ejaculation. This, along with the release of oxytocin and serotonin, may account for the "rolling over and falling asleep" syndrome.

This article originally appeared on Health.com.