Mind reading is a scenario straight out of science fiction, but scientists say they can now see and identify different emotional states in the human brain. Researchers at Duke used magnetic resonance imaging (MRIs) to map out various emotional states, and say the research may eventually serve as a form of treatment to help people who have difficulty identifying their own emotions.

“Earlier studies have shown that functional MRI can identify whether a person is thinking about a face or a house. Our study is the first to show that specific emotions like fear and anger can be decoded from these scans as well,” Kevin LaBar, a professor of psychology and neuroscience at Duke said in a statement.

The study builds on previous research by the team published in 2015. LaBar and Philip Krangel, a graduate student at the time, were able to identify emotions as networks of activity found across the brain.

These networks were then mapped by showing two music and film clips to 32 research subjects, intending to inspire seven emotions: content, amusement, surprise, fear, anger, sad, and neutral. To confirm the results, the participants completed questionnaires regarding their moods during the clips.

Next, a portion of the data was presented to analytical software called a machine learning algorithm and was tasked with finding a pattern for each of the seven emotions. After learning what each emotion looked like, the algorithm was given the remainder of the data and was asked to classify the subject’s emotions without knowing what prompted them.

Labar said rather than random guessing, the model was better than chance, and “it proved fairly sensitive.”

A follow-up study, published on Sept. 14, scanned 21 research subjects who were told to let their minds wander.

“We tested whether these seven brain maps of emotions occurred spontaneously while participants were resting in the fMRI scanner without any emotional stimuli being presented,” LaBar said in a press release.

When the same algorithm was used in this study, it was able to accurately predict the moods self-reported by the research subjects.

This research may be applicable in studying people with poor insight into their emotional status, LaBar said in the release.

Read more: Can High Levels Of Negative, Unpleasant Emotions Cause Brain Damage?

Kragel P, Knodt A, Hariri A, LaBar K. Decoding Spontaneous Emotional States in the Human Brain. Plos Biology. 2016