How does a electroencephalogram work?