Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed Sep 12, 2021
0 parents commit ff2042c
Show file tree
Hide file tree
Showing 18 changed files with 1,504 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Maven ##
/target/

## Eclipse ##
/.classpath
/.project
/.settings/

## Interactive tests ##
/samples/

## IntelliJ
/.idea/
*.iml
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
TrackMate-clij2
===============

A [clij2](https://clij.github.io) plugin for [TrackMate](https://imagej.net/plugins/trackmate/).

![img.png](docs/trackmate_clij2_screenhot.png)

This plugin was inspired by [TrackMate-Examples](https://github.com/fiji/TrackMate-examples), [TrackMate-MorpholibJ](https://github.com/tinevez/TrackMate-MorphoLibJ) and [TrackMate-StarDist](https://github.com/tinevez/TrackMate-StarDist)
and this [preprint by Dimitry Ershov](https://www.biorxiv.org/content/10.1101/2021.09.03.458852v1.full).

# Installation

* Download and install [Fiji](https://fiji.sc/Downloads)
* Install [clij](https://clij.github.io/clij2-docs/installationInFiji)

# Usage

* Open a dataset and start TrackMate from the `Plugins > Tracking` menu.
* In the 2nd step (Select Detector), choose `CLIJ2 Voronoi Otsu Labeling`.

![img.png](docs/choose_clij2.png)

* When configuring the detector, enter `spot-sigma` to fine-tune how close objects can be and `outline_sigma` to control how precise outlines are.
Read more in the [Voronoi-Otsu-Labeling tutorial]

![img.png](docs/config_detector.png)

* Wait a moment :-)

![img.png](docs/wait_detection.png)

* In further processing, it is recommended to filter detected spots by their area.

![img.png](docs/filter_spots_by_area.png)

* Therefore, it might be helpful to change the visualization by adapting the maximum shown area. This makes objects better visible that stick to each other.

![img.png](docs/visualize_area.png)

* For tracking, the overlap tracker is recommended.

![img.png](docs/choose_overlap_tracker.png)

* For visualization, select 'Show tracks local in time'.
![img_1.png](docs/visualize_spots_int_time.png)

## Feedback and support
CLIJ is developed in the open because we believe in the open source community.
See our [community guidelines](https://clij.github.io/clij2-docs/community_guidelines).
Feel free to drop feedback or ask questions via [image.sc](https://image.sc).

[Imprint](https://clij.github.io/imprint)
Binary file added docs/choose_clij2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/choose_overlap_tracker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/config_detector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/filter_spots_by_area.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/trackmate_clij2_screenhot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/visualize_area.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/visualize_spots_int_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/wait_detection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn clean -DskipTests=true install -Dgpg.skip
674 changes: 674 additions & 0 deletions license.txt

Large diffs are not rendered by default.

130 changes: 130 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>net.haesleinhuepf</groupId>
<artifactId>clij-parent-pom</artifactId>
<version>2.5.1.1</version>
<relativePath />
</parent>

<groupId>net.haesleinhuepf</groupId>
<artifactId>TrackMate_clij2</artifactId>
<version>2.5.1.1</version>

<name>TrackMate clij2 bridge</name>
<description>A clij2 detector plugin for TrackMate</description>
<url>https://imagej.net/TrackMate_examples</url>
<inceptionYear>2014</inceptionYear>
<organization>
<name>Fiji</name>
<url>https://fiji.sc/</url>
</organization>
<licenses>
<license>
<name>GNU General Public License v3+</name>
<url>https://www.gnu.org/licenses/gpl.html</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<id>haesleinhuepf</id>
<name>Robert Haase</name>
<url>https://haesleinhuepf.net</url>
<organization>DFG Cluster of Excellence Physics of Life, TU Dresden</organization>
<roles>
<role>founder</role>
<role>lead</role>
<role>developer</role>
<role>debugger</role>
<role>reviewer</role>
<role>support</role>
<role>maintainer</role>
</roles>
</developer>
</developers>
<contributors>
<contributor>
<name>none</name>
</contributor>
</contributors>

<mailingLists>
<mailingList>
<name>Image.sc Forum</name>
<archive>https://forum.image.sc/tags/fiji</archive>
</mailingList>
</mailingLists>

<scm>
<connection>scm:git:git://github.com/clij/TrackMate-clij2</connection>
<developerConnection>scm:git:git@github.com:clij/TrackMate-clij2</developerConnection>
<tag>HEAD</tag>
<url>scm:git:git@github.com:clij/TrackMate-clij2</url>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>scm:git:git@github.com:clij/TrackMate-clij2/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/clij/TrackMate-clij2/actions</url>
</ciManagement>

<properties>
<package-name>net.haesleinhuepf</package-name>
<license.licenseName>bsd_3</license.licenseName>
<license.copyrightOwners>Robert Haase, MPI CBG</license.copyrightOwners>
<scijava.app.directory>C:/programs/fiji-win64/Fiji.app/</scijava.app.directory>
</properties>

<repositories>
<repository>
<id>scijava.public</id>
<url>https://maven.scijava.org/content/groups/public</url>
</repository>
</repositories>

<dependencies>
<!-- Fiji dependencies -->
<dependency>
<groupId>sc.fiji</groupId>
<artifactId>TrackMate</artifactId>
<version>7.0.3</version>
</dependency>

<!-- ImageJ dependencies -->
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej-common</artifactId>
</dependency>

<!-- ImgLib2 dependencies -->
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2</artifactId>
</dependency>

<!-- SciJava dependencies -->
<dependency>
<groupId>org.scijava</groupId>
<artifactId>scijava-common</artifactId>
</dependency>

<!-- CLIJ dependencies -->
<dependency>
<groupId>net.haesleinhuepf</groupId>
<artifactId>clij2_</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package plugin.trackmate.clij2;

import java.util.ArrayList;
import java.util.List;

import fiji.plugin.trackmate.util.TMUtils;
import ij.ImagePlus;
import net.haesleinhuepf.clij.clearcl.ClearCLBuffer;
import net.haesleinhuepf.clij2.CLIJ2;
import net.imagej.ImgPlus;
import net.imglib2.Interval;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import fiji.plugin.trackmate.Spot;
import fiji.plugin.trackmate.detection.SpotDetector;
import fiji.plugin.trackmate.detection.LabelImageDetector;


public class CLIJ2VoronoiOtsuLabelingDetector< T extends RealType< T > & NativeType< T >> implements SpotDetector< T >
{
private final static String BASE_ERROR_MESSAGE = "CLIJ2 Voronoi-Otsu-Labeling Detector: ";

protected final Interval interval;

/** The frame we operate in. */
private final int frame;
private final double outline_sigma;
private final double spot_sigma;
private final ImgPlus<T> img;

/** Holder for the results of detection. */
private List< Spot > spots;

/** Error message holder. */
private String errorMessage;

/** Holder for the processing time. */
private long processingTime;

/*
* CONSTRUCTOR
*/

public CLIJ2VoronoiOtsuLabelingDetector(final ImgPlus< T > img, final Interval interval, double spot_sigma, double outline_sigma, final int frame )
{
this.img = img;

// Take the ROI box from the interval parameter.
this.interval = interval;

this.spot_sigma = spot_sigma;
this.outline_sigma = outline_sigma;

// We need to know what frame we are in.
this.frame = frame;
}

/*
* METHODS
*/

@Override
public List< Spot > getResult()
{
return spots;
}

@Override
public boolean checkInput()
{
if ( null == img )
{
errorMessage = BASE_ERROR_MESSAGE + "Image is null.";
return false;
}
return true;
}

@Override
public boolean process()
{
final long start = System.currentTimeMillis();

final ImagePlus tmp = ImageJFunctions.wrap( img, "tmpwrapped" );

CLIJ2 clij2 = CLIJ2.getInstance();

ClearCLBuffer input_image = clij2.push(tmp);
ClearCLBuffer output_labels = clij2.create_like(input_image);

clij2.voronoiOtsuLabeling(input_image, output_labels, spot_sigma, outline_sigma);

RandomAccessibleInterval labelImage = clij2.pullRAI(output_labels);

output_labels.close();
input_image.close();

final double[] calibration = TMUtils.getSpatialCalibration( img );
boolean simplify = false;

final LabelImageDetector< T > lbldetector = new LabelImageDetector<T>( labelImage, interval, calibration, simplify );
if ( !lbldetector.checkInput() || !lbldetector.process() )
{
errorMessage = BASE_ERROR_MESSAGE + lbldetector.getErrorMessage();
return false;
}
spots = lbldetector.getResult();

final long end = System.currentTimeMillis();
this.processingTime = end - start;
return true;
}



@Override
public String getErrorMessage()
{
/*
* If something wrong happens while you #checkInput() or #process(),
* state it in the errorMessage field.
*/
return errorMessage;
}

@Override
public long getProcessingTime()
{
return processingTime;
}

}
Loading

0 comments on commit ff2042c

Please sign in to comment.