Skip to content

Commit

Permalink
Make sure the user selection of analyzers are added in priority order.
Browse files Browse the repository at this point in the history
This is crucial, as some analyzers depend on others to have been
computed. This is implemented following the priority of the analyzer
factories, which is known by the provider. The provider returns a list
of keys, in priority order, so we must make sure to reproduce this
order with the user selection.
Hence the gymnastic in the configure(Settings) method.
  • Loading branch information
tinevez committed Sep 11, 2023
1 parent 0c9d068 commit cd94a6a
Showing 1 changed file with 39 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,19 @@ public void configure( final Settings settings )
settings.clearEdgeAnalyzers();
settings.clearTrackAnalyzers();

final List< String > spotAnalyzers = getSelectedAnalyzers( SPOTS );
final List< String > selectionSpotAnalyzers = getSelectedAnalyzers( SPOTS );

// Base spot analyzers.
// Base spot analyzers, in priority order.
final SpotAnalyzerProvider spotAnalyzerProvider = new SpotAnalyzerProvider( settings.imp == null
? 1 : settings.imp.getNChannels() );
for ( final String key : spotAnalyzers )
for ( final String key : spotAnalyzerProvider.getVisibleKeys() )
{
final SpotAnalyzerFactory< ? > factory = spotAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addSpotAnalyzerFactory( factory );
if ( selectionSpotAnalyzers.contains( key ) )
{
final SpotAnalyzerFactory< ? > factory = spotAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addSpotAnalyzerFactory( factory );
}
}

// Shall we add 2D morphology analyzers?
Expand All @@ -114,11 +117,14 @@ public void configure( final Settings settings )
&& settings.detectorFactory.has2Dsegmentation() )
{
final Spot2DMorphologyAnalyzerProvider spotMorphologyAnalyzerProvider = new Spot2DMorphologyAnalyzerProvider( settings.imp.getNChannels() );
for ( final String key : spotAnalyzers )
for ( final String key : spotMorphologyAnalyzerProvider.getVisibleKeys() )
{
final Spot2DMorphologyAnalyzerFactory< ? > factory = spotMorphologyAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addSpotAnalyzerFactory( factory );
if ( selectionSpotAnalyzers.contains( key ) )
{
final Spot2DMorphologyAnalyzerFactory< ? > factory = spotMorphologyAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addSpotAnalyzerFactory( factory );
}
}
}

Expand All @@ -129,30 +135,41 @@ public void configure( final Settings settings )
&& settings.detectorFactory.has3Dsegmentation() )
{
final Spot3DMorphologyAnalyzerProvider spotMorphologyAnalyzerProvider = new Spot3DMorphologyAnalyzerProvider( settings.imp.getNChannels() );
for ( final String key : spotAnalyzers )
for ( final String key : spotMorphologyAnalyzerProvider.getVisibleKeys() )
{
final Spot3DMorphologyAnalyzerFactory< ? > factory = spotMorphologyAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addSpotAnalyzerFactory( factory );
if ( selectionSpotAnalyzers.contains( key ) )
{
final Spot3DMorphologyAnalyzerFactory< ? > factory = spotMorphologyAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addSpotAnalyzerFactory( factory );
}
}
}

// Edge analyzers.
final List< String > selectedEdgeAnalyzers = getSelectedAnalyzers( EDGES );
final EdgeAnalyzerProvider edgeAnalyzerProvider = new EdgeAnalyzerProvider();
for ( final String key : getSelectedAnalyzers( EDGES ) )
for ( final String key : edgeAnalyzerProvider.getVisibleKeys() )
{
final EdgeAnalyzer factory = edgeAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addEdgeAnalyzer( factory );
if ( selectedEdgeAnalyzers.contains( key ) )
{
final EdgeAnalyzer factory = edgeAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addEdgeAnalyzer( factory );
}
}

// Track analyzers.
final List< String > selectedTrackAnalyzers = getSelectedAnalyzers( TRACKS );
final TrackAnalyzerProvider trackAnalyzerProvider = new TrackAnalyzerProvider();
for ( final String key : getSelectedAnalyzers( TRACKS ) )
for ( final String key : trackAnalyzerProvider.getVisibleKeys() )
{
final TrackAnalyzer factory = trackAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addTrackAnalyzer( factory );
if ( selectedTrackAnalyzers.contains( key ) )
{
final TrackAnalyzer factory = trackAnalyzerProvider.getFactory( key );
if ( factory != null )
settings.addTrackAnalyzer( factory );
}
}
}

Expand Down

0 comments on commit cd94a6a

Please sign in to comment.