Spatially, every part of the brain receives inputs from and acts on the other regions. Temporally, every moment’s brain carries information from the previous moment and influences the next moment. Fully dissecting single and straightforward processes at the whole-brain scale could lead to understanding complex brain functions, such as cognition. We developed a system that can monitor the entire zebrafish brain with single-cell resolution, and real-timely process the obtained neuronal or behavioral information to generate closed-loop perturbations. Using this approach, we studied sensorimotor transformation under two circumstances: the immediate sensory cues get integrated and separated in different parts of the brain and different stages of the information flow; the previous sensory experiences get encoded, stored, and retrieved during navigation. Interestingly, the latter process may recapitulate the serial bias, which is proposed to maintain the continuous perception of the environment. In summary, merging the insights accumulated in the cognitive neurosciences with the experimental techniques in the circuit study might provide a layer supporting a thorough understanding of complex brain functions.