Diagnosis and treatment of cognitive impairment