DEFCoN-ImageJ¶
An ImageJ plugin for DEFCoN, the fluorescence spot counter based on fully convolutional neural networks
Instructions¶
Contents
Installation¶
You will need a trained DEFCoN network model to use the plugin regardless of the installation procedure that you choose to follow. These may be downloaded from the DEFCoN-ImageJ Wiki.
Fiji/ImageJ update site¶
- Make a backup of your Fiji folder. (This is always a good idea before adding an update site.
- Open Fiji and navigate to Help > Update…. Install any updates and restart Fiji if necessary.
- In the ImageJ Update dialog, click the Manage update sites button, scroll to the bottom of the list, and add http://sites.imagej.net/Kmdouglass under the URL column. You may give it any name you want, such as LEB-EPFL.
- Install all the updates and restart Fiji.
- Verify that the plugin is recognized by clicking Plugins on the menu bar and looking for DEFCoN.
Manual installation¶
- Download the latest DEFCoN-ImageJ .jar and dependencies from the GitHub releases.
- Place the DEFCoN-ImageJ .jar file inside your <ImageJ_Root>/plugins folder. Unzip the dependencies into the <ImageJ_Root>/jars folder.
- Verify that the plugin is recognized by opening ImageJ/Fiji by clicking Plugins on the menu bar and looking for DEFCoN.
Using DEFCoN¶
DEFCoN provides two kinds of networks for spot counting. They are called
- density map
- maximum local count
The density map network produces a density map estimate from an image. The sum of the pixel values in a region of the density map is equal to the estimated number of fluorescent spots within that region.

The maximum local count network first computes the sum of the pixels in all possible subregions of the density map. It returns the single largest value of all these sums. In effect, it reports the highest local density of spots across an entire image. (The original maximum count network available on the DEFCoN-ImageJ wiki uses 7x7 pixels subregions.)

The ImageJ GUI¶
- Open an image or image stack or select a currently open image/stack.
- Navigate to Plugins > DEFCoN > Density map… on the menu bar.
- A dialog will appear asking for you to enter the name of a folder. This folder should contain a saved TensorFlow model of a DEFCoN density map network. (The dialog will remember the previous path that was used, meaning you will not have to reenter this path every time you wish to use DEFCoN.)
- Click OK to start processing.
To compute the maximum local count, repeat these steps but select Plugins > DEFCoN > Maximum local count… instead. In the dialog, select a folder containing a saved maximum local count network.
ImageJ macros¶
The macro panel may be accessed through the menu bar by navigating to Plugins > New > Macro.
The macros for running the counting network and maximum local count network are:
run("Density map...","load=/path/to/density/network");
run("Maximum local count...", "load=/path/to/max/count/network");
Training your own DEFCoN networks¶
Information on training your own DEFCoN network may be found at the DEFCoN project page. DEFCoN will usually perform best when trained on data that closesly matches your particular use case.
Javadoc¶
ch.epfl.leb.defcon.ij¶
DensityCount¶
-
public class
DensityCount
implements PlugInFilter¶ Computes a density map estimate for counting objects within an image.
Author: Baptiste Ottino
Methods¶
run¶
-
public void
run
(ImageProcessor ip)¶ Computes a density map from the selected image stack. A results table that indicates the count is displayed in addition to the density map image.
Parameters: - ip – The input image processor.
setup¶
-
public int
setup
(String pathToModel, ImagePlus imp)¶ Sets up the PlugInFilter.
Parameters: - pathToModel – The path to a saved TensorFlow model bundle.
- imp – The currently active image.
Returns: A flag indicating which types of images this plugin handles.
See also: PlugInFilter
MaxCountFCN¶
-
public class
MaxCountFCN
extends AbstractPredictor implements PlugInFilter¶
Methods¶
setup¶
-
public int
setup
(String pathToModel, ImagePlus imp)¶ Sets up the PlugInFilter. Please see for more information on the PlugInFilter API.
Parameters: - pathToModel – The path to a saved TensorFlow model bundle.
- imp – The currently active image.
Returns: A flag indicating which types of images this plugin handles.
See also: PlugInFilter
ch.epfl.leb.defcon.ij.gui¶
ch.epfl.leb.defcon.predictors¶
ImageBitDepthException¶
NoLocalCountMapException¶
Predictor¶
-
public interface
Predictor
¶ Makes density map predictions from images.
Author: Kyle M. Douglass
Methods¶
getCount¶
-
public double
getCount
()¶ Returns the most recent count.
Throws: Returns: The predicted count from the density map.
getDensityMap¶
-
public FloatProcessor
getDensityMap
()¶ Returns the most recently calculated density map prediction.
Throws: Returns: The predicted density map.
getLocalCountMap¶
-
public FloatProcessor
getLocalCountMap
()¶ Returns the most recently-calculated local count map.
Throws: Returns: The most recently calculated local count map.
getMaximumLocalCount¶
-
public double
getMaximumLocalCount
(int boxSize)¶ Returns the maximum local count value. This value is obtained by convolving the density map with a square kernel whose values are all 1 and then taking the maximum of the resulting map. It effectively produces the highest count value over length scales equal to the size of the kernel.
Parameters: - boxSize – The width of the square kernel.
Throws: Returns: The maximum local count from the density map.
SessionClosedException¶
ch.epfl.leb.defcon.predictors.internal¶
AbstractPredictor¶
-
public abstract class
AbstractPredictor
¶ A base implementation for DEFCoN predictors. A predictor is a class that takes an image(s) as input and estimates a density map of object locations from it.
Author: Kyle M. Douglass
Fields¶
DefaultPredictor¶
-
public class
DefaultPredictor
extends AbstractPredictor implements Predictor¶ Makes density map predictions from images.
Author: Baptiste Ottino, Kyle M. Douglass
Methods¶
finalize¶
-
protected void
finalize
()¶ Failsafe in case the TensorFlow session has not been closed.
Throws:
getCount¶
-
public double
getCount
()¶ Returns the most recent count.
Throws: Returns: The predicted count from the density map.
getDensityMap¶
-
public FloatProcessor
getDensityMap
()¶ Returns the most recently calculated density map prediction.
Throws: Returns: The predicted density map.
getLocalCountMap¶
-
public FloatProcessor
getLocalCountMap
()¶ Returns the most recently-calculated local count map.
Throws: Returns: The most recently calculated local count map.
getMaximumLocalCount¶
-
public double
getMaximumLocalCount
(int boxSize)¶ Returns the maximum local count value. This value is obtained by convolving the density map with a square kernel whose values are all 1 and then taking the maximum of the resulting map. It effectively produces the highest count value over length scales equal to the size of the kernel.
Parameters: - boxSize – The width of the square kernel.
Throws: Returns: The maximum local count from the density map.
DefaultPredictorIT¶
-
public class
DefaultPredictorIT
¶ Integration tests for the DefaultPredictor class.
Author: Kyle M. Douglass
Methods¶
testGetDensityMap¶
-
public void
testGetDensityMap
()¶ Test of getDensityMap method, of class DefaultPredictor.
testGetDensityMapResized¶
-
public void
testGetDensityMapResized
()¶ Test of getDensityMap method, of class DefaultPredictor. This test verifies that images whose dimensions are not multiples of four are automatically cropped before computing the density map.
testGetLocalCountMap¶
-
public void
testGetLocalCountMap
()¶ Test of getLocalCountMap, of class DefaultPredictor.
Throws:
ch.epfl.leb.defcon.utils¶
GraphBuilder¶
-
public class
GraphBuilder
¶ Appends various operations to TensorFlow graphs.
Author: Baptiste Ottino See also: Output | TensorFlow, Graph | TensorFlow
Methods¶
constant¶
-
public static <T> Output<T>
constant
(Graph g, String name, Object value, Class<T> type)¶ Builds an Output tensor with a single scalar value.
Parameters: - <T> –
- g – The TensorFlow graph to modify.
- name – The full name of the operation.
- value – The value output by the operation.
- type – The output datatype.
Returns: Symbolic handle to the tensor produced by the appended operation.
constant¶
-
public static Output<Integer>
constant
(Graph g, String name, int value)¶ Builds an Output tensor with a single scalar value.
Parameters: - g – The TensorFlow graph to modify.
- name – The full name of the operation.
- value – The value output by the operation.
Returns: Symbolic handle to the tensor produced by the appended operation.
expandDims¶
-
public static <T> Output<T>
expandDims
(Graph g, String name, Output<T> input, Output<Integer> dim)¶ Adds a dimension to a TensorFlow Output tensor. The dimension as added at the position “dim.” (with numpy/tensorflow syntax: 0 for the first position, -1 in the end)
Parameters: - <T> –
- g – The TensorFlow graph to modify.
- name – The full name of the operation.
- input – The input operation to expand.
- dim –
Returns: Symbolic handle to the tensor produced by the appended operation.
This is the ImageJ plugin for the density estimation by fully convolutional networks (DEFCoN) algorithm, an image processing tool for fluorescence spot counting. With this plugin, you can use trained DEFCoN models directly on images from within ImageJ.
Authors¶
See also¶
- DEFCoN-ImageJ Wiki - Download site for pre-trained DEFCoN models
- DEFCoN - Software for training a DEFCoN model
- ALICA - Automated laser illumination control for Micro-Manager
- SASS - SMLM acquistion simulation software