Sounds kind of like a temper tantrum. My baby would bang her head on the railing of the crib until I freaked out and got her out. Now, she figured out that hurting herself makes ME feel bad.
Whenever she hears the word 'no' she will start banging her head on anything near her. If nothing is around, she will hit herself in the head and pull her hair. A new thing she has discovered is to pinch her tuti.
She doesn't want to stop playing for me to change her pants, so she gets mad at me and starts pinching her tuti.
I thought something was wrong for a while, then I just began to ignore the tantrums. They still happen, just not as much.
Try ignoring the rituals and maybe she will stop. Try putting soothing music on and just shutting the door and walking away.
Hope this helps.