Scientists are hopeful that a new technology will be able to objectively measure and detect pain in people — such as elderly dementia patients — who are unable to articulate whether they are hurting, according to a new study.

Traditionally, medical professionals have relied on patients’ self-assessments to determine pain levels. But now, researchers at Stanford are combining neuroimaging devices with software that could alert nurses and physicians when a patient is in pain and cannot communicate what he or she is feeling, Reuters reported. This could be helpful in treating young children, dementia patients or those with difficulty speaking.

In one trial, eight participants underwent brain scans while investigators touched them with objects with increasing degrees of heat, according to the study. A computer used data from the scans to detect brain activity patterns consistent with pain.

“The question we were trying to answer was can we use neuroimaging to objectively detect whether a person is in a state of pain or not. The answer was yes,” researcher Sean Mackey, M.D., Ph.D., told Reuters. “We’re hopeful we can eventually use this technology for better detection and better treatment of chronic pain.”

The study was published in PLoS One.