We present an imaging system for pan-neuronal recording in crawling Caenorhabditis elegans. A spinning disk confocal microscope, modified for automated tracking of the C. elegans head ganglia, simultaneously records the activity and position of \~80 neurons that coexpress cytoplasmic calcium indicator GCaMP6s and nuclear localized red fluorescent protein at 10 volumes per second. We developed a behavioral analysis algorithm that maps the movements of the head ganglia to the animal’s posture and locomotion. Image registration and analysis software automatically assigns an index to each nucleus and calculates the corresponding calcium signal. Neurons with highly stereotyped positions can be associated with unique indexes and subsequently identified using an atlas of the worm nervous system. To test our system, we analyzed the brainwide activity patterns of moving worms subjected to thermosensory inputs. We demonstrate that our setup is able to uncover representations of sensory input and motor output of individual neurons from brainwide dynamics. Our imaging setup and analysis pipeline should facilitate mapping circuits for sensory to motor transformation in transparent behaving animals such as C. elegans and Drosophila larva.