diff --git a/pom.xml b/pom.xml index fa5986b..ff56d56 100644 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.scijava pom-scijava - 30.0.0 + 37.0.0 ch.fmi fmi-ij2-plugins - 0.8.2-SNAPSHOT + 0.9.0-SNAPSHOT ImageJ2 plugins for use in ImageJ and KNIME A collection of plugins developed at the FMI Basel. @@ -79,8 +79,7 @@ lgpl_v3 FMI Basel - 0.0.4 - 0.1.2 + 0.7.0 sign,deploy-to-scijava @@ -132,12 +131,7 @@ sc.fiji - TrackMate_ - - - org.scijava - TrackMate_extras - ${TrackMate_extras.version} + TrackMate gov.nist.math diff --git a/src/main/java/ch/fmi/AnisotropicDistanceMap.java b/src/main/java/ch/fmi/AnisotropicDistanceMap.java index 30b72b1..251c484 100644 --- a/src/main/java/ch/fmi/AnisotropicDistanceMap.java +++ b/src/main/java/ch/fmi/AnisotropicDistanceMap.java @@ -29,8 +29,9 @@ import net.imagej.ops.Ops; import net.imagej.ops.Ops.Image.DistanceTransform; import net.imagej.ops.convert.ConvertImages; +import net.imglib2.RandomAccessibleInterval; import net.imglib2.algorithm.morphology.distance.DistanceTransform.DISTANCE_TYPE; -import net.imglib2.converter.read.ConvertedRandomAccessibleInterval; +import net.imglib2.converter.Converters; import net.imglib2.img.Img; import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.RealType; @@ -95,8 +96,8 @@ public void run() { break; case IMGLIB: FloatType type = new FloatType(); - ConvertedRandomAccessibleInterval, FloatType> conv = new ConvertedRandomAccessibleInterval<>( - input, (s, t) -> t.set(s.getRealDouble() > 0.0 ? 100000000 : 0.0f), + RandomAccessibleInterval conv = Converters.convert( + (RandomAccessibleInterval>) input, (s, t) -> t.set(s.getRealDouble() > 0.0 ? 100000000 : 0.0f), type); outImg = (Img) ops.run(Ops.Create.Img.class, conv); net.imglib2.algorithm.morphology.distance.DistanceTransform diff --git a/src/main/java/ch/fmi/SpotImageGenerator.java b/src/main/java/ch/fmi/SpotImageGenerator.java index 86e7291..9b47d6d 100644 --- a/src/main/java/ch/fmi/SpotImageGenerator.java +++ b/src/main/java/ch/fmi/SpotImageGenerator.java @@ -57,7 +57,7 @@ public class SpotImageGenerator implements Command { private Double radius; @Parameter(type = ItemIO.OUTPUT) - private ImgPlus resultImg; + private ImgPlus resultImg; @SuppressWarnings("unchecked") @Override @@ -76,7 +76,7 @@ public void run() { RandomAccessibleInterval kernel = ops.create().kernelGauss( radius * 2.0, 2); - resultImg = ImgPlus.wrap((Img) ops.filter().convolve(img, + resultImg = ImgPlus.wrap((Img) ops.filter().convolve(img, kernel)); } diff --git a/src/main/java/ch/fmi/TrackMateCollectionTracker.java b/src/main/java/ch/fmi/TrackMateCollectionTracker.java index cf926d9..2c86e15 100644 --- a/src/main/java/ch/fmi/TrackMateCollectionTracker.java +++ b/src/main/java/ch/fmi/TrackMateCollectionTracker.java @@ -21,25 +21,25 @@ */ package ch.fmi; +import java.util.ArrayList; + import com.google.common.primitives.Doubles; import com.google.common.primitives.Ints; -import java.util.ArrayList; +import org.scijava.ItemIO; +import org.scijava.command.Command; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; import fiji.plugin.trackmate.Model; import fiji.plugin.trackmate.Settings; import fiji.plugin.trackmate.Spot; import fiji.plugin.trackmate.TrackMate; import fiji.plugin.trackmate.TrackModel; -import fiji.plugin.trackmate.tracking.LAPUtils; import fiji.plugin.trackmate.tracking.TrackerKeys; -import fiji.plugin.trackmate.tracking.sparselap.SparseLAPTrackerFactory; - -import org.scijava.ItemIO; -import org.scijava.command.Command; -import org.scijava.log.LogService; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; +import fiji.plugin.trackmate.tracking.jaqaman.LAPUtils; +import fiji.plugin.trackmate.tracking.jaqaman.SparseLAPTrackerFactory; @Plugin(type = Command.class, headless = true, menuPath = "FMI>Track Spot Collection") public class TrackMateCollectionTracker implements Command { @@ -130,7 +130,7 @@ public void run() { settings.dt = frameInterval; settings.trackerFactory = new SparseLAPTrackerFactory(); - settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap(); + settings.trackerSettings = LAPUtils.getDefaultSegmentSettingsMap(); settings.trackerSettings.put(TrackerKeys.KEY_LINKING_MAX_DISTANCE, linkingMaxDistance); settings.trackerSettings.put(TrackerKeys.KEY_GAP_CLOSING_MAX_DISTANCE, diff --git a/src/main/java/ch/fmi/TrackMateSpotDetector.java b/src/main/java/ch/fmi/TrackMateSpotDetector.java index 4372d79..6f33f71 100644 --- a/src/main/java/ch/fmi/TrackMateSpotDetector.java +++ b/src/main/java/ch/fmi/TrackMateSpotDetector.java @@ -21,9 +21,18 @@ */ package ch.fmi; +import java.util.ArrayList; + import com.google.common.primitives.Doubles; import com.google.common.primitives.Ints; +import org.scijava.ItemIO; +import org.scijava.command.Command; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +import ch.fmi.trackmate.features.MaxQualitySpotAnalyzerFactory; import fiji.plugin.trackmate.Model; import fiji.plugin.trackmate.Settings; import fiji.plugin.trackmate.Spot; @@ -32,22 +41,13 @@ import fiji.plugin.trackmate.detection.DetectorKeys; import fiji.plugin.trackmate.detection.LogDetectorFactory; import fiji.plugin.trackmate.features.FeatureFilter; -import fiji.plugin.trackmate.features.spot.SpotContrastAnalyzerFactory; -import fiji.plugin.trackmate.features.spot.SpotIntensityAnalyzerFactory; -import fiji.plugin.trackmate.features.spot.SpotRadiusEstimatorFactory; +import fiji.plugin.trackmate.features.spot.SpotContrastAndSNRAnalyzerFactory; +import fiji.plugin.trackmate.features.spot.SpotIntensityMultiCAnalyzerFactory; import ij.ImagePlus; import ij.gui.Roi; import ij.plugin.filter.ThresholdToSelection; import ij.process.ImageProcessor; -import java.util.ArrayList; - -import org.scijava.ItemIO; -import org.scijava.command.Command; -import org.scijava.log.LogService; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - @Plugin(type = Command.class, headless = true, menuPath = "FMI>Spot Detection (Subpixel localization)") public class TrackMateSpotDetector implements Command { @Parameter @@ -128,8 +128,7 @@ public void run() { imp.setCalibration(null); } - Settings settings = new Settings(); - settings.setFrom(imp); + Settings settings = new Settings(imp); // TODO make detector choice optional settings.detectorFactory = new LogDetectorFactory<>(); @@ -142,9 +141,8 @@ public void run() { DetectorKeys.KEY_RADIUS, spotSize); settings.detectorSettings.put( // DetectorKeys.KEY_THRESHOLD, spotThreshold); - settings.addSpotAnalyzerFactory(new SpotIntensityAnalyzerFactory<>()); - settings.addSpotAnalyzerFactory(new SpotRadiusEstimatorFactory<>()); - settings.addSpotAnalyzerFactory(new SpotContrastAnalyzerFactory<>()); + settings.addSpotAnalyzerFactory(new SpotIntensityMultiCAnalyzerFactory<>()); + settings.addSpotAnalyzerFactory(new SpotContrastAndSNRAnalyzerFactory<>()); settings.addSpotAnalyzerFactory(new MaxQualitySpotAnalyzerFactory<>()); if (filterMaxQuality) { @@ -165,7 +163,6 @@ public void run() { ArrayList qualityList = new ArrayList<>(); ArrayList totalIntensityList = new ArrayList<>(); ArrayList meanIntensityList = new ArrayList<>(); - ArrayList estDiameterList = new ArrayList<>(); ArrayList contrastList = new ArrayList<>(); // TODO add other outputs @@ -183,15 +180,12 @@ public void run() { qualityList.add(spot.getFeature(Spot.QUALITY)); totalIntensityList .add(spot - .getFeature(SpotIntensityAnalyzerFactory.TOTAL_INTENSITY)); + .getFeature("TOTAL_INTENSITY_CH1")); meanIntensityList .add(spot - .getFeature(SpotIntensityAnalyzerFactory.MEAN_INTENSITY)); - estDiameterList - .add(spot - .getFeature(SpotRadiusEstimatorFactory.ESTIMATED_DIAMETER)); + .getFeature("MEAN_INTENSITY_CH1")); contrastList.add(spot - .getFeature(SpotContrastAnalyzerFactory.KEY)); + .getFeature("CONTRAST_CH1")); } } else { log.warn(trackmate.getErrorMessage()); @@ -207,7 +201,6 @@ public void run() { quality = Doubles.toArray(qualityList); totalIntensity = Doubles.toArray(totalIntensityList); meanIntensity = Doubles.toArray(meanIntensityList); - estDiameter = Doubles.toArray(estDiameterList); contrast = Doubles.toArray(contrastList); // Return summary values diff --git a/src/main/java/ch/fmi/TrackMateWrapper.java b/src/main/java/ch/fmi/TrackMateWrapper.java index 8f09c25..0c07f0e 100644 --- a/src/main/java/ch/fmi/TrackMateWrapper.java +++ b/src/main/java/ch/fmi/TrackMateWrapper.java @@ -21,8 +21,17 @@ */ package ch.fmi; +import java.util.ArrayList; + import com.google.common.primitives.Doubles; +import org.scijava.ItemIO; +import org.scijava.command.Command; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +import ch.fmi.trackmate.features.MaxQualitySpotAnalyzerFactory; import fiji.plugin.trackmate.FeatureModel; import fiji.plugin.trackmate.Model; import fiji.plugin.trackmate.Settings; @@ -32,26 +41,17 @@ import fiji.plugin.trackmate.detection.DetectorKeys; import fiji.plugin.trackmate.detection.LogDetectorFactory; import fiji.plugin.trackmate.features.FeatureFilter; -import fiji.plugin.trackmate.features.spot.SpotContrastAnalyzerFactory; -import fiji.plugin.trackmate.features.spot.SpotIntensityAnalyzerFactory; -import fiji.plugin.trackmate.features.spot.SpotRadiusEstimatorFactory; +import fiji.plugin.trackmate.features.spot.SpotContrastAndSNRAnalyzerFactory; +import fiji.plugin.trackmate.features.spot.SpotIntensityMultiCAnalyzerFactory; import fiji.plugin.trackmate.features.track.TrackDurationAnalyzer; -import fiji.plugin.trackmate.tracking.LAPUtils; import fiji.plugin.trackmate.tracking.TrackerKeys; -import fiji.plugin.trackmate.tracking.sparselap.SparseLAPTrackerFactory; +import fiji.plugin.trackmate.tracking.jaqaman.LAPUtils; +import fiji.plugin.trackmate.tracking.jaqaman.SparseLAPTrackerFactory; import ij.ImagePlus; import ij.gui.Roi; import ij.plugin.filter.ThresholdToSelection; import ij.process.ImageProcessor; -import java.util.ArrayList; - -import org.scijava.ItemIO; -import org.scijava.command.Command; -import org.scijava.log.LogService; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - @Plugin(type = Command.class, headless = true, menuPath = "FMI>Track Spots (Subpixel localization)") public class TrackMateWrapper implements Command { @Parameter @@ -125,9 +125,6 @@ public class TrackMateWrapper implements Command { @Parameter(type = ItemIO.OUTPUT) private double[] radius; - @Parameter(type = ItemIO.OUTPUT) - private double[] estDiameter; - @Parameter(type = ItemIO.OUTPUT) private double[] contrast; @@ -143,9 +140,8 @@ public void run() { // Create TrackMate instance with settings Model model = new Model(); - Settings settings = new Settings(); + Settings settings = new Settings(imp); - settings.setFrom(imp); settings.dt = frameInterval; settings.detectorFactory = new LogDetectorFactory<>(); @@ -164,16 +160,15 @@ public void run() { } settings.trackerFactory = new SparseLAPTrackerFactory(); - settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap(); + settings.trackerSettings = LAPUtils.getDefaultSegmentSettingsMap(); settings.trackerSettings.put(TrackerKeys.KEY_LINKING_MAX_DISTANCE, linkingMaxDistance); settings.trackerSettings.put(TrackerKeys.KEY_GAP_CLOSING_MAX_DISTANCE, closingMaxDistance); settings.trackerSettings.put(TrackerKeys.KEY_GAP_CLOSING_MAX_FRAME_GAP, frameGap); - settings.addSpotAnalyzerFactory(new SpotIntensityAnalyzerFactory<>()); - settings.addSpotAnalyzerFactory(new SpotRadiusEstimatorFactory<>()); - settings.addSpotAnalyzerFactory(new SpotContrastAnalyzerFactory<>()); + settings.addSpotAnalyzerFactory(new SpotIntensityMultiCAnalyzerFactory<>()); + settings.addSpotAnalyzerFactory(new SpotContrastAndSNRAnalyzerFactory<>()); settings.addSpotAnalyzerFactory(new MaxQualitySpotAnalyzerFactory<>()); settings.addTrackAnalyzer(new TrackDurationAnalyzer()); @@ -204,7 +199,6 @@ public void run() { ArrayList totalIntensityList = new ArrayList<>(); ArrayList meanIntensityList = new ArrayList<>(); ArrayList radiusList = new ArrayList<>(); - ArrayList diameterList = new ArrayList<>(); ArrayList contrastList = new ArrayList<>(); TrackModel trackModel = model.getTrackModel(); @@ -223,16 +217,13 @@ public void run() { zList.add(spot.getDoublePosition(2)); totalIntensityList .add(spot - .getFeature(SpotIntensityAnalyzerFactory.TOTAL_INTENSITY)); + .getFeature("TOTAL_INTENSITY_CH1")); meanIntensityList .add(spot - .getFeature(SpotIntensityAnalyzerFactory.MEAN_INTENSITY)); + .getFeature("MEAN_INTENSITY_CH1")); radiusList.add(spot.getFeature(Spot.RADIUS)); - diameterList - .add(spot - .getFeature(SpotRadiusEstimatorFactory.ESTIMATED_DIAMETER)); contrastList.add(spot - .getFeature(SpotContrastAnalyzerFactory.KEY)); + .getFeature("CONTRAST_CH1")); } } @@ -257,7 +248,6 @@ public void run() { totalIntensity = Doubles.toArray(totalIntensityList); meanIntensity = Doubles.toArray(meanIntensityList); radius = Doubles.toArray(radiusList); - estDiameter = Doubles.toArray(diameterList); contrast = Doubles.toArray(contrastList); // Return summary values diff --git a/src/main/java/ch/fmi/TrackMateWrapperMultiChannel.java b/src/main/java/ch/fmi/TrackMateWrapperMultiChannel.java index 9c2b6f6..eaef19a 100644 --- a/src/main/java/ch/fmi/TrackMateWrapperMultiChannel.java +++ b/src/main/java/ch/fmi/TrackMateWrapperMultiChannel.java @@ -21,8 +21,17 @@ */ package ch.fmi; +import java.util.ArrayList; + import com.google.common.primitives.Doubles; +import org.scijava.ItemIO; +import org.scijava.command.Command; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +import ch.fmi.trackmate.features.MaxQualitySpotAnalyzerFactory; import fiji.plugin.trackmate.FeatureModel; import fiji.plugin.trackmate.Model; import fiji.plugin.trackmate.Settings; @@ -31,28 +40,18 @@ import fiji.plugin.trackmate.TrackModel; import fiji.plugin.trackmate.detection.DetectorKeys; import fiji.plugin.trackmate.detection.LogDetectorFactory; -import fiji.plugin.trackmate.extra.spotanalyzer.SpotMultiChannelIntensityAnalyzerFactory; import fiji.plugin.trackmate.features.FeatureFilter; -import fiji.plugin.trackmate.features.spot.SpotContrastAnalyzerFactory; -import fiji.plugin.trackmate.features.spot.SpotIntensityAnalyzerFactory; -import fiji.plugin.trackmate.features.spot.SpotRadiusEstimatorFactory; +import fiji.plugin.trackmate.features.spot.SpotContrastAndSNRAnalyzerFactory; +import fiji.plugin.trackmate.features.spot.SpotIntensityMultiCAnalyzerFactory; import fiji.plugin.trackmate.features.track.TrackDurationAnalyzer; -import fiji.plugin.trackmate.tracking.LAPUtils; import fiji.plugin.trackmate.tracking.TrackerKeys; -import fiji.plugin.trackmate.tracking.sparselap.SparseLAPTrackerFactory; +import fiji.plugin.trackmate.tracking.jaqaman.LAPUtils; +import fiji.plugin.trackmate.tracking.jaqaman.SparseLAPTrackerFactory; import ij.ImagePlus; import ij.gui.Roi; import ij.plugin.filter.ThresholdToSelection; import ij.process.ImageProcessor; -import java.util.ArrayList; - -import org.scijava.ItemIO; -import org.scijava.command.Command; -import org.scijava.log.LogService; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - @Plugin(type = Command.class, headless = true, menuPath = "FMI>Track Spots (Subpixel localization, multi-channel)") public class TrackMateWrapperMultiChannel implements Command { @Parameter @@ -129,9 +128,6 @@ public class TrackMateWrapperMultiChannel implements Command { @Parameter(type = ItemIO.OUTPUT) private double[] radius; - @Parameter(type = ItemIO.OUTPUT) - private double[] estDiameter; - @Parameter(type = ItemIO.OUTPUT) private double[] contrast; @@ -156,9 +152,8 @@ public void run() { // Create TrackMate instance with settings Model model = new Model(); - Settings settings = new Settings(); + Settings settings = new Settings(imp); - settings.setFrom(imp); settings.dt = frameInterval; settings.detectorFactory = new LogDetectorFactory<>(); @@ -179,17 +174,15 @@ public void run() { } settings.trackerFactory = new SparseLAPTrackerFactory(); - settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap(); + settings.trackerSettings = LAPUtils.getDefaultSegmentSettingsMap(); settings.trackerSettings.put(TrackerKeys.KEY_LINKING_MAX_DISTANCE, linkingMaxDistance); settings.trackerSettings.put(TrackerKeys.KEY_GAP_CLOSING_MAX_DISTANCE, closingMaxDistance); settings.trackerSettings.put(TrackerKeys.KEY_GAP_CLOSING_MAX_FRAME_GAP, frameGap); - settings.addSpotAnalyzerFactory(new SpotIntensityAnalyzerFactory<>()); - settings.addSpotAnalyzerFactory(new SpotRadiusEstimatorFactory<>()); - settings.addSpotAnalyzerFactory(new SpotContrastAnalyzerFactory<>()); - settings.addSpotAnalyzerFactory(new SpotMultiChannelIntensityAnalyzerFactory<>()); + settings.addSpotAnalyzerFactory(new SpotIntensityMultiCAnalyzerFactory<>()); + settings.addSpotAnalyzerFactory(new SpotContrastAndSNRAnalyzerFactory<>()); settings.addSpotAnalyzerFactory(new MaxQualitySpotAnalyzerFactory<>()); settings.addTrackAnalyzer(new TrackDurationAnalyzer()); @@ -220,7 +213,6 @@ public void run() { ArrayList totalIntensityList = new ArrayList<>(); ArrayList meanIntensityList = new ArrayList<>(); ArrayList radiusList = new ArrayList<>(); - ArrayList diameterList = new ArrayList<>(); ArrayList contrastList = new ArrayList<>(); ArrayList ch1List = new ArrayList<>(); @@ -243,19 +235,16 @@ public void run() { zList.add(spot.getDoublePosition(2)); totalIntensityList .add(spot - .getFeature(SpotIntensityAnalyzerFactory.TOTAL_INTENSITY)); + .getFeature("TOTAL_INTENSITY_CH1")); meanIntensityList .add(spot - .getFeature(SpotIntensityAnalyzerFactory.MEAN_INTENSITY)); + .getFeature("MEAN_INTENSITY_CH1")); radiusList.add(spot.getFeature(Spot.RADIUS)); - diameterList - .add(spot - .getFeature(SpotRadiusEstimatorFactory.ESTIMATED_DIAMETER)); contrastList.add(spot - .getFeature(SpotContrastAnalyzerFactory.KEY)); - addIfNotNull(ch1List, spot.getFeature(SpotMultiChannelIntensityAnalyzerFactory.FEATURES.get(0))); - addIfNotNull(ch2List, spot.getFeature(SpotMultiChannelIntensityAnalyzerFactory.FEATURES.get(1))); - addIfNotNull(ch3List, spot.getFeature(SpotMultiChannelIntensityAnalyzerFactory.FEATURES.get(2))); + .getFeature("CONTRAST_CH1")); + addIfNotNull(ch1List, spot.getFeature("MEAN_INTENSITY_CH1")); + addIfNotNull(ch2List, spot.getFeature("MEAN_INTENSITY_CH2")); + addIfNotNull(ch3List, spot.getFeature("MEAN_INTENSITY_CH3")); } } @@ -280,7 +269,6 @@ public void run() { totalIntensity = Doubles.toArray(totalIntensityList); meanIntensity = Doubles.toArray(meanIntensityList); radius = Doubles.toArray(radiusList); - estDiameter = Doubles.toArray(diameterList); contrast = Doubles.toArray(contrastList); if (!ch1List.isEmpty()) ch1Intensity = Doubles.toArray(ch1List);