A functional model of non-suicidal self-injury in real-time