Quantifying sensory and cognitive signals in visual and frontal cortex