Though still poorly understood, the basal ganglia are sort of like the movement command center of the brain that responds to situations by choosing from a menu of motions or gestures that you’ve learned. The theory is that when situations are frustrating or stressful because you are either over- or under-stimulated (i.e. strung out or bored) your basal ganglia manage by selecting (or perhaps failing to inhibit) a default motor behavior, which would be the tic, stereotypy or motor habit.

In this way, we are not so different from animals. Go to many zoos and you’ll see anxious or bored animals rocking, jerking their heads and necks, plucking out their feathers or fur, pacing in circles, swinging their arms (or trunks in the case of elephants) and mouthing themselves or various objects.

“The whole point of a habit is you don’t have to use cognitive resources to do it,” said Doug Woods, a professor of psychology at Marquette University in Milwaukee who studies and treats people with tics and other repetitive behaviors. He said that for many of his patients, the tics somehow become associated with a reward — whether it’s temporary distraction, satisfaction or release.

Most repetitive behaviors, regardless of etiology, begin in childhood. The immature brain, unable to recognize and process emotions as an adult does, resorts to motor activity to cope. Except for children with severe autism, most kids grow out of habits like head-shaking, arm-flapping and grimacing as they become better able to understand and manage their feelings. Or they just find a way to convert the behavior into something more socially acceptable and “adult.” Rocking might morph into leg-bobbing, mouth-stretching turns into gum-chewing or finger-wiggling may become iPhone-fiddling (yet another reason people can’t put down their phones).

“These behaviors persist, it’s just the person learns to have more control over it or learns to do it in private or under the table,” said Dr. Harvey Singer, professor of neurology at Johns Hopkins School of Medicine and specialist in childhood stereotypies.

Most people don’t seek treatment and indeed, many find their repetitive behavior comforting. Help is generally only sought when the movement or vocalization becomes so insistent and frequent it impairs daily functioning or is a turnoff in relationships. Neck tics can harm vertebrae, for example; skin-picking can lead to unsightly scabs and scarring and employers tend not to hire people who can’t stop blinking or clicking a pen during an interview. It probably goes without saying that such behavior is not an asset in dating.

To help people stop, doctors first rule out drugs such as antihistamines, antidepressants, A.D.H.D. medications, methamphetamine or heroin as a cause or aggravating factor. Assuming this isn’t the case, treatment begins with raising the person’s awareness of the tic or motor habit since it’s become so automatic. This usually involves describing it to a therapist in excruciating detail including any urges that precede it and every aspect and nuance of the movement.