Example of implementation of a measurement module - jeanollion/bacmman GitHub Wiki
In this tutorial we will illustrate how to create a _Measurement _module for BACMMAN. We chose here to implement a method to estimate fluorescence in cells, as described in Kaiser et al. 2018. This method analyzes the fluorescence for each detected bacterium by fitting a function on a fluorescence profile that includes the bacterium and the area on its sides.
This tutorial is made for beginners in Java programming, so many basic aspects of code editing are detailed. For complete beginners we strongly recommend to follow a Java tutorial in order to get familiar with the basic notions such as types, variables, methods, arguments, class, interface etc... (for instance this one)
More advanced programmers can simply look at the code of the example of implementation.
There are several options to create a module. Either a single .java
file containing an "_" character in its name. For more complex programs containing several files, one will need a .jar
archive with a plugins.config
file listing all the module classes it contains. In this tutorial we propose to use the latter solution, which is more generic, together with Maven which allows managing dependencies.
To edit the code we strongly advise using an IDE, such as IntelliJ, Netbeans, Ecllipse... this tutorial is made with IntelliJ.
Install IntelliJ
In the IDE, create a new _Maven _project:
- File>New>Project, select Maven
- As Project SDK select 1.8.

If 1.8 is not available, it has to be installed. After installation click on the New... button on the right and select the directory of the newly installed JDK 8.
- Click Next
- Enter bacmman.modules as
groupId
and fluorescence_fit asartifactId
(identifier of the project) (we intentionally put a "_" in the name to meet imageJ's plugin requirements.)
The project contains a pom.xml file, related to Maven, which mainly contains the dependencies and information on the project.
To add BACMMAN as a dependency for the project, add the following code in this file, just before </project>
:
<dependencies>
<dependency>
<groupId>com.github.jeanollion.bacmman</groupId>
<artifactId>bacmman-core</artifactId>
<version>2.2.5</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
To download the dependency, click on enable auto import on the popup, or click on the Maven Projects button located on the right-end bar and click on the button Reimport all Maven Projects

Note: At this stage the dependency should not appear in red. If it still appears in red, it mean it was not found on the remote server, try to remove Maven cache located at ~/.m2/repository/com/github/
, at re-import from Maven
In the left panel, unfold the folders fluorescence_fit>src>main>java, right click on java and create a package named bacmman.plugins.plugins.measurements. Right-click on the package and create a java class named FluorescenceFit (note: proposed package & class name follow BAMMAN architecture but it is not necessary these names).

Copy and paste the code of the module in the newly create file (overwrite all). See the comments in the code for detailed explanations of the different parts.
- From the left panel right click on resources ( fluorescence_fit>src>main>resources) and choose New>file. Name it plugins.config
- Edit the plugins.config file and add the content of this file
- The first part is the location in the ImageJ menu
- the second part is the name of the module as it will appear in BACMMAN
- the last part is the address of the measurement we created in the form package_name.class_name
On the right click on Maven Projects, click on the button Execute Maven Goal and in the Command Line field write package. It will generate a .jar file in the target subfolder of the project.
Put the .jar
file in the plugin directory of Fiji. Restart Fiji.
Start BACMMAN and open a dataset, in the configuration tab add a new measurement (right-click on _Measurements _and choose Add Element) and select the module with the command name given in the plugins.config
file.