Skip to content

Commit

Permalink
Add a copy method to the detector and tracker factory.
Browse files Browse the repository at this point in the history
This will break the external detectors we added in v7, so they will
need an update too.
This is required to properly copy a Settings object without any
undesirable side effect. All in all, the issue we are trying to address
is a design fault done early in TrackMate, where we allowed a tracker
and a detector factory to have instance fields.... What a mistake...
  • Loading branch information
tinevez committed Oct 27, 2021
1 parent 69a015e commit 3a77dfe
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
import static fiji.plugin.trackmate.detection.DetectorKeys.KEY_DO_SUBPIXEL_LOCALIZATION;
import static fiji.plugin.trackmate.detection.DetectorKeys.KEY_RADIUS;
import static fiji.plugin.trackmate.detection.DetectorKeys.KEY_THRESHOLD;
import net.imglib2.Interval;
import net.imglib2.RandomAccessible;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;

import org.scijava.plugin.Plugin;

Expand All @@ -37,6 +33,10 @@
import fiji.plugin.trackmate.gui.components.ConfigurationPanel;
import fiji.plugin.trackmate.gui.components.detector.DogDetectorConfigurationPanel;
import fiji.plugin.trackmate.util.TMUtils;
import net.imglib2.Interval;
import net.imglib2.RandomAccessible;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;

@Plugin( type = SpotDetectorFactory.class )
public class DogDetectorFactory< T extends RealType< T > & NativeType< T >> extends LogDetectorFactory< T >
Expand Down Expand Up @@ -98,4 +98,9 @@ public ConfigurationPanel getDetectorConfigurationPanel( final Settings lSetting
return new DogDetectorConfigurationPanel( lSettings, model, DogDetectorFactory.THIS_INFO_TEXT, DogDetectorFactory.THIS_NAME );
}

@Override
public DogDetectorFactory< T > copy()
{
return new DogDetectorFactory<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,10 @@ public ImageIcon getIcon()
{
return null;
}

@Override
public LabeImageDetectorFactory< T > copy()
{
return new LabeImageDetectorFactory<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,9 @@ public ImageIcon getIcon()
return null;
}

@Override
public LogDetectorFactory< T > copy()
{
return new LogDetectorFactory< >();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,10 @@ public ImageIcon getIcon()
{
return null;
}

@Override
public ManualDetectorFactory< T > copy()
{
return new ManualDetectorFactory<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,10 @@ public ImageIcon getIcon()
{
return null;
}

@Override
public MaskDetectorFactory< T > copy()
{
return new MaskDetectorFactory<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,11 @@ public default boolean has2Dsegmentation()
{
return false;
}

/**
* Returns a copy the current instance.
*
* @return a new instance of this detector factory.
*/
public SpotDetectorFactoryBase< T > copy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,10 @@ public ImageIcon getIcon()
{
return null;
}

@Override
public ThresholdDetectorFactory< T > copy()
{
return new ThresholdDetectorFactory<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
*/
package fiji.plugin.trackmate.tracking;

import fiji.plugin.trackmate.Model;
import fiji.plugin.trackmate.SpotCollection;
import fiji.plugin.trackmate.gui.components.ConfigurationPanel;

import java.util.Map;

import javax.swing.ImageIcon;
Expand All @@ -33,6 +29,10 @@
import org.scijava.Priority;
import org.scijava.plugin.Plugin;

import fiji.plugin.trackmate.Model;
import fiji.plugin.trackmate.SpotCollection;
import fiji.plugin.trackmate.gui.components.ConfigurationPanel;

@Plugin( type = SpotTrackerFactory.class, priority = Priority.HIGH )
public class ManualTrackerFactory implements SpotTrackerFactory
{
Expand Down Expand Up @@ -117,4 +117,9 @@ public String getErrorMessage()
return errorMessage;
}

@Override
public ManualTrackerFactory copy()
{
return new ManualTrackerFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,11 @@ public interface SpotTrackerFactory extends TrackMateModule
* @see #checkSettingsValidity(Map)
*/
public String getErrorMessage();

/**
* Returns a copy the current instance.
*
* @return a new instance of this tracker factory.
*/
public SpotTrackerFactory copy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,10 @@ public String getErrorMessage()
{
return errorMessage;
}

@Override
public KalmanTrackerFactory copy()
{
return new KalmanTrackerFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,10 @@ public String getErrorMessage()
{
return errorMessage;
}

@Override
public NearestNeighborTrackerFactory copy()
{
return new NearestNeighborTrackerFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,10 @@ public String getErrorMessage()
{
return errorMessage;
}

@Override
public OverlapTrackerFactory copy()
{
return new OverlapTrackerFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ public ConfigurationPanel getTrackerConfigurationPanel( final Model model )
return new SimpleLAPTrackerSettingsPanel( getName(), THIS2_INFO_TEXT, spaceUnits );
}

@Override
public SimpleSparseLAPTrackerFactory copy()
{
return new SimpleSparseLAPTrackerFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,9 @@ public SpotTracker create( final SpotCollection spots, final Map< String, Object
return new SparseLAPTracker( spots, settings );
}

@Override
public SparseLAPTrackerFactory copy()
{
return new SparseLAPTrackerFactory();
}
}

1 comment on commit 3a77dfe

@imagesc-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/error-when-launching-the-trackmate/59380/12

Please sign in to comment.