Skip to content

Commit

Permalink
Rework the NN tracker UI and description.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinevez committed Nov 6, 2024
1 parent a0e1398 commit 42acf1c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 46 deletions.
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 @@ -23,15 +23,18 @@

import static fiji.plugin.trackmate.gui.Fonts.BIG_FONT;
import static fiji.plugin.trackmate.gui.Fonts.FONT;
import static fiji.plugin.trackmate.gui.Fonts.TEXTFIELD_DIMENSION;
import static fiji.plugin.trackmate.tracking.TrackerKeys.KEY_LINKING_MAX_DISTANCE;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.HashMap;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import fiji.plugin.trackmate.gui.GuiUtils;
Expand All @@ -44,12 +47,6 @@ public class NearestNeighborTrackerSettingsPanel extends ConfigurationPanel

private JFormattedTextField maxDistField;

private JLabel labelTrackerDescription;

private JLabel labelUnits;

private JLabel labelTracker;

private final String infoText;

private final String trackerName;
Expand Down Expand Up @@ -80,44 +77,75 @@ public void setSettings( final Map< String, Object > settings )

private void initGUI()
{
setBorder( BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) );

setLayout( null );
final GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] { 164, 40, 54, 0 };
gridBagLayout.rowHeights = new int[] { 30, 40, 225, 30, 60 };
gridBagLayout.columnWeights = new double[] { 1.0, 0.0, 0.0, Double.MIN_VALUE };
gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
setLayout( gridBagLayout );

final JLabel lblSettingsForTracker = new JLabel( "Settings for tracker:" );
lblSettingsForTracker.setBounds( 10, 11, 280, 20 );
lblSettingsForTracker.setFont( FONT );
add( lblSettingsForTracker );

labelTracker = new JLabel( trackerName );
final GridBagConstraints gbcLblSettingsForTracker = new GridBagConstraints();
gbcLblSettingsForTracker.fill = GridBagConstraints.BOTH;
gbcLblSettingsForTracker.insets = new Insets( 0, 0, 5, 0 );
gbcLblSettingsForTracker.gridwidth = 3;
gbcLblSettingsForTracker.gridx = 0;
gbcLblSettingsForTracker.gridy = 0;
add( lblSettingsForTracker, gbcLblSettingsForTracker );

final JLabel labelTracker = new JLabel( trackerName );
labelTracker.setFont( BIG_FONT );
labelTracker.setHorizontalAlignment( SwingConstants.CENTER );
labelTracker.setBounds( 10, 42, 280, 20 );
add( labelTracker );

labelTrackerDescription = new JLabel( "<tracker description>" );
labelTrackerDescription.setFont( FONT.deriveFont( Font.ITALIC ) );
labelTrackerDescription.setBounds( 10, 67, 280, 225 );
labelTrackerDescription.setText( infoText.replace( "<br>", "" ).replace( "<p>", "<p align=\"justify\">" ).replace( "<html>", "<html><p align=\"justify\">" ) );
add( labelTrackerDescription );
final GridBagConstraints gbcLabelTracker = new GridBagConstraints();
gbcLabelTracker.fill = GridBagConstraints.BOTH;
gbcLabelTracker.insets = new Insets( 0, 0, 5, 0 );
gbcLabelTracker.gridwidth = 3;
gbcLabelTracker.gridx = 0;
gbcLabelTracker.gridy = 1;
add( labelTracker, gbcLabelTracker );

final GridBagConstraints gbcLabelTrackerDescription = new GridBagConstraints();
gbcLabelTrackerDescription.anchor = GridBagConstraints.NORTH;
gbcLabelTrackerDescription.fill = GridBagConstraints.BOTH;
gbcLabelTrackerDescription.insets = new Insets( 0, 0, 5, 0 );
gbcLabelTrackerDescription.gridwidth = 3;
gbcLabelTrackerDescription.gridx = 0;
gbcLabelTrackerDescription.gridy = 2;
add( GuiUtils.textInScrollPanel( GuiUtils.infoDisplay( infoText ) ), gbcLabelTrackerDescription );

final JLabel lblMaximalLinkingDistance = new JLabel( "Maximal linking distance: " );
lblMaximalLinkingDistance.setFont( FONT );
lblMaximalLinkingDistance.setBounds( 10, 314, 164, 20 );
add( lblMaximalLinkingDistance );
final GridBagConstraints gbcLblMaximalLinkingDistance = new GridBagConstraints();
gbcLblMaximalLinkingDistance.fill = GridBagConstraints.BOTH;
gbcLblMaximalLinkingDistance.insets = new Insets( 0, 0, 0, 5 );
gbcLblMaximalLinkingDistance.gridx = 0;
gbcLblMaximalLinkingDistance.gridy = 3;
add( lblMaximalLinkingDistance, gbcLblMaximalLinkingDistance );

maxDistField = new JFormattedTextField( 15. );
maxDistField.setHorizontalAlignment( JTextField.CENTER );
maxDistField.setFont( FONT );
maxDistField.setBounds( 184, 316, 62, 16 );
maxDistField.setSize( TEXTFIELD_DIMENSION );
add( maxDistField );

labelUnits = new JLabel( spaceUnits );
labelUnits.setFont( FONT );
labelUnits.setBounds( 236, 314, 34, 20 );
add( labelUnits );
final GridBagConstraints gbcMaxDistField = new GridBagConstraints();
gbcMaxDistField.fill = GridBagConstraints.BOTH;
gbcMaxDistField.insets = new Insets( 0, 0, 0, 5 );
gbcMaxDistField.gridx = 1;
gbcMaxDistField.gridy = 3;
add( maxDistField, gbcMaxDistField );

// Select text-fields content on focus.
GuiUtils.selectAllOnFocus( maxDistField );

final JLabel labelUnits = new JLabel( spaceUnits );
labelUnits.setFont( FONT );
final GridBagConstraints gbcLabelUnits = new GridBagConstraints();
gbcLabelUnits.anchor = GridBagConstraints.WEST;
gbcLabelUnits.fill = GridBagConstraints.VERTICAL;
gbcLabelUnits.gridx = 2;
gbcLabelUnits.gridy = 3;
add( labelUnits, gbcLabelUnits );
}

@Override
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 Down Expand Up @@ -50,19 +50,23 @@ public class NearestNeighborTrackerFactory implements SpotTrackerFactory
public static final String NAME = "Nearest-neighbor tracker";

public static final String INFO_TEXT = "<html>"
+ "This tracker is the most simple one, and is based on nearest neighbor <br>"
+ "search. The spots in the target frame are searched for the nearest neighbor <br> "
+ "of each spot in the source frame. If the spots found are closer than the <br>"
+ "maximal allowed distance, a link between the two is created. <br>"
+ "This tracker is the most simple one, and is based on nearest neighbor "
+ "search. "
+ "<p>"
+ "The nearest neighbor search relies upon the KD-tree technique implemented <br>"
+ "in imglib by Johannes Schindelin and friends. This ensure a very efficient "
+ "tracking and makes this tracker suitable for situation where a huge number <br>"
+ "of particles are to be tracked over a very large number of frames. However, <br>"
+ "because of the naiveness of its principles, it can result in pathological <br>"
+ "tracks. It can only do frame-to-frame linking; there cannot be any track <br>"
+ "For each pair of consecutive frames <i>t1</i> and <i>t2</i>, it iterates through all "
+ "spots in frame <i>t1</i>. For each source spot in <i>t1</i>, it searches for the nearest target spot "
+ "in frame <i>t2</i>. If it is not already connected to a spot in frame <i>t1</i>, and is "
+ "within the maximal linking distance, a link between the two spots is created. <br>"
+ "<p>"
+ "The nearest neighbor search relies upon the KD-tree technique implemented "
+ "in imglib2. This ensure a very efficient "
+ "tracking and makes this tracker suitable for situation where a huge number "
+ "of particles are to be tracked over a very large number of frames. However, "
+ "because of the naiveness of its principles, it can result in pathological "
+ "tracks. It can only do frame-to-frame linking; there cannot be any track "
+ "merging or splitting, and gaps will not be closed. Also, the end results are non-"
+ "deterministic."
+ "deterministic, as the links created depend in the order in which the source spots "
+ "are iterated."
+ " </html>";

private String errorMessage;
Expand Down

0 comments on commit 42acf1c

Please sign in to comment.