Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import static org.mastodon.tracking.detection.DetectorKeys.DEFAULT_THRESHOLD;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_ADD_BEHAVIOR;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_DETECTION_TYPE;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_DO_SUBPIXEL_LOCALIZATION;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_MAX_TIMEPOINT;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_MIN_TIMEPOINT;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_RADIUS;
Expand Down Expand Up @@ -502,6 +503,7 @@ public static final boolean checkSettingsValidity( final Map< String, Object > s
ok = ok & checkParameter( settings, KEY_MAX_TIMEPOINT, Integer.class, errorHolder );
ok = ok & checkParameter( settings, KEY_RADIUS, Double.class, errorHolder );
ok = ok & checkParameter( settings, KEY_THRESHOLD, Double.class, errorHolder );
ok = ok & checkParameter( settings, KEY_DO_SUBPIXEL_LOCALIZATION, Boolean.class, errorHolder );
// ok = ok & checkParameter( settings, KEY_ADD_BEHAVIOR, String.class, errorHolder );

// Check key presence.
Expand All @@ -511,6 +513,7 @@ public static final boolean checkSettingsValidity( final Map< String, Object > s
mandatoryKeys.add( KEY_MAX_TIMEPOINT );
mandatoryKeys.add( KEY_RADIUS );
mandatoryKeys.add( KEY_THRESHOLD );
mandatoryKeys.add( KEY_DO_SUBPIXEL_LOCALIZATION );
final List< String > optionalKeys = new ArrayList<>();
optionalKeys.add( KEY_ADD_BEHAVIOR );
optionalKeys.add( KEY_ROI );
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/mastodon/tracking/detection/DetectorKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ public class DetectorKeys
*/
public static final String DEFAULT_ADD_BEHAVIOR = null;

/**
* The key identifying the parameter setting whether we use sub-pixel
* localization for spot position. Accepted values are {@link Boolean}s.
* <p>
* Currently used by:
* <ul>
* <li>{@link LogDetectorOp}
* <li>{@link DogDetectorOp}
* </ul>
*/
public static final String KEY_DO_SUBPIXEL_LOCALIZATION = "DO_SUBPIXEL_LOCALIZATION";

/**
* Default value for the {@link #KEY_DO_SUBPIXEL_LOCALIZATION} parameter.
*/
public static final Boolean DEFAULT_DO_SUBPIXEL_LOCALIZATION = true;

private DetectorKeys()
{}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
package org.mastodon.tracking.detection;

import static org.mastodon.tracking.detection.DetectorKeys.KEY_DETECTION_TYPE;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_DO_SUBPIXEL_LOCALIZATION;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_MAX_TIMEPOINT;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_MIN_TIMEPOINT;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_RADIUS;
Expand Down Expand Up @@ -104,6 +105,7 @@ public void mutate1( final DetectionCreatorFactory detectionCreatorFactory, fina
final double threshold = ( double ) settings.get( KEY_THRESHOLD );
final Interval roi = ( Interval ) settings.get( KEY_ROI );
final DetectionType detectionType = DetectionType.getOrDefault( ( String ) settings.get( KEY_DETECTION_TYPE ), DetectionType.MINIMA );
final boolean doSubpixelLocalization = ( boolean ) settings.get( KEY_DO_SUBPIXEL_LOCALIZATION );

statusService.showStatus( "DoG detection." );
for ( int tp = minTimepoint; tp <= maxTimepoint; tp++ )
Expand Down Expand Up @@ -209,7 +211,9 @@ public void mutate1( final DetectionCreatorFactory detectionCreatorFactory, fina
threshold,
true );
dog.setExecutorService( threadService.getExecutorService() );
final ArrayList< RefinedPeak< Point > > refinedPeaks = dog.getSubpixelPeaks();
final ArrayList< RefinedPeak< Point > > refinedPeaks = doSubpixelLocalization ?
dog.getSubpixelPeaks() :
dog.getPeaks().stream().map( p -> new RefinedPeak< Point >( p, p, 0, false ) ).collect( ArrayList::new, ArrayList::add, ArrayList::addAll );

final double[] pos = new double[ 3 ];
final RealPoint sp = RealPoint.wrap( pos );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import static org.mastodon.tracking.detection.DetectorKeys.KEY_ROI;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_SETUP_ID;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_THRESHOLD;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_DO_SUBPIXEL_LOCALIZATION;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.KEY_ALLOW_LINKING_IF_HAS_INCOMING;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.KEY_ALLOW_LINKING_IF_HAS_OUTGOING;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.KEY_ALLOW_LINKING_TO_EXISTING;
Expand Down Expand Up @@ -190,6 +191,7 @@ public void compute( final Collection< Spot > input, final Map< String, Object >
final boolean continueIfLinkExists = ( boolean ) settings.get( KEY_CONTINUE_IF_LINK_EXISTS );
final double neighborhoodFactor = Math.max( NEIGHBORHOOD_FACTOR, distanceFactor + 1. );
final boolean detectSpots = ( boolean ) settings.get( KEY_DETECT_SPOT );
final boolean doSubpixelLocalization = ( boolean ) settings.get( KEY_DO_SUBPIXEL_LOCALIZATION );

/*
* Units.
Expand Down Expand Up @@ -441,6 +443,7 @@ else if ( detectSpots )
detectorSettings.put( KEY_MIN_TIMEPOINT, Integer.valueOf( tp ) );
detectorSettings.put( KEY_MAX_TIMEPOINT, Integer.valueOf( tp ) );
detectorSettings.put( KEY_ROI, roi );
detectorSettings.put( KEY_DO_SUBPIXEL_LOCALIZATION, Boolean.valueOf( doSubpixelLocalization ) );

final DetectorOp detector = ( DetectorOp ) Inplaces.binary1( ops(), DoGDetectorOp.class,
detectionCreator, sources, detectorSettings );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static final Map< String, Object > getDefaultDetectorSettingsMap()
settings.put( KEY_ALLOW_LINKING_IF_HAS_OUTGOING, DEFAULT_ALLOW_LINKING_IF_HAS_OUTGOING );
settings.put( KEY_CONTINUE_IF_LINK_EXISTS, DEFAULT_CONTINUE_IF_LINK_EXISTS );
settings.put( KEY_DETECT_SPOT, DEFAULT_DETECT_SPOT );
settings.put( KEY_DO_SUBPIXEL_LOCALIZATION, DEFAULT_DO_SUBPIXEL_LOCALIZATION );
return settings;
}

Expand Down Expand Up @@ -95,6 +96,7 @@ public static final boolean checkSettingsValidity( final Map< String, Object > s
ok = ok & checkParameter( settings, KEY_ALLOW_LINKING_IF_HAS_OUTGOING, Boolean.class, errorHolder );
ok = ok & checkParameter( settings, KEY_CONTINUE_IF_LINK_EXISTS, Boolean.class, errorHolder );
ok = ok & checkParameter( settings, KEY_DETECT_SPOT, Boolean.class, errorHolder );
ok = ok & checkParameter( settings, KEY_DO_SUBPIXEL_LOCALIZATION, Boolean.class, errorHolder );

// Check key presence.
final List< String > mandatoryKeys = new ArrayList< String >();
Expand All @@ -108,6 +110,7 @@ public static final boolean checkSettingsValidity( final Map< String, Object > s
mandatoryKeys.add( KEY_ALLOW_LINKING_IF_HAS_OUTGOING );
mandatoryKeys.add( KEY_CONTINUE_IF_LINK_EXISTS );
mandatoryKeys.add( KEY_DETECT_SPOT );
mandatoryKeys.add( KEY_DO_SUBPIXEL_LOCALIZATION );
final List< String > optionalKeys = new ArrayList< String >();
optionalKeys.add( KEY_RESOLUTION_LEVEL );
ok = ok & checkMapKeys( settings, mandatoryKeys, optionalKeys, errorHolder );
Expand Down Expand Up @@ -299,6 +302,23 @@ public static final boolean checkSettingsValidity( final Map< String, Object > s
*/
public static final boolean DEFAULT_DETECT_SPOT = true;

/**
* The key identifying the parameter setting whether we use sub-pixel
* localization for spot position. Accepted values are {@link Boolean}s.
* <p>
* Currently used by:
* <ul>
* <li>{@link LogDetectorOp}
* <li>{@link DogDetectorOp}
* </ul>
*/
public static final String KEY_DO_SUBPIXEL_LOCALIZATION = "DO_SUBPIXEL_LOCALIZATION";

/**
* Default value for the {@link #KEY_DO_SUBPIXEL_LOCALIZATION} parameter.
*/
public static final Boolean DEFAULT_DO_SUBPIXEL_LOCALIZATION = true;

/** Minimal size of neighborhoods, in spot diameter units. */
public static final double NEIGHBORHOOD_FACTOR = 2.;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public class SemiAutomaticTrackerConfigPanel extends JPanel
+ "to create spots to link to from the image data. "
+ "</p></html>";

private static final String DO_SUBPIXEL_LOCALIZATION_TOOLTIP = "<html><p width=\"500\"> "
+ "Parameter that specifies whether we use sub-pixel "
+ "localization for spot detection. "
+ "</p></html>";

/**
* The cancel button.
*/
Expand All @@ -140,9 +145,9 @@ public SemiAutomaticTrackerConfigPanel(

final GridBagLayout gbl = new GridBagLayout();
gbl.columnWidths = new int[] { 0, 0, 0 };
gbl.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
gbl.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
gbl.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gbl.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
gbl.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
setLayout( gbl );

final JLabel lblDetection = new JLabel( "Detection." );
Expand Down Expand Up @@ -355,6 +360,17 @@ public SemiAutomaticTrackerConfigPanel(
gbcChckbxDetectSpot.gridy = 14;
add( chckbxDetectSpot, gbcChckbxDetectSpot );

final JCheckBox chckbxDoSubpixelLocalization = new JCheckBox("Do sub-pixel localization?");
chckbxDoSubpixelLocalization.setToolTipText( DO_SUBPIXEL_LOCALIZATION_TOOLTIP );
chckbxDoSubpixelLocalization.addItemListener( ( e ) -> editedSettings.setDoSubpixelLocalization( chckbxDoSubpixelLocalization.isSelected() ) );
final GridBagConstraints gbcChckbxDoSubpixelLocalization = new GridBagConstraints();
gbcChckbxDoSubpixelLocalization.anchor = GridBagConstraints.WEST;
gbcChckbxDoSubpixelLocalization.gridwidth = 2;
gbcChckbxDoSubpixelLocalization.insets = new Insets( 5, 5, 5, 0 );
gbcChckbxDoSubpixelLocalization.gridx = 0;
gbcChckbxDoSubpixelLocalization.gridy = 15;
add( chckbxDoSubpixelLocalization, gbcChckbxDoSubpixelLocalization );

final JSeparator sep3 = new JSeparator();
sep3.setMinimumSize( new Dimension( 5, 10 ) );
final GridBagConstraints gbcSeparator3 = new GridBagConstraints();
Expand All @@ -363,7 +379,7 @@ public SemiAutomaticTrackerConfigPanel(
gbcSeparator3.gridwidth = 2;
gbcSeparator3.insets = new Insets( 0, 0, 5, 0 );
gbcSeparator3.gridx = 0;
gbcSeparator3.gridy = 15;
gbcSeparator3.gridy = 16;
add( sep3, gbcSeparator3 );

final JLabel lblNavigation = new JLabel( "Navigation." );
Expand All @@ -373,7 +389,7 @@ public SemiAutomaticTrackerConfigPanel(
gbcLblNavigation.gridwidth = 2;
gbcLblNavigation.insets = new Insets( 5, 5, 5, 0 );
gbcLblNavigation.gridx = 0;
gbcLblNavigation.gridy = 16;
gbcLblNavigation.gridy = 17;
add( lblNavigation, gbcLblNavigation );

if ( null != groupHandle )
Expand All @@ -384,7 +400,7 @@ public SemiAutomaticTrackerConfigPanel(
gbcGroupLocksPanel.insets = new Insets( 0, 0, 5, 0 );
gbcGroupLocksPanel.fill = GridBagConstraints.BOTH;
gbcGroupLocksPanel.gridx = 0;
gbcGroupLocksPanel.gridy = 17;
gbcGroupLocksPanel.gridy = 18;
add( groupLocksPanel, gbcGroupLocksPanel );
}

Expand All @@ -395,7 +411,7 @@ public SemiAutomaticTrackerConfigPanel(
gbcPanelButtons.insets = new Insets( 5, 5, 0, 0 );
gbcPanelButtons.fill = GridBagConstraints.HORIZONTAL;
gbcPanelButtons.gridx = 0;
gbcPanelButtons.gridy = 19;
gbcPanelButtons.gridy = 20;
add( panelButtons, gbcPanelButtons );
panelButtons.setLayout( new BoxLayout( panelButtons, BoxLayout.X_AXIS ) );

Expand All @@ -417,6 +433,7 @@ public SemiAutomaticTrackerConfigPanel(
chckbxLinkOutgoing.setSelected( editedSettings.allowIfOutgoingLinks() );
chckbxContinueTracking.setSelected( editedSettings.continueIfLinked() );
chckbxDetectSpot.setSelected( editedSettings.detectSpot() );
chckbxDoSubpixelLocalization.setSelected( editedSettings.doSubpixelLocalization() );
repaint();
};
final ItemListener disabler = ( e ) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
*/
package org.mastodon.tracking.mamut.trackmate.semiauto.ui;

import static org.mastodon.tracking.detection.DetectorKeys.DEFAULT_DO_SUBPIXEL_LOCALIZATION;
import static org.mastodon.tracking.detection.DetectorKeys.DEFAULT_SETUP_ID;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_DO_SUBPIXEL_LOCALIZATION;
import static org.mastodon.tracking.detection.DetectorKeys.KEY_SETUP_ID;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.DEFAULT_ALLOW_LINKING_IF_HAS_INCOMING;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.DEFAULT_ALLOW_LINKING_IF_HAS_OUTGOING;
Expand Down Expand Up @@ -92,6 +94,8 @@ public interface UpdateListener

private boolean detectSpot;

private boolean doSubpixelLocalization;

private static final SemiAutomaticTrackerSettings defSats;
static
{
Expand All @@ -106,6 +110,7 @@ public interface UpdateListener
defSats.allowIfOutgoingLinks = DEFAULT_ALLOW_LINKING_IF_HAS_OUTGOING;
defSats.continueIfLinked = DEFAULT_CONTINUE_IF_LINK_EXISTS;
defSats.detectSpot = DEFAULT_DETECT_SPOT;
defSats.doSubpixelLocalization = DEFAULT_DO_SUBPIXEL_LOCALIZATION;
defSats.name = "Forward";
}

Expand All @@ -123,6 +128,7 @@ public interface UpdateListener
backSats.allowIfOutgoingLinks = Boolean.valueOf( true );
backSats.continueIfLinked = Boolean.valueOf( false );
backSats.detectSpot = DEFAULT_DETECT_SPOT;
backSats.doSubpixelLocalization = DEFAULT_DO_SUBPIXEL_LOCALIZATION;
backSats.name = "Backtracking";
}

Expand Down Expand Up @@ -169,6 +175,7 @@ public void set( final SemiAutomaticTrackerSettings stas )
this.allowIfOutgoingLinks = stas.allowIfOutgoingLinks;
this.continueIfLinked = stas.continueIfLinked;
this.detectSpot = stas.detectSpot;
this.doSubpixelLocalization = stas.doSubpixelLocalization;
notifyListeners();
}

Expand All @@ -185,6 +192,7 @@ public Map< String, Object > getAsSettingsMap()
map.put( KEY_ALLOW_LINKING_IF_HAS_OUTGOING, Boolean.valueOf( allowIfOutgoingLinks ) );
map.put( KEY_CONTINUE_IF_LINK_EXISTS, Boolean.valueOf( continueIfLinked ) );
map.put( KEY_DETECT_SPOT, Boolean.valueOf( detectSpot ) );
map.put( KEY_DO_SUBPIXEL_LOCALIZATION, Boolean.valueOf( doSubpixelLocalization ) );
return map;
}

Expand Down Expand Up @@ -328,6 +336,20 @@ public void setDetectSpot( final boolean detectSpot )
}
}

public boolean doSubpixelLocalization()
{
return doSubpixelLocalization;
}

public void setDoSubpixelLocalization( final boolean doSubpixelLocalization )
{
if ( this.doSubpixelLocalization != doSubpixelLocalization )
{
this.doSubpixelLocalization = doSubpixelLocalization;
notifyListeners();
}
}

@Override
public SemiAutomaticTrackerSettings copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/
package org.mastodon.tracking.mamut.trackmate.semiauto.ui;

import static org.mastodon.tracking.detection.DetectorKeys.DEFAULT_DO_SUBPIXEL_LOCALIZATION;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.DEFAULT_ALLOW_LINKING_IF_HAS_INCOMING;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.DEFAULT_ALLOW_LINKING_IF_HAS_OUTGOING;
import static org.mastodon.tracking.mamut.trackmate.semiauto.SemiAutomaticTrackerKeys.DEFAULT_ALLOW_LINKING_TO_EXISTING;
Expand Down Expand Up @@ -121,6 +122,7 @@ public Node representData( final Object data )
mapping.put( "allowIfOutgoingLinks", s.allowIfOutgoingLinks() );
mapping.put( "continueIfLinked", s.continueIfLinked() );
mapping.put( "detectSpot", s.detectSpot() );
mapping.put( "doSubpixelLocalization", s.doSubpixelLocalization() );

final Node node = representMapping( getTag(), mapping, getDefaultFlowStyle() );
return node;
Expand Down Expand Up @@ -152,6 +154,7 @@ public Object construct( final Node node ) throws YAMLException
s.setAllowIfOutgoingLinks( getBooleanOrDefault( mapping, "allowIfOutgoingLinks", DEFAULT_ALLOW_LINKING_IF_HAS_OUTGOING ) );
s.setContinueIfLinked( getBooleanOrDefault( mapping, "continueIfLinked", DEFAULT_CONTINUE_IF_LINK_EXISTS ) );
s.setDetectSpot( getBooleanOrDefault( mapping, "detectSpot", DEFAULT_DETECT_SPOT ) );
s.setDoSubpixelLocalization( getBooleanOrDefault( mapping, "doSubpixelLocalization", DEFAULT_DO_SUBPIXEL_LOCALIZATION ) );

return s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ public void aboutToHidePanel()
final double minSizePixel = DoGDetectorOp.MIN_SPOT_PIXEL_SIZE / 2.;
final int timepoint = ( int ) settings.values.getDetectorSettings().get( KEY_MIN_TIMEPOINT );
final double threshold = ( double ) settings.values.getDetectorSettings().get( KEY_THRESHOLD );
final boolean doSubpixelLocalization = ( boolean ) settings.values.getDetectorSettings().get( DetectorKeys.KEY_DO_SUBPIXEL_LOCALIZATION );
final List< SourceAndConverter< ? > > sources = settings.values.getSources();
logger.info( WizardUtils.echoDetectorConfigInfo( sources, minSizePixel, timepoint, setupID, radius, threshold ) );
logger.info( WizardUtils.echoDetectorConfigInfo( sources, minSizePixel, timepoint, setupID, radius, threshold, doSubpixelLocalization ) );
final String addBehavior = ( String ) settings.values.getDetectorSettings().get( KEY_ADD_BEHAVIOR );
logger.info( String.format( " - dealing with existing spot: %s.\n", addBehavior ) );
}
Expand Down
Loading