There are some fringe religions which see pain as a form of meditation. In fact, it is one of the many ways to achieve transcendence - pain, meditation, drugs, dancing etc. They all change the physiology of the body and brain in different ways. Even chanting and praying/singing in church/temple/mosque has an effect on the chemistry of the brain in this way.