This repository is associated to the paper "A curious formulation robot enables the discovery of a novel protocell behavior" by Grizou, J., Points, L. J., Sharma, A. & Cronin, L. (2020) [PDF in Open Access @ Science Advances]. An overview of the scientific approach can be found at https://jgrizou.com/projects/chemobot.
Code used to run closed-loop droplet experiments using the curiosity (and other) algorithms.
The principles are described in details in the Supportng Information of the paper section 2.1.3 starting p83. The guiding principles are as follow:
Each experimental run requires three distinct steps, each feeding data to the next one in an iterative way:
Perform experiments on the droplet system. This task is given to the Dropfactory platform. Dropfactory has only one role, it looks for experiments (in the form of a params.json file) to run in a specific folder and executes them. It then saves a video of the experiment as a video.avi file and an information file in the form of a run_info.json file with time, temperature and humidity information. This process is operated by the realworld_experiments/dropfactory_watch_folder.py script in this repository.
Analyse the results of the experiments. This task is given to a specific, standalone and independent software running in its own thread. This process looks for droplet videos (in the form of video.avi files) in a specific folder (typically generated by the platform once an experiment is finalized) and process the file in three steps. It first extract frame by frame the contour of each droplets, then attempt to stitch together the droplet in each frame as time sequences and finally computes a bunch of metrics about the droplet motion in the form of a features.json file. See section 2.1.5 title “Droplet Tracking” of the SI and https://github.com/croningp/chemobot_tools. This process is operated by the realworld_experiments/vision_watch_folder.py script in this repository.
Decide on what experiment to do next. This task is given to a specific, standalone and independent software running in its own thread. This process looks for droplet features files (typically generated by the video droplet tracking in the form of a features.jsonfile) and an experimental parameter files in a specific folder. It gathers all this information and, depending on the algorithm selected, output a new experimental file (params.jsonfile) for the platform to execute. This process is operated by the explauto_watch_folder.py script in this repository.
Top-level scripts used to start experiments on the platform:
- create_xp.py is the script used to create a folder with a configuration file representing an exeprimental run. This configuration file will contains the random seed, the algorithm type and parameters, as well as the number and configuration of droplet experiments.
- realworld_experiments/dropfactory_watch_folder.py is the script that watch a folder for new droplet experiments (from the algorithm) and send them to the Dropfactory platform, which will output a video of the experiments.
- realworld_experiments/vision_watch_folder.py is the script that watch a folder for new droplet videos (from the Dropfacotry platform) and send them to the droplet tracking software, which will ouput metrics about the droplet motion.
- explauto_watch_folder.py is the script that watch a folder for new experimental observation (from the droplet tracking) and send them to the algorithm as new data, which will output a new droplet experiment parameters to be run on the Dropfactory platform.
An early practical guide to launch and monitor experiments is also available in the protocol release. It might be slighlty out of date but will point in the right direction with guiding principles.
- datasets folder contains data from previous work used to develop the code architecture and for debugging. When developping or debugging, the datasets are used to train a model that is used instead of running experiments on the Dropfacotry platform.
- explauto_tools folder holds the code interfacing our work with the explauto library, for examples to define an environment, setup an experiment and run the selected algortihm to generate the next experiments.
- models folder holds the regression methods used to generate a model from the data stored in the datasets folder. The model is used to speed up developping and debugging by bypassing the robotic platform.
- realworld_experiments folder is where real droplet experiments performed on the platform are geenrated and stored.
- simulated_experiments folder is where experiments are simulated using the model for developing and debugging, it is a simple way to test the code without having access to the robot.
- tune_explauto_parameters folder was used to select the best parameters for the various algorithms by running experiments against our model.
- utils contains a set of python tools useful for this work. Among them is utils/watcher.py that monitor folder to check for new data (e.g. a new droplet video) and the utils/xp_utils.py that contains tools to generate, monitor and extract experimental results in the correct location.
The robotic platform hardware and code is described at https://github.com/croningp/dropfactory
The code to analyse the experiments and reproduce the plots in the paper and SI are available at https://github.com/croningp/dropfactory_analysis
The droplet tracking code is available at https://github.com/croningp/chemobot_tools
This code has been tested under Python 2.7.6 on Ubuntu 14.04 LTS. Despite all our efforts, we cannot guarantee everything will be executable on other OS or Python version.
Aside from the standard libraries, we are using the following libraries. You do not have to install them all, it depends on the task you are performing.
opencv: Image analysis with python binding. Version: cv2.version is '2.4.8'
numpy: Scientific computing in Python. Version: numpy.version is '1.10.4'
scipy: More scientific computing in Python. Version: scipy.version is '0.16.1'
sklearn: Machine Learning in Python. Version: sklearn.version is '0.19.1'
filetools is a simple file management library
dropfactory should be installed and placed at the same level as the repository