While peripheral sensory neurons respond to natural stimuli with a broad range of spatiotemporal frequencies, central neurons instead respond sparsely to specific features in general. The nonlinear transformations leading to this emergent selectivity are not well understood. Here we characterized how the neural representation of stimuli changes across successive brain areas, using the electrosensory system of weakly electric fish as a model system. We found that midbrain torus semicircularis (TS) neurons were on average more selective in their responses than hindbrain electrosensory lateral line lobe (ELL) neurons. Further analysis revealed two categories of TS neurons: dense coding TS neurons that were ELL-like and sparse coding TS neurons that displayed selective responses. These neurons in general responded to preferred stimuli with few spikes and were mostly silent for other stimuli. We further investigated whether information about stimulus attributes was contained in the activities of ELL and TS neurons. To do so, we used a spike train metric to quantify how well stimuli could be discriminated based on spiking responses. We found that sparse coding TS neurons performed poorly even when their activities were combined compared with ELL and dense coding TS neurons. In contrast, combining the activities of as few as 12 dense coding TS neurons could lead to optimal discrimination. On the other hand, sparse coding TS neurons were better detectors of whether their preferred stimulus occurred compared with either dense coding TS or ELL neurons. Our results therefore suggest that the TS implements parallel detection and estimation of sensory input.