Two research teams used micro-CT 3D X-ray scans to look at what is going on inside the cocoon and get a good look at how caterpillars transform into butterflies. They routinely scanned a chrysalis during its metamorphosis and generated 3D models of its organs and various parts to create the video we see here.
Via Gizmodo