Cerebral palsy is caused by abnormal development or damage to the parts of the brain that control movement, balance, and posture. Most often, the problems occur during pregnancy; however, they may also occur during childbirth or shortly after birth. Often, the cause is unknown. Risk factors include preterm birth, being a twin, certain infections during pregnancy such as toxoplasmosis or rubella, exposure to methylmercury during pregnancy, a difficult delivery, and head trauma during the first few years of life, among others. About 2% of cases are believed to be due to an inherited genetic cause. A number of sub-types are classified based on the specific problems present. For example, those with stiff muscles have spastic cerebral palsy, those with poor coordination have ataxic cerebral palsy and those with writhing movements have athetoid cerebral palsy. Diagnosis is based on the child's development over time. Blood tests and medical imaging may be used to rule out other possible causes.