Magic mushrooms might help depressed patients by helping them “reset” their brains, according to a new study that uses brain scans to look at the lasting effects of psychedelics.

There has been a recent wave of research into the helpful effects of psychedelics for mental health. LSD microdoses make people feel sharper, while magic mushrooms have helped cancer patients cope with depression and anxiety. But most of these brain imagining studies focus on how the brain changes when you’re on the drug, while in a study published today in the journal Scientific Reports, researchers focused on the results before and after.

Scientists at Imperial College London gave psilocybin, the active ingredient in magic mushrooms, to 20 patients who had depression that hadn’t been helped by other treatments. Patients first took a 10mg dose of psilocybin, then a 25mg dose the week after.

All the patients said they still felt better a week after treatment, and about half of them felt better five weeks later, too. These self-reports were confirmed by before-and-after brain scans. After the treatment, there was less blood flow in the part of the brain that is involved in emotion processing, called the amygdala.

Interestingly, scans of the brain while on drugs show a type of “disintegration” where there’s less connectivity between different parts. Researchers have suggested that this disintegration is responsible for why people report losing their sense of self or ego while on drugs. But the scans of the brain afterward found that there’s more connectivity and integration, suggesting that maybe psychedelics work by breaking down the old pattern and kickstarting the brain into a new one.

This research is at an early stage; the group in this study was small and didn’t have a control group. Also, the therapeutic benefits of mushrooms are also usually dependent on people taking them in carefully controlled environments. (So, doing a lot of mushrooms at a rave might not be good for mental health.) Larger studies are still needed, but this is a good peek into the mechanisms of how this works. The team at Imperial College London plan to do a study testing psilocybin against antidepressants next year.