Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>37.0.0</version>
<version>43.0.0</version>
<relativePath />
</parent>

<groupId>sc.fiji</groupId>
<artifactId>TrackMate-MorphoLibJ</artifactId>
<version>1.2.2-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>

<name>TrackMate-MorphoLibJ</name>
<description>TrackMate detector based on the watershed segmentation tool in the MorphoLibJ plugin.</description>
Expand Down Expand Up @@ -84,7 +84,7 @@
<!-- NB: Deploy releases to the SciJava Maven repository. -->
<releaseProfiles>sign,deploy-to-scijava</releaseProfiles>

<TrackMate.version>7.10.2</TrackMate.version>
<TrackMate.version>8.0.0</TrackMate.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
Expand All @@ -25,6 +25,7 @@
import static fiji.plugin.trackmate.detection.ThresholdDetectorFactory.KEY_SIMPLIFY_CONTOURS;
import static fiji.plugin.trackmate.gui.Fonts.BIG_FONT;
import static fiji.plugin.trackmate.gui.Fonts.SMALL_FONT;
import static fiji.plugin.trackmate.morpholibj.MorphoLibJDetectorFactory.ICON;
import static fiji.plugin.trackmate.morpholibj.MorphoLibJDetectorFactory.KEY_CONNECTIVITY;
import static fiji.plugin.trackmate.morpholibj.MorphoLibJDetectorFactory.KEY_TOLERANCE;

Expand All @@ -33,15 +34,13 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
Expand All @@ -64,8 +63,6 @@ public class MorphoLibJDetectorConfigurationPanel extends ConfigurationPanel

private static final NumberFormat THRESHOLD_FORMAT = new DecimalFormat( "#.##" );

protected static final ImageIcon ICON = new ImageIcon( getResource( "images/TrackMateMorphoLibJ-logo-100px.png" ) );

private static final String TITLE = MorphoLibJDetectorFactory.NAME;

private final JSlider sliderChannel;
Expand All @@ -80,9 +77,8 @@ public MorphoLibJDetectorConfigurationPanel( final Settings settings, final Mode
{
final GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] { 144, 0, 32 };
gridBagLayout.rowHeights = new int[] { 0, 84, 0, 27, 0, 0, 0 };
gridBagLayout.rowHeights = new int[] { 0, 84, 0, 27, 0, 0, 150 };
gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0 };
gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
setLayout( gridBagLayout );

final JLabel lblDetector = new JLabel( TITLE, ICON, JLabel.RIGHT );
Expand All @@ -107,7 +103,14 @@ public MorphoLibJDetectorConfigurationPanel( final Settings settings, final Mode
gbcLblHelptext.insets = new Insets( 5, 5, 5, 5 );
gbcLblHelptext.gridx = 0;
gbcLblHelptext.gridy = 1;
add( GuiUtils.textInScrollPanel( GuiUtils.infoDisplay( MorphoLibJDetectorFactory.INFO_TEXT ) ), gbcLblHelptext );
gbcLblHelptext.weighty = 1.;
add( GuiUtils.textInScrollPanel( GuiUtils.infoDisplay(
MorphoLibJDetectorFactory.INFO_TEXT.replace( "</html>", "" )
+ "<html>Online documentation: <br/>"
+ "<a href='" + MorphoLibJDetectorFactory.DOC_URL + "'>"
+ MorphoLibJDetectorFactory.DOC_URL
+ "</a></html>" ) ),
gbcLblHelptext );

/*
* Channel selector.
Expand Down Expand Up @@ -301,9 +304,4 @@ public void setSettings( final Map< String, Object > settings )
@Override
public void clean()
{}

protected static URL getResource( final String name )
{
return MorphoLibJDetectorFactory.class.getClassLoader().getResource( name );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
Expand All @@ -24,29 +24,20 @@
import static fiji.plugin.trackmate.detection.DetectorKeys.DEFAULT_TARGET_CHANNEL;
import static fiji.plugin.trackmate.detection.DetectorKeys.KEY_TARGET_CHANNEL;
import static fiji.plugin.trackmate.detection.ThresholdDetectorFactory.KEY_SIMPLIFY_CONTOURS;
import static fiji.plugin.trackmate.io.IOUtils.readBooleanAttribute;
import static fiji.plugin.trackmate.io.IOUtils.readDoubleAttribute;
import static fiji.plugin.trackmate.io.IOUtils.readIntegerAttribute;
import static fiji.plugin.trackmate.io.IOUtils.writeAttribute;
import static fiji.plugin.trackmate.io.IOUtils.writeTargetChannel;
import static fiji.plugin.trackmate.util.TMUtils.checkMapKeys;
import static fiji.plugin.trackmate.util.TMUtils.checkParameter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.ImageIcon;

import org.jdom2.Element;
import org.scijava.Priority;
import org.scijava.plugin.Plugin;

import fiji.plugin.trackmate.Model;
import fiji.plugin.trackmate.Settings;
import fiji.plugin.trackmate.detection.SpotDetector;
import fiji.plugin.trackmate.detection.SpotDetectorFactory;
import fiji.plugin.trackmate.gui.GuiUtils;
import fiji.plugin.trackmate.gui.components.ConfigurationPanel;
import fiji.plugin.trackmate.util.TMUtils;
import net.imagej.ImgPlus;
Expand All @@ -57,11 +48,6 @@
@Plugin( type = SpotDetectorFactory.class, priority = Priority.LOW - 5. )
public class MorphoLibJDetectorFactory< T extends RealType< T > & NativeType< T > > implements SpotDetectorFactory< T >
{

/*
* CONSTANTS
*/

/**
* The key to the parameter that stores the tolerance value to use in
* morphological segmentation. Accepted values are doubles.
Expand Down Expand Up @@ -99,29 +85,14 @@ public class MorphoLibJDetectorFactory< T extends RealType< T > & NativeType< T
+ "also cite the MorphoLibJ paper: <a href=\"https://doi.org/10.1093/bioinformatics/btw413\">Legland, D.; Arganda-Carreras, I. & Andrey, P. (2016), "
+ "'MorphoLibJ: integrated library and plugins for mathematical morphology with ImageJ', "
+ "Bioinformatics (Oxford Univ Press) 32(22): 3532-3534.</a> "
+ "<p>"
+ "Documentation for this module "
+ "<a href=\"https://imagej.net/plugins/trackmate/trackmate-morpholibj\">on the ImageJ Wiki</a>."
+ "<p>"
+ "</html>";

/*
* FIELDS
*/

/** The image to operate on. Multiple frames, single channel. */
protected ImgPlus< T > img;

protected Map< String, Object > settings;
public static final String DOC_URL = "https://imagej.net/plugins/trackmate/trackmate-morpholibj";

protected String errorMessage;

/*
* METHODS
*/
public static final ImageIcon ICON = new ImageIcon( GuiUtils.getResource( "images/TrackMateMorphoLibJ-logo-64px.png", MorphoLibJDetectorFactory.class ) );

@Override
public SpotDetector< T > getDetector( final Interval interval, final int frame )
public SpotDetector< T > getDetector( final ImgPlus< T > img, final Map< String, Object > settings, final Interval interval, final int frame )
{
final int channel = ( Integer ) settings.get( KEY_TARGET_CHANNEL ) - 1;
final ImgPlus< T > input = TMUtils.hyperSlice( img, channel, frame );
Expand All @@ -138,54 +109,6 @@ public SpotDetector< T > getDetector( final Interval interval, final int frame )
return detector;
}

@Override
public boolean setTarget( final ImgPlus< T > img, final Map< String, Object > settings )
{
this.img = img;
this.settings = settings;
return checkSettings( settings );
}

@Override
public String getErrorMessage()
{
return errorMessage;
}

@Override
public boolean marshall( final Map< String, Object > settings, final Element element )
{
final StringBuilder errorHolder = new StringBuilder();
boolean ok = writeTargetChannel( settings, element, errorHolder );
ok = ok && writeAttribute( settings, element, KEY_TOLERANCE, Double.class, errorHolder );
ok = ok && writeAttribute( settings, element, KEY_CONNECTIVITY, Integer.class, errorHolder );
ok = ok && writeAttribute( settings, element, KEY_SIMPLIFY_CONTOURS, Boolean.class, errorHolder );

if ( !ok )
errorMessage = errorHolder.toString();

return ok;
}

@Override
public boolean unmarshall( final Element element, final Map< String, Object > settings )
{
settings.clear();
final StringBuilder errorHolder = new StringBuilder();
boolean ok = true;
ok = ok && readIntegerAttribute( element, settings, KEY_TARGET_CHANNEL, errorHolder );
ok = ok && readDoubleAttribute( element, settings, KEY_TOLERANCE, errorHolder );
ok = ok && readIntegerAttribute( element, settings, KEY_CONNECTIVITY, errorHolder );
ok = ok && readBooleanAttribute( element, settings, KEY_SIMPLIFY_CONTOURS, errorHolder );

if ( !ok )
{
errorMessage = errorHolder.toString();
return false;
}
return checkSettings( settings );
}

@Override
public ConfigurationPanel getDetectorConfigurationPanel( final Settings settings, final Model model )
{
Expand All @@ -204,36 +127,21 @@ public Map< String, Object > getDefaultSettings()
}

@Override
public boolean checkSettings( final Map< String, Object > settings )
public String getInfoText()
{
boolean ok = true;
final StringBuilder errorHolder = new StringBuilder();
ok = ok & checkParameter( settings, KEY_TARGET_CHANNEL, Integer.class, errorHolder );
ok = ok & checkParameter( settings, KEY_TOLERANCE, Double.class, errorHolder );
ok = ok & checkParameter( settings, KEY_CONNECTIVITY, Integer.class, errorHolder );
ok = ok & checkParameter( settings, KEY_SIMPLIFY_CONTOURS, Boolean.class, errorHolder );
final List< String > mandatoryKeys = new ArrayList<>();
mandatoryKeys.add( KEY_TARGET_CHANNEL );
mandatoryKeys.add( KEY_TOLERANCE );
mandatoryKeys.add( KEY_CONNECTIVITY );
mandatoryKeys.add( KEY_SIMPLIFY_CONTOURS );
ok = ok & checkMapKeys( settings, mandatoryKeys, null, errorHolder );
if ( !ok )
errorMessage = errorHolder.toString();

return ok;
return INFO_TEXT;
}

@Override
public String getInfoText()
public ImageIcon getIcon()
{
return INFO_TEXT;
return ICON;
}

@Override
public ImageIcon getIcon()
public String getUrl()
{
return null;
return DOC_URL;
}

@Override
Expand All @@ -253,10 +161,4 @@ public boolean has2Dsegmentation()
{
return true;
}

@Override
public MorphoLibJDetectorFactory< T > copy()
{
return new MorphoLibJDetectorFactory<>();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.