Skip to content

Commit ede4d0e

Browse files
author
Stefan Hahmann
committed
Enable confirmEnvInstallation flag and inject logger in detector/linker tests for enhanced flexibility and debugging.
1 parent c03e0c2 commit ede4d0e

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/test/java/org/mastodon/mamut/detection/cellpose/Cellpose3DetectorTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.mastodon.mamut.io.importer.labelimage.util.DemoUtils;
5555
import org.mastodon.mamut.model.Model;
5656
import org.mastodon.tracking.detection.DetectorKeys;
57+
import org.mastodon.tracking.mamut.detection.AbstractSpotDetectorOp;
5758
import org.scijava.Context;
5859

5960
import io.scif.img.ImgOpener;
@@ -63,12 +64,18 @@ class Cellpose3DetectorTest
6364

6465
@Disabled( "This test is disabled, because it has very long runtime (> 2 minutes)" )
6566
@Test
66-
void testCompute3D() throws IllegalAccessException, URISyntaxException
67+
void testCompute3D() throws IllegalAccessException, URISyntaxException, NoSuchFieldException
6768
{
6869
Cellpose3Detector detector = new Cellpose3Detector();
70+
detector.setConfirmEnvInstallation( false );
6971

7072
try (Context context = new Context())
7173
{
74+
org.scijava.log.Logger log = context.getService( org.scijava.log.LogService.class ).subLogger( "Cellpose3DetectorTest" );
75+
Field logger = AbstractSpotDetectorOp.class.getDeclaredField( "log" );
76+
logger.setAccessible( true );
77+
logger.set( detector, log );
78+
7279
ImgOpener imgOpener = new ImgOpener();
7380
URL url3d = getClass().getClassLoader().getResource( "org/mastodon/mamut/appose/nuclei_3d.tif" );
7481
URL url2d = getClass().getClassLoader().getResource( "org/mastodon/mamut/appose/blobs.tif" );

src/test/java/org/mastodon/mamut/detection/cellpose/Cellpose4DetectorTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.mastodon.mamut.io.importer.labelimage.util.SphereRenderer;
5252
import org.mastodon.mamut.model.Model;
5353
import org.mastodon.tracking.detection.DetectorKeys;
54+
import org.mastodon.tracking.mamut.detection.AbstractSpotDetectorOp;
5455
import org.scijava.Context;
5556

5657

@@ -59,13 +60,19 @@ class Cellpose4DetectorTest
5960

6061
@Disabled( "This test is disabled, because it has very long runtime (> 5 minutes)" )
6162
@Test
62-
void testCompute3D() throws IllegalAccessException
63+
void testCompute3D() throws IllegalAccessException, NoSuchFieldException
6364
{
6465
Cellpose4Detector detector = new Cellpose4Detector();
66+
detector.setConfirmEnvInstallation( false );
6567
Model model = new Model();
6668

6769
try (Context context = new Context())
6870
{
71+
org.scijava.log.Logger log = context.getService( org.scijava.log.LogService.class ).subLogger( "Cellpose4DetectorTest" );
72+
Field logger = AbstractSpotDetectorOp.class.getDeclaredField( "log" );
73+
logger.setAccessible( true );
74+
logger.set( detector, log );
75+
6976
Img< FloatType > img = ArrayImgs.floats( 12, 12, 12 );
7077
SphereRenderer.renderSphere( new int[] { 5, 5, 5 }, 5, 100, img );
7178
context.inject( detector ); // make sure the detector is initialized with the context

src/test/java/org/mastodon/mamut/detection/stardist/StarDistDetectorTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.mastodon.mamut.io.importer.labelimage.util.DemoUtils;
4949
import org.mastodon.mamut.model.Model;
5050
import org.mastodon.tracking.detection.DetectorKeys;
51+
import org.mastodon.tracking.mamut.detection.AbstractSpotDetectorOp;
5152
import org.mastodon.tracking.mamut.trackmate.wizard.descriptors.StarDistDetectorDescriptor;
5253
import org.scijava.Context;
5354

@@ -57,12 +58,18 @@ class StarDistDetectorTest
5758
{
5859
@Disabled( "This test is disabled, because it has very long runtime (> 2 minutes)" )
5960
@Test
60-
void testCompute3D() throws IllegalAccessException, URISyntaxException
61+
void testCompute3D() throws IllegalAccessException, URISyntaxException, NoSuchFieldException
6162
{
6263
StarDistDetector detector = new StarDistDetector();
64+
detector.setConfirmEnvInstallation( false );
6365

6466
try (Context context = new Context())
6567
{
68+
org.scijava.log.Logger log = context.getService( org.scijava.log.LogService.class ).subLogger( "StarDistDetectorTest" );
69+
Field logger = AbstractSpotDetectorOp.class.getDeclaredField( "log" );
70+
logger.setAccessible( true );
71+
logger.set( detector, log );
72+
6673
ImgOpener imgOpener = new ImgOpener();
6774
URL url3d = getClass().getClassLoader().getResource( "org/mastodon/mamut/appose/nuclei_3d.tif" );
6875
URL url2d = getClass().getClassLoader().getResource( "org/mastodon/mamut/appose/blobs.tif" );

src/test/java/org/mastodon/mamut/linking/trackastra/TrackastraLinkerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void testLinking3D() throws IOException, SpimDataException, NoSuchFieldException
5050
assertEquals( 10, graph.vertices().size() );
5151
assertEquals( 0, graph.edges().size() );
5252
TrackastraLinker< Spot, Link > linker = new TrackastraLinker<>();
53+
linker.setConfirmEnvInstallation( false );
5354
Map< String, Object > settingsMap = TrackastraUtils.getDefaultTrackAstraSettingsMap();
5455
settingsMap.put( KEY_MAX_TIMEPOINT, 4 );
5556
settingsMap.put( KEY_SOURCE, appModel.getSharedBdvData().getSources().get( 0 ).getSpimSource() );
@@ -91,6 +92,7 @@ void testLinking2D() throws IOException, SpimDataException, NoSuchFieldException
9192
assertEquals( 13, graph.vertices().size() );
9293
assertEquals( 0, graph.edges().size() );
9394
TrackastraLinker< Spot, Link > linker = new TrackastraLinker<>();
95+
linker.setConfirmEnvInstallation( false );
9496
Map< String, Object > settingsMap = TrackastraUtils.getDefaultTrackAstraSettingsMap();
9597
settingsMap.put( KEY_MAX_TIMEPOINT, 4 );
9698
settingsMap.put( KEY_SOURCE, appModel.getSharedBdvData().getSources().get( 0 ).getSpimSource() );

0 commit comments

Comments
 (0)