Abstract: Advances in optical neural imaging provide an opportunity to record panneuronal neural activity and behavior simultaneously. With a compact nervous system, the transparent nematode Caenorhabditis elegans is a good candidate for whole-brain imaging and investigating the neural representation of behaviors. The analysis of calcium imaging recordings relies on computer algorithms for identifying and tracking neurons in recorded videos. In this work, we provided a series of methodological advances for analyzing recordings of neural activity. We developed new algorithms for identifying neurons and straightening heads. We showed that the new algorithm detected more neurons and prevented artifacts that can occur during the straightening step. Identifying correspondence between constellations of neurons is essential for both tracking neurons within an animal and resolving neuronal identities across animals. We proposed a deep learning model, fDNC, for finding neural correspondence in C. elegans. The fDNC model finds neural correspondence within and across individuals with an accuracy that is comparable or compares favorably to other methods but does so much more quickly. Using the new algorithms above for analyzing whole-brain imaging recordings, we studied neural activity and behaviors in different contexts. We explored the neural representation of the animal's velocity and body curvature and showed that they could be decoded from a linear combination of neural activity during spontaneous motion. With the neuronal identities, we further presented preliminary results of a uniform neural decoder of behavior across different animals. In addition, we investigated the behavior of C. elegans in mating-related context. Our results implied that males adjusted their navigation strategies in response to the odor of hermaphrodite. We identified candidate neurons that represent the odor stimulus pattern and behavioral responses.