Whole-brain dynamics underlying spontaneous behavior in C. elegans