Reverse-engineering the visual and haptic perceptual algorithms in the brain