There is voluminous writing in the area of monastic spiritually about this. On the one hand, they affirm that these thoughts aren't chosen, using the vocabulary of sinful thoughts introduced by demons. But it's also clear that change is possible through prayer/meditation (not exactly identical to modern ideas about mindfulness).