WormsPy is a software for controlling an open source tracking fluorescence microscope. It is designed to utilize two cameras, shifted to different wavelengths to allow simultaneous tracking and behavioural measurements with epifluorescence imaging. The dual recording approach using the same light path allows the user to align the images in post and make inferences about how neural activity affects behaviour and how the animal’s interactions with its environment affect neural activity. While WormsPy was developed for calcium imaging in head sensory and interneurons in C. elegans, its modular design and low cost allows it to be iterated on by other researchers and find applications in new fields.
Example of a worm expressing pansensory GCaMP being tracked using WormsPy

Example behavioural analysis of headbending correlated with compartmentalized calcium activity in nrD and nrV in the RIA interneuron.

Frame-synced recordings and stage position allow for sophisticated offline analysis

Example with various drosophila larvae expressing jGCaMP8f in muscle tissue courtesy of the Ohyama lab at McGill.

WormsPy was designed for calcium imaging in head sensory and interneurons in C. elegans. However, many applications are possible by changing the filter sets and objectives and with some slight tweaks to the software. The basic design of WormsPy includes:
See the demonstration video here: https://youtu.be/mhyYDpziSE8
For a full build guide please see our publication: https://www.biorxiv.org/content/10.1101/2025.03.21.644605v1
Minimum requirements to use WormSpy:
conda initconda create --name wormspy python=3.8.15conda activate wormspypip install -r requirements.txtWormsPy/backend/code/app.py and adjust COM ports as well as other settings as neededlocalhost:5000More information for those interested in adapting WormSpy for their use case.
The frontend of WormsPy was developed using Angular (HTML/SCSS/TS). To make adjustments the frontend, the installation of NodeJs is required. Run npm install in the wormspy folder after initially downloading the files. Adjustments to the frontend can be made in the live-feed component found in wormspy/src/app/live-feed.
To continue using flask as a web server and maintain StartWormSpy.bat as an easy launch option, follow these steps:
ng build --configuration production --deploy-url static/ to create new production files in the wormspy/dist folder.index.html file into the production/template folder.production/static folder. Ignore assets unless those have been updated.
WormSpy uses a Python Flask web server (app.py) to communicate with the frontend. A combination of the OpenCV and EasyPySpin libraries are used to communicate with the cameras. The Zaber Motion ASCII library is used to control the Zaber motors via the Zaber_messenger_router(), which is why the Zaberlauncher application must be open for WormsPy to work. There is an optional DeepLabCut (DLC) Live tracking option available. To activate, uncomment the code that loads in the pretrained model in lines #87-92.
If you would like to train and use your own DLC model, place your model in the DLC_models folder and replace the skeleton folder in the DLCLive function of the video_feed method.
For more detailed programmatical information about WormSpy, refer to the inline comments found in app.py.
WormSpy was developed by Sebastian Wittekindt and Lennard Wittekindt at McGill University. Funded by the Canadian Institute for Health Research.
Provided as open source software under the MIT license, view the license for details.