From 8122626b4c961fcc14b049f8016e2514110cb77f Mon Sep 17 00:00:00 2001 From: Stefan Hahmann Date: Thu, 25 Jan 2024 14:59:26 +0100 Subject: [PATCH 1/3] Replace custom distance method by distance method of imglib2 While searching for a method that can directly compute the distance between 2 spots in the Mastodon code base, I found the distance method in this class. Later, I learned that there is the same method in imglib2. In order to simplify the code I suggest to replace this re-implementation by using the imglib2 version of this method. --- .../BranchDisplacementDurationFeatureComputer.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeatureComputer.java b/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeatureComputer.java index db21b51b3..3f7eafda5 100644 --- a/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeatureComputer.java +++ b/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeatureComputer.java @@ -28,6 +28,7 @@ */ package org.mastodon.mamut.feature.branch; +import net.imglib2.util.Util; import org.mastodon.mamut.feature.MamutFeatureComputer; import org.mastodon.mamut.model.Model; import org.mastodon.mamut.model.ModelGraph; @@ -94,21 +95,10 @@ private void runForBranchSpot( BranchSpot branchSpot, Spot ref1, Spot ref2 ) // get target spot final Spot target = branchGraph.getLastLinkedVertex( branchSpot, ref2 ); - output.dispMap.set( branchSpot, distance( source, target ) ); + output.dispMap.set( branchSpot, Util.distance( source, target ) ); output.durMap.set( branchSpot, duration( source, target ) ); } - private double distance( Spot source, Spot target ) - { - double d2 = 0.; - for ( int d = 0; d < 3; d++ ) - { - final double dx = source.getDoublePosition( d ) - target.getDoublePosition( d ); - d2 += dx * dx; - } - return Math.sqrt( d2 ); - } - private double duration( Spot source, Spot target ) { final double t1 = target.getTimepoint(); From fa7111f76c1eb1190dc168a977a4a5c197ce81e7 Mon Sep 17 00:00:00 2001 From: Stefan Hahmann Date: Thu, 8 Feb 2024 15:28:23 +0100 Subject: [PATCH 2/3] Add the panel that shows the current timepoint and number of spots to the BDV views of Mastodon --- .../org/mastodon/mamut/views/bdv/MamutBranchViewBdv.java | 6 ++++++ .../java/org/mastodon/mamut/views/bdv/MamutViewBdv.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/org/mastodon/mamut/views/bdv/MamutBranchViewBdv.java b/src/main/java/org/mastodon/mamut/views/bdv/MamutBranchViewBdv.java index 9a29b6a5b..237965ba0 100644 --- a/src/main/java/org/mastodon/mamut/views/bdv/MamutBranchViewBdv.java +++ b/src/main/java/org/mastodon/mamut/views/bdv/MamutBranchViewBdv.java @@ -49,6 +49,7 @@ import org.mastodon.mamut.MainWindow; import org.mastodon.mamut.MamutMenuBuilder; import org.mastodon.mamut.ProjectModel; +import org.mastodon.mamut.TimepointAndNumberOfSpotsPanel; import org.mastodon.mamut.model.BoundingSphereRadiusStatistics; import org.mastodon.mamut.model.BranchGraphModelOverlayProperties; import org.mastodon.mamut.model.Link; @@ -210,6 +211,11 @@ public MamutBranchViewBdv( final ProjectModel appModel ) navigationHandler ); OverlayActions.install( viewActions, viewer, tracksOverlay ); + // Add the timepoint and number of spots panel. + final TimepointAndNumberOfSpotsPanel timepointAndNumberOfSpotsPanel = + new TimepointAndNumberOfSpotsPanel( this.timepointModel, model ); + frame.getSettingsPanel().add( timepointAndNumberOfSpotsPanel ); + /* * We must make a search action using the underlying model graph, * because we cannot iterate over the OverlayGraphWrapper properly diff --git a/src/main/java/org/mastodon/mamut/views/bdv/MamutViewBdv.java b/src/main/java/org/mastodon/mamut/views/bdv/MamutViewBdv.java index f68ea31d6..4d798bc99 100644 --- a/src/main/java/org/mastodon/mamut/views/bdv/MamutViewBdv.java +++ b/src/main/java/org/mastodon/mamut/views/bdv/MamutViewBdv.java @@ -48,6 +48,7 @@ import org.mastodon.mamut.MainWindow; import org.mastodon.mamut.MamutMenuBuilder; import org.mastodon.mamut.ProjectModel; +import org.mastodon.mamut.TimepointAndNumberOfSpotsPanel; import org.mastodon.mamut.UndoActions; import org.mastodon.mamut.model.Link; import org.mastodon.mamut.model.Model; @@ -232,6 +233,11 @@ public MamutViewBdv( final ProjectModel appModel ) colorBarOverlay, appModel.getKeymap() ); onClose( onCloseMIPDialog ); + // Add the timepoint and number of spots panel. + final TimepointAndNumberOfSpotsPanel timepointAndNumberOfSpotsPanel = + new TimepointAndNumberOfSpotsPanel( this.timepointModel, model ); + frame.getSettingsPanel().add( timepointAndNumberOfSpotsPanel ); + /* * We must make a search action using the underlying model graph, * because we cannot iterate over the OverlayGraphWrapper properly From d51bbfda93b0006ad52451e8e38066dc2e413067 Mon Sep 17 00:00:00 2001 From: Stefan Hahmann Date: Wed, 21 Feb 2024 17:43:33 +0100 Subject: [PATCH 3/3] Replace

tags with tags in BranchDisplacementDurationFeature and BranchNSpotsFeature javadoc * Reasoning: the javadoc rules where complaining about multiple

-tags used in a row. "unexpected heading used:

, compared to implicit preceding heading:

" --- .../BranchDisplacementDurationFeature.java | 22 ++++++++++--------- .../feature/branch/BranchNSpotsFeature.java | 17 +++++++------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeature.java b/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeature.java index 1ad7e6587..a7a4c5db2 100644 --- a/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeature.java +++ b/src/main/java/org/mastodon/mamut/feature/branch/BranchDisplacementDurationFeature.java @@ -63,8 +63,8 @@ * in the lineage tree. *

* Cf. following example: - * - *

Model-Graph (i.e. Graph of Spots)

+ *

+ * Model-Graph (i.e. Graph of Spots) * *

  *                                                Spot( 0, X=1,00, Y=2,00, Z=3,00, tp=0 )
@@ -91,7 +91,7 @@
  *                                               Spot( 10, X=11,00, Y=22,00, Z=33,00, tp=7 )  Spot( 7, X=8,00, Y=16,00, Z=24,00, tp=7 )
  * 
* - *

Branch-Graph (i.e. Graph of BranchSpots)

+ * Branch-Graph (i.e. Graph of BranchSpots) * *
  *                        branchSpotA
@@ -103,7 +103,7 @@
  *                                  branchSpotD    branchSpotE
  * 
* - *

Duration

+ * Duration *
    *
  • {@code branchSpotA = 2}
  • *
  • {@code branchSpotB = 2}
  • @@ -112,7 +112,7 @@ *
  • {@code branchSpotE = 3}
  • *
* - *

Displacement

+ * Displacement *
    *
  • {@code branchSpot0 = Math.sqrt( 4+16+36 )}
  • *
  • {@code branchSpot1 = Math.sqrt( 4+16+36 )}
  • @@ -122,7 +122,7 @@ *
* * - *

Spot-Graph

+ * Spot-Graph * *
  *    Spot( 0, X=1,00, Y=2,00, Z=3,00, tp=0 )
@@ -140,14 +140,16 @@
  *  Spot( 4, X=5,00, Y=10,00, Z=15,00, tp=3 )
  * 
* - *

BranchSpot-Graph

branchSpot0 - * - *

Duration

+ * BranchSpot-Graph + *

+ * branchSpot0 + *

+ * Duration *

    *
  • {@code branchSpot0 = 4}
  • *
* - *

Displacement

+ * Displacement *
    *
  • {@code branchSpot0 = Math.sqrt(16+64+144)}
  • *
diff --git a/src/main/java/org/mastodon/mamut/feature/branch/BranchNSpotsFeature.java b/src/main/java/org/mastodon/mamut/feature/branch/BranchNSpotsFeature.java index 9fa97d848..3c244f009 100644 --- a/src/main/java/org/mastodon/mamut/feature/branch/BranchNSpotsFeature.java +++ b/src/main/java/org/mastodon/mamut/feature/branch/BranchNSpotsFeature.java @@ -53,8 +53,8 @@ * be equivalent to {@link BranchDisplacementDurationFeature} (duration). * However, in situations where there are spots missing within a branch spot, this * may well be different. - * - *

Model-Graph (i.e. Graph of Spots)

+ *

+ * Model-Graph (i.e. Graph of Spots) * *

  *                                                Spot( 0, X=1,00, Y=2,00, Z=3,00, tp=0 )
@@ -81,7 +81,7 @@
  *                                               Spot( 10, X=11,00, Y=22,00, Z=33,00, tp=7 )  Spot( 7, X=8,00, Y=16,00, Z=24,00, tp=7 )
  * 
* - *

Branch-Graph (i.e. Graph of BranchSpots)

+ * Branch-Graph (i.e. Graph of BranchSpots) * *
  *                        branchSpotA
@@ -102,7 +102,7 @@
  * 
  *
  *
- * 

Model-Graph (i.e. Graph of Spots)

+ * Model-Graph (i.e. Graph of Spots) * *
  *    Spot( 0, X=1,00, Y=2,00, Z=3,00, tp=0 )
@@ -120,14 +120,15 @@
  *  Spot( 4, X=5,00, Y=10,00, Z=15,00, tp=3 )
  * 
* - *

Branch-Graph (i.e. Graph of BranchSpots)

- * branchSpot0 + * Branch-Graph (i.e. Graph of BranchSpots) + *

+ * branchSpot0 * *

    *
  • {@code branchSpot0 = 5}
  • *
* - *

Model-Graph (i.e. Graph of Spots)

+ * Model-Graph (i.e. Graph of Spots) *
  *                                                Spot( 0, X=1,00, Y=2,00, Z=3,00, tp=0 )
  *                                                                   │
@@ -152,7 +153,7 @@
  *                                                                    │                                           │
  *                                               Spot( 10, X=11,00, Y=22,00, Z=33,00, tp=7 )  Spot( 7, X=8,00, Y=16,00, Z=24,00, tp=7 )
  * 
- *

Branch-Graph (i.e. Graph of BranchSpots)

+ * Branch-Graph (i.e. Graph of BranchSpots) *
  *                        branchSpotA
  * 	       ┌──────────────┴─────────────────┐