From a3de11f19c20838c68da06226b8e6f64263702b9 Mon Sep 17 00:00:00 2001 From: Georges El Haddad Date: Thu, 9 Apr 2020 00:17:31 +0200 Subject: [PATCH] fix: remove filter track list --- src/spotmetrics/analyzer/AnalysisEngine.java | 78 ++++++++++++-------- src/spotmetrics/ui/SpotMetricsFrame.java | 7 +- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/src/spotmetrics/analyzer/AnalysisEngine.java b/src/spotmetrics/analyzer/AnalysisEngine.java index aa9d632..90e4873 100644 --- a/src/spotmetrics/analyzer/AnalysisEngine.java +++ b/src/spotmetrics/analyzer/AnalysisEngine.java @@ -1,11 +1,9 @@ package spotmetrics.analyzer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; + import fiji.plugin.trackmate.Logger; import fiji.plugin.trackmate.Model; import fiji.plugin.trackmate.Settings; @@ -177,6 +175,7 @@ public final Map trackSpots() { calibrateImageDimensions(); parentFrame.updateProgressBar("Setting up TrackMate ..."); + IJ.log("Setting up TrackMate ..."); Model model = new Model(); model.setLogger(Logger.IJ_LOGGER); @@ -209,6 +208,8 @@ public final Map trackSpots() { if (ok) { boolean success = false; parentFrame.updateProgressBar("Detecting spots ..."); + IJ.log("Detecting spots ..."); + success = trackMate.execDetection(); if (!success) { IJ.error("TrackMate Error - Detection", trackMate.getErrorMessage()); @@ -216,6 +217,8 @@ public final Map trackSpots() { if (success) { parentFrame.updateProgressBar("Initial spot filtering ..."); + IJ.log("Initial spot filtering ..."); + success = trackMate.execInitialSpotFiltering(); if (!success) { IJ.error("TrackMate Error - Initial Filtering", trackMate.getErrorMessage()); @@ -224,6 +227,8 @@ public final Map trackSpots() { if (success) { parentFrame.updateProgressBar("Spot filtering ..."); + IJ.log("Spot filtering ..."); + success = trackMate.execSpotFiltering(false); if (!success) { IJ.error("TrackMate Error - Spot Filtering", trackMate.getErrorMessage()); @@ -232,6 +237,8 @@ public final Map trackSpots() { if (success) { parentFrame.updateProgressBar("Tracking spots ..."); + IJ.log("Tracking spots ..."); + success = trackMate.execTracking(); if (!success) { IJ.error("TrackMate Error - Tracking", trackMate.getErrorMessage()); @@ -240,6 +247,8 @@ public final Map trackSpots() { if (success) { parentFrame.updateProgressBar("Track filtering ..."); + IJ.log("Track filtering ..."); + success = trackMate.execTrackFiltering(false); if (!success) { IJ.error("TrackMate Error - Track Filtering", trackMate.getErrorMessage()); @@ -252,6 +261,7 @@ public final Map trackSpots() { for (Integer trackId : trackIds) { Set spots = trackModel.trackSpots(trackId); +// IJ.log("Running through Track ID "+trackId+" ..."); MyTrack tr = new MyTrack(); tr.setLabel("Track_" + String.format("%04d", trackId)); @@ -283,9 +293,13 @@ public final Map trackSpots() { else { IJ.error("TrackMate Error - Settings", trackMate.getErrorMessage()); } - - parentFrame.updateProgressBar("Syncing tracks to video range ..."); - filterTrackList(tracksMap, model); + +// parentFrame.updateProgressBar("Syncing tracks to video range ..."); +// IJ.log("Syncing tracks to video range ..."); +// +// IJ.log("Before Filter: tracksMap.size() == "+tracksMap.size()); +// filterTrackList(tracksMap, model); +// IJ.log("After Filter: tracksMap.size() == "+tracksMap.size()); model = null; settings = null; @@ -294,31 +308,33 @@ public final Map trackSpots() { return tracksMap; } - private final void filterTrackList(Map tracksMap, Model model) { - //Only keep the tracks who have spots between startFrame and endFrame - //Remove all tracks that don't match - //Remove all spots below and above the range - - parentFrame.updateProgressBar("Synchronizng tracks to video range ... "); - - List deleteTrackIDs = new ArrayList(); - - Iterator iter = tracksMap.values().iterator(); - while (iter.hasNext()) { - MyTrack track = iter.next(); - - if (track.getTrackDuration() != imagePlus.getStackSize()) { - deleteTrackIDs.add(track.getLabel()); - } - } - - for (String trackID : deleteTrackIDs) { - tracksMap.remove(trackID); - } - - deleteTrackIDs.clear(); - deleteTrackIDs = null; - } +// private final void filterTrackList(Map tracksMap, Model model) { +// //Only keep the tracks who have spots between startFrame and endFrame +// //Remove all tracks that don't match +// //Remove all spots below and above the range +// +// parentFrame.updateProgressBar("Synchronizng tracks to video range ... "); +// +// List deleteTrackIDs = new ArrayList(); +// +// Iterator iter = tracksMap.values().iterator(); +// while (iter.hasNext()) { +// MyTrack track = iter.next(); +// +// IJ.log("Track Duration = "+track.getTrackDuration()+" != stackSize = "+imagePlus.getStackSize()); +// if (track.getTrackDuration() != imagePlus.getStackSize()) { +// deleteTrackIDs.add(track.getLabel()); +// IJ.log("Delete track: "+track.getLabel()); +// } +// } +// +// for (String trackID : deleteTrackIDs) { +// tracksMap.remove(trackID); +// } +// +// deleteTrackIDs.clear(); +// deleteTrackIDs = null; +// } public final void cropVideo() { if(imagePlus != null) { diff --git a/src/spotmetrics/ui/SpotMetricsFrame.java b/src/spotmetrics/ui/SpotMetricsFrame.java index 43da7ef..f7f00a0 100644 --- a/src/spotmetrics/ui/SpotMetricsFrame.java +++ b/src/spotmetrics/ui/SpotMetricsFrame.java @@ -24,6 +24,8 @@ import javax.swing.JTabbedPane; import javax.swing.JTextField; import javax.swing.UIManager; + +import ij.IJ; import ij.ImagePlus; import spotmetrics.SpotMetrics; import spotmetrics.analyzer.AnalysisEngine; @@ -338,8 +340,11 @@ public void run() { engine.processVideo(); engine.setTrackingOptions(trackOptions); Map tracksMap = engine.trackSpots(); - + +// IJ.log("Is tracksMap null? "+(tracksMap == null)); + if (tracksMap != null) { + IJ.log("tracksMap size = "+tracksMap.size()); spotsPanel.clearSpotTreeSelection(); spotsPanel.setSpotTracks(tracksMap, analysisPanel.getXoffset(), analysisPanel.getYoffset(), analysisPanel.getWoffset(), analysisPanel.getHoffset(), true); spotsPanel.setImagePlus(engine.getImagePlus());