HFCV is a collection of deep learning models for doing image analysis tasks on microscopy images. For each model, we provide the model weights, the code to run it and an example script to show how it works on sample images. There are currently three models available - BrightQuant, LipiQuant and nucleus detection. To learn more about them, please read the accompanying blog post. In short, BrightQuant and nucleus detection are models for estimating cell counts from brightfield and Hoechst stained images, respectively. LipiQuant is a segmentation model for lipid droplets, which we use at Hoxton Farms to measure adipogenic differentiation. In order to try them out you can run the example scripts described at the bottom of the page.
We recommend running the BrightQuant model on images taken at 4X magnification, 20X for LipiQuant and 4-20X for nucleus detection. The models may generalise outside these ranges but have not been validated.
In order to run the models you will need to install the hfcv package. If you have cloned the repo you can install the package
by running the following command in the repo root:
pip install -e .
Alternatively you can download just the wheel file (located in dist/) and run
pip install path/to/package.wheel
The Python package contains the minimal dependencies required to run the models. If you additionally want to run the example scripts, there are additional dependencies:
pip install -r dev-requirements.txt
We recommend using a virtual environment when running the commands above.
There are two example scripts that show how the models work and how to run them.
This script reads in a collection of paired images, one brightfield and one Hoechst stained. It then runs the BrightQuant model on the brightfield image and the nucleus detection model on the Hoechst stained images. The output of each model is then shown (bottom) along with the raw image (top). Finally, a scatter plot of the estimated cell counts from nucleus detection and BrightQuant is plotted.
This script reads in brightfield images and then runs LipiQuant on them, one after the other. Each output is shown along with the raw image.
This script reads in pairs of brightfield and Hoechst stained images, then runs LipiQuant and nucleus detection, respectively. It then assigns each droplet to the closest nucleus and produces a labelled brightfield image, with nuclei represented by checkerboards and lipid droplets in solid colour. The colour of the lipid droplets corresponds to the assigned nucleus. By using the assign_droplets_to_nuclei function it also computes a simple metric (fraction of nuclei with total assigned droplet area above an arbitrary threshold). However, there is lots of flexibility to explore with other kinds of metrics.
