Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

# A compressed sensing framework for efficient dissection of neural circuits

## Abstract

A fundamental question in neuroscience is how neural networks generate behavior. The lack of genetic tools and unique promoters to functionally manipulate specific neuronal subtypes makes it challenging to determine the roles of individual subtypes in behavior. We describe a compressed sensing-based framework in combination with non-specific genetic tools to infer candidate neurons controlling behaviors with fewer measurements than previously thought possible. We tested this framework by inferring interneuron subtypes regulating the speed of locomotion of the nematode Caenorhabditis elegans. We developed a real-time stabilization microscope for accurate long-term, high-magnification imaging and targeted perturbation of neural activity in freely moving animals to validate our inferences. We show that a circuit of three interconnected interneuron subtypes, RMG, AVB and SIA control different aspects of locomotion speed as the animal navigates its environment. Our work suggests that compressed sensing approaches can be used to identify key nodes in complex biological networks.

This is a preview of subscription content, access via your institution

## Access options

\$32.00

All prices are NET prices.

## Data availability

The data that support the findings presented in this study are available from the corresponding authors upon reasonable request.

## References

1. Trent, C., Tsuing, N. & Horvitz, H. R. Egg-laying defective mutants of the nematode Caenorhabditis elegans. Genetics 104, 619–647 (1983).

2. Beverly, M., Anbil, S. & Sengupta, P. Degeneracy and neuromodulation among thermosensory neurons contribute to robust thermosensory behaviors in Caenorhabditis elegans. J. Neurosci. 31, 11718–11727 (2011).

3. Luo, L. et al. Bidirectional thermotaxis in Caenorhabditis elegans is mediated by distinct sensorimotor strategies driven by the AFD thermosensory neurons. Proc. Natl Acad. Sci. USA 111, 2776–2781 (2014).

4. Zimmer, M. et al. Neurons detect increases and decreases in oxygen levels using distinct guanylate cyclases. Neuron 61, 865–879 (2009).

5. Zaslaver, A. et al. Hierarchical sparse coding in the sensory system of Caenorhabditis elegans. Proc. Natl Acad. Sci. USA 112, 1185–1189 (2015).

6. White, J. Q. & Jorgensen, E. M. Sensation in a single neuron pair represses male behavior in hermaphrodites. Neuron 75, 593–600 (2012).

7. Tran, D. H., Meissner, G. W., French, R. L. & Baker, B. S. A small subset of fruitless subesophageal neurons modulate early courtship in Drosophila. PLoS ONE 9, e95472 (2014).

8. Huang, K.-H., Ahrens, M. B., Dunn, T. W. & Engert, F. Spinal projection neurons control turning behaviors in zebrafish. Curr. Biol. 23, 1566–1573 (2013).

9. Capelli, P., Pivetta, C., Soledad Esposito, M. & Arber, S. Locomotor speed control circuits in the caudal brainstem. Nature 551, 373–377 (2017).

10. Milo, R. et al. Network motifs: simple building blocks of complex networks. Science 298, 824–827 (2002).

11. Gray, J. M., Hill, J. J. & Bargmann, C. I. A circuit for navigation in Caenorhabditis elegans. Proc. Natl Acad. Sci. USA 102, 3184–3191 (2005).

12. Hobert, O., Glenwinkel, L. & White, J. Revisiting neuronal cell type classification in Caenorhabditis elegans. Curr. Biol. 26, R1197–R1203 (2016).

13. Hawrylycz, M. J. et al. An anatomically comprehensive atlas of the adult human brain transcriptome. Nature 489, 391–399 (2012).

14. Lein, E. S. et al. Genome-wide atlas of gene expression in the adult mouse brain. Nature 445, 168–176 (2007).

15. Murphey, D. K., Herman, A. M. & Arenkiel, B. R. Dissecting inhibitory brain circuits with genetically-targeted technologies. Front. Neural Circuits 8, 124 (2014).

16. Candès, E. J., Romberg, J. K. & Tao, T. Stable signal recovery from incomplete and inaccurate measurements. Commun. Pure Appl. Math. 59, 1207–1223 (2006).

17. Donoho, D. L. Compressed sensing. IEEE Trans. Inf. Theory 52, 1289–1306 (2006).

18. Lustig, M., Donoho, D. L., Santos, J. M. & Pauly, J. M. Compressed sensing MRI. IEEE Signal Process. Mag. 25, 72–82 (2008).

19. Satat, G., Tancik, M. & Raskar, R. Lensless Imaging With Compressive Ultrafast Sensing. IEEE Trans. Comput. Imaging 3, 398–407 (2017).

20. Shental, N., Amir, A. & Zuk, O. Identification of rare alleles and their carriers using compressed se(que)nsing. Nucleic Acids Res. 38, e179 (2010).

21. Amir, A. & Zuk, O. Bacterial community reconstruction using compressed sensing. J. Comput. Biol. 18, 1723–1741 (2011).

22. Candes, E. J. & Wakin, M. B. An introduction to compressive sampling. IEEE Signal Process. Mag. 25, 21–30 (2008).

23. Candes, E. J. & Tao, T. Decoding by linear programming. IEEE Trans. Inf. Theory 51, 4203–4215 (2005).

24. White, J. G., Southgate, E., Thomson, J. N. & Brenner, S. The structure of the nervous system of the nematode Caenorhabditis elegans. Phil. Trans. R. Soc. Lond. B 314, 1–340 (1986).

25. Xu, M. et al. Computer assisted assembly of connectomes from electron micrographs: application to Caenorhabditis elegans. PLoS ONE 8, e54050 (2013).

26. Edwards, S. L. et al. A novel molecular solution for ultraviolet light detection in Caenorhabditis elegans. PLoS Biol. 6, e198 (2008).

27. Chow, B. Y. et al. High-performance genetically targetable optical neural silencing by light-driven proton pumps. Nature 463, 98–102 (2010).

28. Husson, S. J. et al. Microbial light-activatable proton pumps as neuronal inhibitors to functionally dissect neuronal networks in C. elegans. PLoS ONE 7, e40937 (2012).

29. Tibshirani, R. Regression shrinkage and selection via the lasso: a retrospective. J. R. Stat. Soc. Series B Stat. Methodol. 73, 273–282 (2011).

30. Tibshirani, R. Regression Shrinkage and Selection via the Lasso. J. R. Stat. Soc. Series B Stat. Methodol. 58, 267–288 (1996).

31. Hu, T. & Chklovskii, D.B. Reconstruction of Sparse Circuits Using Multi-neuronal Excitation (RESCUME). Adv. Neural Inf. Process. Syst. NIPS 22, (2009).

32. Thrampoulidis, C., Abbasi, E. & Hassibi, B. in Advances in Neural Information Processing Systems 28 (eds. Cortes, C., Lawrence, N. D., Lee, D. D., Sugiyama, M. & Garnett, R.) 3420–3428 (Curran Associates, 2015).

33. Shipley, F. B., Clark, C. M., Alkema, M. J. & Leifer, A. M. Simultaneous optogenetic manipulation and calcium imaging in freely moving C. elegans. Front. Neural Circuits 8, 28 (2014).

34. Piggott, B. J., Liu, J., Feng, Z., Wescott, S. A. & Xu, X. Z. S. The neural circuits and synaptic mechanisms underlying motor initiation in C. elegans. Cell 147, 922–933 (2011).

35. Nguyen, J. P. et al. Whole-brain calcium imaging with cellular resolution in freely behaving Caenorhabditis elegans. Proc. Natl Acad. Sci. USA 113, E1074–E1081 (2016).

36. Faumont, S. et al. An image-free opto-mechanical system for creating virtual environments and imaging neuronal activity in freely moving Caenorhabditis elegans. PLoS ONE 6, e24666 (2011).

37. Chen, T.-W. et al. Ultrasensitive fluorescent proteins for imaging neuronal activity. Nature 499, 295–300 (2013).

38. Jazayeri, M. & Afraz, A. Navigating the neural space in search of the neural code. Neuron 93, 1003–1014 (2017).

39. Li, Z., Liu, J., Zheng, M. & Xu, X. Z. S. Encoding of both analog- and digital-like behavioral outputs by one C. elegans interneuron. Cell 159, 751–765 (2014).

40. Kawano, T. et al. An imbalancing act: gap junctions reduce the backward motor circuit activity to bias C. elegans for forward locomotion. Neuron 72, 572–586 (2011).

41. Chalfie, M. et al. The neural circuit for touch sensitivity in Caenorhabditis elegans. J. Neurosci. 5, 956–964 (1985).

42. Roberts, W. M. et al. A stochastic neuronal model predicts random search behaviors at multiple spatial scales in C. elegans. eLife 5, e12572 (2016).

43. Busch, K. E. et al. Tonic signaling from O2 sensors sets neural circuit activity and behavioral state. Nat. Neurosci. 15, 581–591 (2012).

44. Laurent, P. et al. Decoding a neural circuit controlling global animal state in C. elegans. eLife 4, e04241 (2015).

45. Macosko, E. Z. et al. A hub-and-spoke circuit drives pheromone attraction and social behaviour in C. elegans. Nature 458, 1171–1175 (2009).

46. Mello, C. & Fire, A. DNA transformation. Methods Cell Biol. 48, 451–482 (1995).

47. Baek, J.-H., Cosman, P., Feng, Z., Silver, J. & Schafer, W. R. Using machine vision to analyze and classify Caenorhabditis elegans behavioral phenotypes quantitatively. J. Neurosci. Methods 118, 9–21 (2002).

48. Ramot, D., Johnson, B. E. Jr, Berry, T. L. Jr, Carnell, L. & Goodman, M. B. The Parallel Worm Tracker: a platform for measuring average speed and drug-induced paralysis in nematodes. PLoS ONE 3, e2208 (2008).

49. Lecun, Y., Bottou, L., Bengio, Y. & Haffner, P. Gradient-based learning applied to document recognition. Proc. IEEE 86, 2278–2324 (1998).

50. Berg, H. C. How to track bacteria. Rev. Sci. Instrum. 42, 868–871 (1971).

51. Shin, C. W., Inokuchi, S. & Kim, K. I. Retina-like visual sensor for fast tracking and navigation robots. Mach. Vis. Appl. 10, 1–8 (1997).

52. Mao, W. Error and adjustment of reflecting prisms. Opt. Eng. 36, 3367–3372 (1997).

53. Sullivan, D. L. Alignment of rotational prisms. Appl. Opt. 11, 2028–2032 (1972).

54. David Giese, J., Ford, T. N. & Mertz, J. Fast volumetric phase-gradient imaging in thick samples. Opt. Express 22, 1152–1162 (2014).

55. Lee, J.B. et al. A compressed sensing framework for efficient dissection of neural circuits. Code Ocean https://doi.org/10.24433/CO.020095e2-4067-4d44-9ea4-30d55309dda9

56. Lee, J.B. et al. A compressed sensing framework for efficient dissection of neural circuits. Code Ocean https://doi.org/10.24433/CO.3bc0d23b-b316-474d-9ab2-076e1deac88a

## Acknowledgements

We thank N. Ringstad and members of the Ramanathan Laboratory for useful discussions and comments. This work was supported by a US National Institutes of Health (NIH) Directors Pioneer award (DP1OD008197, to S.R.) and a grant from the NIH (R01DC016058, to J.S.). We also acknowledge support from the NSF-Simons Center for Mathematical and Statistical Analysis of Biology at Harvard University, and from NSF grant number DMS-1764269, and the Harvard FAS Quantitative Biology Initiative (to S.R.). A.K. is supported by Harvard University - Koç University Visiting Scholar Program.

## Author information

Authors

### Contributions

J.B.L. designed and performed experiments, analyzed data, developed the tracking microscope, and wrote the manuscript. A.Y. generated transgenic lines, designed and performed experiments, analyzed data and performed simulations, developed the structural illumination for the microscope, and wrote the manuscript. T.H. performed and analyzed experiments. C.-H.S. generated transgenic lines, and performed and analyzed experiments. J.M. generated transgenic lines, and performed and analyzed some of the Arch inhibition experiments. J.S. supervised the annotation of the expression patterns of different promoters in the different neuronal subtypes. A.K. developed the tracking microscope, and performed and analyzed experiments. S.R. designed and supervised the project, and wrote the manuscript.

### Corresponding authors

Correspondence to Abdullah Yonar or Sharad Ramanathan.

## Ethics declarations

### Competing interests

The authors declare no competing interests.

Publisher’s note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Integrated supplementary information

### Supplementary Figure 1 Validation of neural expression patterns of C. elegans promoters through high-magnification DIC and fluorescent imaging.

All worms were imaged under a 63× objective. Scale bar corresponds to 15 µm. Neurons labeled in italics were seen in less than 20% of all worms imaged and were excluded from the final expression list for each promoter. Each transgenic line was imaged ten times to characterize expression patterns. All details regarding transgenic lines in this figure can be found in Supplementary Table 1.

### Supplementary Figure 2 Behavioral assay with optogenetic perturbations of neurons.

a, Schematics of the setup for monitoring behaviors of multiple worms under optogenetic perturbation. Animals were placed near the bacteria source and monitored for about 45 min while a group of neurons was silenced. b, Sample trajectories of four control worms from the optogenetic-behavior screen. Animals were placed 1.5 cm away from a bacterial lawn under green light, which inhibits a subset of neurons during chemotaxis. c, Two sample time series of speed and their distribution from control group and Pflp-21::Arch transgenic line. Experiments in the top and bottom panels were repeated independently with similar results 131 and 19 times, respectively, for control and Pflp-21::Arch line. d, Measured phenotype vector from behavior screen. Data are shown as mean ± s.e.m (Pdop-2: n = 17, Pflp-21: n = 19, Pnpr-4: n = 12, Podr-2b: n = 11, Psra-11: n = 8).

### Supplementary Figure 3 Speed distributions for 27 transgenic Arch lines under green light.

Speed distributions of each transgenic Arch line from the optogenetic-behavior essay (red) and control group speed distribution (blue).

### Supplementary Figure 4 Functionality of the Arch construct: promoters with no speed phenotype have other behavioral phenotypes.

a, Arrival fractions in a chemotaxis assay, normalized to control. In this chemotaxis assay, many of the lines show lower arrival fraction than the control (Pflp-19, Pflp-22, Pflp-7, Pgpa-14, Plim-6r, Pmgl-1, Pmgl-3, Pmod-1, Pmpz1-p2, Podr-2-18, Pser-2p2, Pser-2p3; red in the axis label) without showing any speed phenotype, suggesting that the optogenetic perturbations are effective in all of these different lines and affect the animals’ exploratory behavior (Pdop-2 (n = 17), Pflp-11 (n = 97), Pflp-12 (n = 8), Pflp-18 (n = 84), Pflp-19 (n = 31), Pflp-21 (n = 19), Pflp-22 (n = 53), Pflp-3 (n = 128), Pflp-4 (n = 103), Pflp-7 (n = 235), Pgpa-14 (n = 111), Pinx-4 (n = 141), Plim-6r (n = 50), Plin-11 (n = 19), Pmbr-1 (n = 98), Pmgl-1 (n = 61), Pmgl-3 (n = 148), Pmod-1 (n = 51), Pmpz1-p2 (n = 14), Pnmr-1 (n = 21), Pnpr-4 (n = 12), Podr-2-18 (n = 108), Podr-2b (n = 11), Prig-5 (n = 82), Pser-2p2 (n = 114), Pser-2p3 (n = 61), Psra-11 (n = 8) independent worms). b, Reversal rate per distance (mm), normalized to control. c, Reversal rate per time (min), normalized to control. Some lines showed changes in their reversal frequency both for per time and per distance but no change in their speed distribution. (Pflp-19, Pnmr-1, Podr-2-18, Pmod-1, Pser-2p2; red in the axis label). Dotted lines are one sigma. (Pdop-2 (n = 17), Pflp-11 (n = 2), Pflp-12 (n = 8), Pflp-18 (n = 2), Pflp-19 (n = 3), Pflp-21 (n = 19), Pflp-22 (n = 53), Pflp-3 (n = 2), Pflp-4 (n = 2), Pflp-7 (n = 7), Pgpa-14 (n = 3), Pinx-4 (n = 2), Plim-6r (n = 2), Plin-11 (n = 19), Pmbr-1 (n = 3), Pmgl-1 (n = 6), Pmgl-3 (n = 3), Pmod-1 (n = 51), Pmpz1-p2 (n = 14), Pnmr-1 (n = 21), Pnpr-4 (n = 12), Podr-2-18 (n = 3), Podr-2b (n = 11), Prig-5 (n = 2), Pser-2p2 (n = 3), Pser-2p3 (n = 3), Psra-11 (n = 8) independent experiments). a,b,c, Data are shown as mean ± s.t.d.

### Supplementary Figure 5 Lasso and L1-norm minimization identify the same set of neurons for both continuous and binarized phenotypes.

a, Neuron weights distribution for each neuron type from 10,000 L1 norm minimization solutions through bootstrapping. L1-norm minimization alone gives rise to consistent results with Lasso regression. RMG, SIA, AVB are robustly inferred as controlling speed by different methods. Centre is median. Box corresponds to 25 and 75 percentiles of the distribution. Whiskers correspond to 5 and 95 percentiles. b, Median neuron weights from Lasso regression solution with the binarized nonlinear phenotype vector $$\overrightarrow P = sgn({\boldsymbol{M}}\overrightarrow \omega )$$, where sgn(x)={−1 if x<0; 0 if x=0; 1 if x>0} based on KL divergence (Fig. 1d) for sparsity parameter spanning three orders of magnitude. c, Mean squared error $$(\chi ^2 = ({\boldsymbol{M}}\overrightarrow \omega = \overrightarrow P )^2)$$ from Lasso regression with binarized phenotype. Red arrows represent the chosen sparsity parameter for (d). d, Neuron weights for each neuron type from the Lasso regression solution with binarized phenotype vector.

### Supplementary Figure 6 Robustness of the solution to promoter removals.

a, Inferred neuron weights against sparsity parameter for example measurement matrices with different combinations of promoters removed from the original set of 27 promoters b, Average and variation of neuron weights obtained from various measurement matrices (n = 192) with up to 5 promoters removed at random from the original set of 27 promoter. Inference of AVB, RMG and SIA is robust to these perturbations. Upon removal of Pmgl-1, the solution contains AIA and decrease the weight of AVB. It is because AIA is expressed in two promoters: Pmgl-1 with no speed phenotype and Psra-11 with significant speed phenotype. Therefore, removal of Pmgl-1 introduces AIA. c, Neuron weights obtained from the measurement matrices in (b) excluding those which did not contain Pmgl-1 (n = 162). So, once Pmgl-1 and the fact that it does not show a speed phenotype is included, AIA is not contained in the sparse solution. Centre is median. Box represents 25th and 75th percentiles of the distribution. Whiskers correspond to 5th and 95th percentiles.

### Supplementary Figure 7 Robustness of the solution to promoter additions.

a, The measurement matrix with additional 5 promoters (Podr-2(16), Popt-3, Pntr-2, Psams-5, Ptdc-1) covering 90 neuron types. b, KL divergence between speed distributions of control and each Arch line. Additional 5 new lines placed to end. Blue dashed lines are 95th percentile in the control KL divergence distribution. c, Median neuron weights from 10,000 Lasso regression solutions for sparsity parameter spanning three orders of magnitude (see Methods). Red arrow indicates the sparsity parameter picked for (d). Dashed line is mean squared error $$\chi ^2 = \left( {{\boldsymbol{M}}\vec \omega - \vec P} \right)^2$$ of optimized solution for given sparsity parameters. After red arrow, mean squared error starts to diverge quickly showing that w does not satisfy $${\boldsymbol{M}}\vec \omega = \vec P$$. d, Neuron weights distribution for each neuron types from 10,000 Lasso regression solutions for sparsity parameter shown in (b). Center is median. Box represents 25th and 75th percentiles of the distribution. Whiskers correspond to 5th and 95th percentiles. The neurons are arranged in the same order as the order of columns of the measurement matrix in (a).

### Supplementary Figure 8 Robustness of the solution to Arch expression efficiency.

a, Inferred neuron identities with 1,000 corrupt measurement matrices (Methods). Each row is a different measurement matrix and each column is a neuron type. Color scale shows inferred neuron weights. b, Distribution of 1,000 solutions using corrupt matrices showing robustness of the inference of AVB, RMG and SIA. Median is red, blue box shows 25th and 75th percentiles, and whiskers are 90th percentile.

### Supplementary Figure 9 False negative and false positive rates of measurement matrices.

a,b, False negative and false positive rates of interneurons for original measurement matrix with 27 promoters covering 88 neuron types. a, Simulation with linear phenotype vector, $$\vec P = {\boldsymbol{M}}\vec \omega$$. b, Simulation with nonlinear phenotype vector, $$\vec P{\mathrm{ = }}sgn\left( {{\boldsymbol{M}}\vec \omega } \right)$$, where sgn(x)={−1 if x<0; 0 if x=0;1 if x>0}. c, False negative and false positive rates for a set of 22 promoters. d, False negative and false positive rates for the set of 32 promoters. e, False negative and false positive rates for a set of 38 promoters. 6 potential promoters from the literature are added to the set of 32 promoters based on frequently missed neurons. ae, Data are shown as mean ± s.t.d. f, Mean false negative rates for various sizes of the measurement matrix (size of promoters set) as a function of the true number of key neurons in the simulations (see Methods). False negative rates decrease as the number of promoters increases. To obtain a measurement matrix with 38 promoters for simulations, we added 6 promoters with characterized expression in the literature (Pnmur-1, Pgur-3, Pric-4, Psems-2, Pdop-4, Pglr-7) to 32 promoters.

### Supplementary Figure 10 Compressed sensing on an artificial neural network.

a, An artificial neural network that we trained for hand-written digit recognition. The network has an input layer of 784 neurons, 4 hidden layers with 100 neurons each, and an output layer of 10 neurons signaling the identity of the digits. After training, key neurons (filled red) were identified computationally from the second single hidden layer (blue box) by inhibiting one neuron at a time. b, Description of a single neuron in the network. Activation function of neurons was a nonlinear sigmoid function. c, Activation of neurons to a digit 6, a digit 7 or to random noise in hidden layer 2. The network learns sparse representation of the data with regularization on its activations during training. d, Performance (accuracy on test dataset) of single neuron (unit) inhibitions constitutes the ground truth to test a CS-based method. e, Random measurement matrix with 50 measurements, each perturbing 5 neurons at a time. f, Phenotype vector using this measurement matrix was obtained by the performance change (accuracy change in test dataset) for group inhibitions (groups defined by the rows of the measurement matrix). g, Inferred neuron weights using Lasso for a range of sparsity parameters. h, Inferred neuron weights for the sparsity parameter shown with black arrow in (g). i, False negative and false positive rates for various sizes of measurement matrices (n = 100 independently generated measurement matrices for each size). Each measurement in the ensemble of measurement matrices perturbs from 3 to 7 neurons at a time. Data are shown as mean ± s.t.d.

### Supplementary Figure 11 Image analysis for calcium imaging with z-scan.

a, Time series of z stack GCaMP6s images. b, The maximum intensity projection of the time series of z stacks plotted as a heat map. Regions of interest and segmentation corresponding to different neurons in x,y are obtained from the maximum intensity projection. Because of the image stabilization and tracking, each neuron stays localized to a specific region of interest throughout the time series (shown by the regions circled in red). In this example, we were able to spatially resolve seven different regions of interest. c, Resolving 2 neurons at different z positions. Time series of maximum pixel intensity in each slice. The different z-stacks, taken sequentially in the time series are delimited by the dashed lines. The intensity of a neuron increases towards the focused plane. In this example, there are two neurons at different z positions (annotated by black squares and open circles). d, Histogram of the position within each z-stack containing the maximum intensity pixel over all z-stacks. The positions of the two peaks within this bimodal distribution are used to set z ranges, or regions of interest in z, for each of the two neurons. Slice position 1–8 would correspond to the black square, and 9–18 would correspond to the open circle. Neurons at different z positions in the z-stack can be resolved by the maximum intensity because of the high-NA objective used (see Methods).

### Supplementary Figure 12 High-magnification fluorescent images of GFP and GCaMP6s lines.

a, AIY::GFP line used in calcium imaging calibration for the microscope in Fig. 3d,e. AWCON::mKO for tracking (left), AIY::GFP for imaging (middle), the merged image (right). b, High-magnification image of Promflp-21::GCaMP6s transgenic line for targeted illumination control experiment in Fig. 3f. AWCON::mKO (Promstr-2::mKO) for tracking (left), Promflp-21::GCaMP6s (middle), the merged image (right). c, Promnpr-4::GCaMP6s transgenic line for SIA calcium imaging. d, Promsra-11::GCaMP6s transgenic line for AVB calcium imaging. Each line was imaged 5 times, and we observed the same expression patterns.

### Supplementary Figure 13 Inhibition of RMG and reverse command interneurons.

a, RMG is solely responsible for the strong phenotype observed in the Promflp-21::Arch line. Inhibition of neurons in Promflp21::Arch results in strong slowdown on average (78%, left box; n = 19). We inhibited RMG alone in the Promflp-21::Arch line with our stabilization microscope. RMG-only inhibition resulted in a 57% (middle box; n = 68) decrease in speed. Inhibition of all other neurons in the Promflp-21::Arch line (right box; n = 24) did not result in a change of speed. bd, Inhibition of reverse command interneurons changes reversal frequency but not speed distribution. b, The promoter nmr-1 drives expression in all three backward command interneuron types (AVA, AVD and AVE). Arch inhibition of the Pnmr1::Arch line reduces reversal frequency compared with that of the control (n = 131 animals for lite-1 control, n = 21 animals for Pnmr-1 inhibition). a,b, Center is median, box represents 25th and 75th percentiles, whiskers are data range. Notch is the 95% confidence interval of the median. Two-sample, two-sided t-test. c, Inhibition of reverse command interneurons in the Pnmr-1::Arch line does not change the speed distribution of animals. d, Example trace of speed and GCAMP activity in AVA the key command interneuron controlling reversals (AVA imaging experiments were repeated five times independently with similar results). Both AVA activity and speed have characteristic features during reversals. AVA activity increases during reversal and decays to base level. The speed of the animal decreases during changes in direction but increases during reversals, as reversal is usually faster than forward motion. AVA activity does not correlate with speed. Cross-correlation analysis of speed and AVA activity for multiple animals suggests that AVA does not control speed (Fig. 4a).

### Supplementary Figure 14 Sample time series of speed and calcium activity of neurons not inferred by compressed sensing as controlling speed.

In all cases, GCaMP6s activity does not correlate with speed (see Fig. 4a). a, CEP (n = 5). b, RIM (n = 9). c, IL-2 (n = 5). d, BAG (n = 5). e, URX (n = 4). f, AIY (n = 7). g, RIB (n = 7). h, URA (n = 7). n is the number of independently repeated experiments with similar results.

### Supplementary Figure 15 Frequency dynamics of SIA, RMG and AVB.

a, Time series of SIA calcium activity (GCaMP6s) and speed data of animal shown in Fig. 4b. b, Another worm with SIA activity and speed smoothed over 1 min to show that the two signals fluctuate on this time scale. SIA imaging was repeated 9 times independently with similar results c, Autocorrelation function for RMG, AVB, SIA for all experiment (top; n = 10, n = 7, n = 9, respectively) and for experiment with pausing after pausing is removed (bottom; n = 4, n = 4, n = 5 respectively). Data are shown as mean (black line) ± s.e.m. (shaded areas). d, Cross-correlation between speed and each of the RMG, AVB and SIA replicates with low-pass filter. Each worm is shown with a different color. e, RMG activity - speed cross-correlation with different pausing lengths in the experiment (n = 10 animals; Pearson correlation). f, Normalized GCaMP activity to before and after reversals for RMG (top; n = 37 reversals) and SIA (bottom; n = 18 reversals). Data are shown as mean (solid) ± s.e.m. (dashed). g, Correlation between SIA activity of worm 1 in (a) and speed shown in red curve with different low-pass filters. For every low-pass filter, data were randomized by the block-bootstrapping method to check whether the correlation was significant. Random correlation shown in blue as mean ± s.t.d. h, Another example of SIA (worm 2 in (b)) having significant correlations for the entire low-pass filter. i, An example showing correlation between speed and GCaMP is significant for only a few of the low-pass filters. j, An example showing correlation between speed and GCaMP is not significant in either fast frequencies or low frequencies. This example also shows that a low-pass filter does not always increase the correlation.

## Supplementary information

### Supplementary Text and Figures

Supplementary Figs. 1–15 and Supplementary Notes 1 and 2

### Supplementary Table 1

Details of the transgenic Arch lines

### Supplementary Table 2

Details of the transgenic GFP and GCaMP lines

### Supplementary Table 3

Statistical information

### Supplementary Video 1

Tracking in x, y, and z.: Representative example of x, y, z tracking and AIY::GFP imaging

### Supplementary Video 2

Tracking in x, y, z and rotation.: Representative example of simulations x, y, z and rotation tracking

### Supplementary Video 3

Tracking in z by imaging a marker neuron at two z positions.: Imaging of an AWCON marker neuron at two different z planes to track the animal in z. Left, AWCON is in focus. Right, AWCON is slightly out of focus

### Supplementary Video 4

Imaging AWCON process for rotational tracking.: AWCON process imaging to track the orientation of the animal. Process of the AWCON stays vertically (left) even though the animal orients itself freely (right)

### Supplementary Video 5

Imaging multiple neurons at different z planes.: Scanning an animal with a liquid lens to image multiple neurons located at different z planes. We can image 15 planes in 1 s

### Supplementary Video 6

Targeted illumination of RMG in the Promflp-21::GFP line.: Targeted illumination of RMG in the Promflp-21::GFP line (Fig. 2f). Only the RMG (far left neuron) signal increases with light illumination (light-blue blinking disk on the upper right)

### Supplementary Video 7

SIA calcium dynamics of freely moving specimens.: SIA imaging from the Promnpr-4::GCaMP6s line animal shown in Fig. 4b. Top left, intensity of GCaMP from camera 2. Top right, trajectory of the animal. The red cross indicates the current position of the animal. Bottom left, body posture of the animal from camera 3. Bottom right, calcium intensity and speed time series. The green line indicates the current time. The maximum projections of SIA images from z scans are shown

### Supplementary Video 8

RMG calcium dynamics of freely moving specimens.: RMG imaging from the Promflp-21::GCaMP6s line animal shown in Fig. 4e. This is a representative example for drop-in RMG activity during pausing events

### Supplementary Video 9

AVB calcium dynamics of freely moving specimens.: AVB imaging from the Promsra-11::GCaMP6s line. The representative example shows AVB responding to both forward motion initiation and slower fluctuation in speed

## Rights and permissions

Reprints and Permissions

Lee, J.B., Yonar, A., Hallacy, T. et al. A compressed sensing framework for efficient dissection of neural circuits. Nat Methods 16, 126–133 (2019). https://doi.org/10.1038/s41592-018-0233-6

• Accepted:

• Published:

• Issue Date:

• DOI: https://doi.org/10.1038/s41592-018-0233-6