From d7f60d3e95b1ecaec4def46ed3c20672534d2bac Mon Sep 17 00:00:00 2001 From: ctrebeau <ctrebeau@pasteur.fr> Date: Mon, 31 Mar 2025 20:57:31 +0200 Subject: [PATCH] code cleanup --- .../ida/zellige/element/Projection.java | 22 +---------- .../ida/zellige/element/ReferenceSurface.java | 7 ---- .../pasteur/ida/zellige/element/Surface.java | 37 ------------------- .../ida/zellige/element/ose/AbstractOSE.java | 6 +-- .../ida/zellige/element/ose/OSEList.java | 12 +++++- .../element/surfaceLine/SurfaceLine.java | 15 ++++---- .../element/surfaceLine/SurfaceLineX.java | 17 +++++---- .../element/surfaceLine/SurfaceLineY.java | 2 - .../pasteur/ida/zellige/gui/LogAppender.java | 2 +- .../pasteur/ida/zellige/gui/MainAppFrame.java | 29 +++++++++------ .../controller/ConstructionController.java | 5 ++- .../gui/controller/SelectionController.java | 3 +- .../interactor/ConstructionInteractor.java | 5 ++- .../zellige/gui/model/ConstructionModel.java | 10 +++-- .../gui/task/AmplitudeThresholdingTask.java | 6 ++- .../ida/zellige/gui/task/BinningTask.java | 6 ++- .../task/ComputeClassificationImagesTask.java | 6 ++- .../gui/task/ConstructionCompletionTask.java | 8 ++-- .../gui/task/InterClassificationTask.java | 4 +- .../zellige/gui/task/IslandSearchTask.java | 6 ++- .../gui/task/OtsuThresholdingTask.java | 6 ++- .../zellige/gui/task/PreprocessingTask.java | 6 ++- .../gui/task/RunFirstConstructionTask.java | 6 ++- .../gui/task/RunSecondConstructionTask.java | 8 ++-- .../ida/zellige/gui/task/SmoothingTask.java | 4 +- .../fr/pasteur/ida/zellige/steps/Utils.java | 5 --- .../steps/construction/Construction.java | 1 - .../selection/util/ExtremaDetection.java | 1 - .../selection/util/ExtremaDetection2D.java | 7 +--- 29 files changed, 110 insertions(+), 142 deletions(-) diff --git a/src/main/java/fr/pasteur/ida/zellige/element/Projection.java b/src/main/java/fr/pasteur/ida/zellige/element/Projection.java index 968f809..107f3ce 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/Projection.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/Projection.java @@ -30,14 +30,12 @@ package fr.pasteur.ida.zellige.element; import net.imglib2.img.Img; import net.imglib2.type.NativeType; -import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.RealType; -import net.imglib2.type.numeric.integer.UnsignedShortType; public class Projection< T extends RealType< T > & NativeType< T > > { - private int offset; - private int deltaZ; + private final int offset; + private final int deltaZ; private String method; private final ReferenceSurface<T> referenceSurface; private Img< T > projection; @@ -52,13 +50,6 @@ public class Projection< T extends RealType< T > & NativeType< T > > this.referenceSurface = referenceSurface; } - public Projection( ReferenceSurface< T > referenceSurface ) - { - this.referenceSurface = referenceSurface; - } - - - public Img< T > get() { return projection; @@ -94,18 +85,9 @@ public class Projection< T extends RealType< T > & NativeType< T > > this.subVolume = subVolume; } - public void setOffset( int offset ) - { - this.offset = offset; - } - public void setMethod( String method ) { this.method = method; } - public void setDeltaZ( int deltaZ ) - { - this.deltaZ = deltaZ; - } } diff --git a/src/main/java/fr/pasteur/ida/zellige/element/ReferenceSurface.java b/src/main/java/fr/pasteur/ida/zellige/element/ReferenceSurface.java index 0e586a6..b294169 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/ReferenceSurface.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/ReferenceSurface.java @@ -86,13 +86,6 @@ public class ReferenceSurface< T extends RealType< T > & NativeType< T > > } } - - public Img< T > getRawProjection() - { - return rawProjection; - } - - public RandomAccessibleInterval< T > getInput() { return input; diff --git a/src/main/java/fr/pasteur/ida/zellige/element/Surface.java b/src/main/java/fr/pasteur/ida/zellige/element/Surface.java index de4c54a..4269afa 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/Surface.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/Surface.java @@ -149,43 +149,6 @@ public class Surface return inCommon / ( double ) count; } - public boolean isTheSameSurfaceAs( Surface other ) - { - for ( int i = 0; i <= this.getHeight() - 1; i++ ) - { - SurfaceLine refLine = this.get( i ); - if ( refLine != null ) - { - SurfaceLine toTest = other.get( i ); - if ( toTest != null ) - { - - for ( int j = 0; j < refLine.getLength(); j++ ) - { - Pixels refPixels = refLine.get( j ); - if ( refPixels != null ) - { - Pixels pixelsToTest = toTest.get( j ); - if ( pixelsToTest != null ) - { -// return false; -// } - if ( ! refPixels.equals( pixelsToTest ) ) - { - return false; - } - } - } - } - } - - } - - } - return true; - } - - /** * Checks if this object shares a majority of {@link Pixels} with another {@link Surface} object. * diff --git a/src/main/java/fr/pasteur/ida/zellige/element/ose/AbstractOSE.java b/src/main/java/fr/pasteur/ida/zellige/element/ose/AbstractOSE.java index baa8e42..a3f584f 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/ose/AbstractOSE.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/ose/AbstractOSE.java @@ -36,9 +36,7 @@ import java.util.ArrayList; public abstract class AbstractOSE extends ArrayList< Coordinate > { - /* Not necessary for the program.*/ private final OSEStartingStatus startingStatus; - /*-------------*/ /** * The visited status for the 1D and 2D reconstructions. @@ -62,10 +60,8 @@ public abstract class AbstractOSE extends ArrayList< Coordinate > */ public void set() { - Integer j = startingStatus.get( this.size() ); - startingStatus.put( this.size(), ( j == null ) ? 1 : j + 1 ); + startingStatus.compute( this.size(), ( k, j ) -> ( j == null ) ? 1 : j + 1 ); startingStatus.setOSCount(); - } /** diff --git a/src/main/java/fr/pasteur/ida/zellige/element/ose/OSEList.java b/src/main/java/fr/pasteur/ida/zellige/element/ose/OSEList.java index 60b1548..cc212f2 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/ose/OSEList.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/ose/OSEList.java @@ -37,7 +37,6 @@ import java.util.Collection; public class OSEList extends ArrayList< AbstractOSE > { - public OSEList() { } @@ -66,6 +65,10 @@ public class OSEList extends ArrayList< AbstractOSE > return add; } + /** + * + * @return the size of the OSE list + */ public int getSize() { int size = 0; @@ -76,6 +79,9 @@ public class OSEList extends ArrayList< AbstractOSE > return size; } + /** + * Resets to false the visited status + */ public void reset() { for ( AbstractOSE os : this ) @@ -84,6 +90,10 @@ public class OSEList extends ArrayList< AbstractOSE > } } + /** + * + * @return true if the OSE list contains a starting OSE + */ public boolean containsAStart() { for ( AbstractOSE os : this ) diff --git a/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLine.java b/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLine.java index 305afcd..1d9ddb0 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLine.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLine.java @@ -74,14 +74,15 @@ public abstract class SurfaceLine this.dimension = new Pixels[ length ] ; set( os ); } - - - public SurfaceLine( AbstractOSE os, int size ) - { - this.dimension = new Pixels[ size] ; - set( os ); - } + /** + * + * @param os + * @param overlap + * @param connexity + * @param surfaceLine + * @return + */ public SurfaceLine match2( AbstractOSE os, int overlap, double connexity, SurfaceLine surfaceLine ) { int match = 0; diff --git a/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineX.java b/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineX.java index fded62f..6ba7479 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineX.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineX.java @@ -44,6 +44,15 @@ public class SurfaceLineX extends SurfaceLine this.setLine( os.get( 0 ).getY() ); } + /** + * Tests if the OS matches the SurfaceLine instance and creates a new SurfaceLine object if so. + * + * @param os - the OS to test against the SurfaceLine instance. + * @param direction - an integer witch indicates the line of the resulting SurfaceLine. + * @param overlap - the minimum number of matching coordinates. + * @param connexity - the minimum percentage of match between the OS and the current instance. + * @return - a new SurfaceLine if there is a match, null otherwise. + */ public SurfaceLine match( AbstractOSE os, int direction, int overlap, double connexity ) { SurfaceLineX surfaceLineX = new SurfaceLineX( this.getLength(), this.getLine() + direction ); @@ -61,12 +70,4 @@ public class SurfaceLineX extends SurfaceLine super(length, line ); } - public SurfaceLineX( AbstractOSE os, int size ) - { - super( os , size); - this.setLine( os.get( 0 ).getY() ); - } - - - } diff --git a/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineY.java b/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineY.java index 9b30ebd..5b064f6 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineY.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/surfaceLine/SurfaceLineY.java @@ -66,8 +66,6 @@ public class SurfaceLineY extends SurfaceLine * @param connexity - the minimum percentage of match between the OS and the current instance. * @return - a new SurfaceLine if there is a match, null otherwise. */ - - public SurfaceLine match( AbstractOSE os, int direction, int overlap, double connexity ) { SurfaceLineY surfaceLineY = new SurfaceLineY( this.getLength(), this.getLine() + direction ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/LogAppender.java b/src/main/java/fr/pasteur/ida/zellige/gui/LogAppender.java index b5f865a..f378ff4 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/LogAppender.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/LogAppender.java @@ -51,7 +51,7 @@ public class LogAppender extends AppenderBase< ILoggingEvent > protected void append( ILoggingEvent iLoggingEvent ) { String level = iLoggingEvent.getLevel().toString(); - if ( level.equals( Level.INFO.toString() ) ) + if ( level.equals( Level.INFO.toString()) && iLoggingEvent.getMarker().contains( "GUI" )) { logMessage.setValue( iLoggingEvent.getFormattedMessage() ); } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java b/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java index 9c77c3f..2959530 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java @@ -45,6 +45,8 @@ import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; import javax.swing.*; import java.awt.*; @@ -57,7 +59,7 @@ import java.util.ResourceBundle; public class MainAppFrame extends JFrame { - private final static Logger LOGGER = LoggerFactory.getLogger( MainAppFrame.class ); + public static final Marker GUI_MARKER = MarkerFactory.getMarker("GUI"); private ImageJ ij; private final ImageDisplayService image; @Parameter @@ -86,15 +88,21 @@ public class MainAppFrame extends JFrame */ public void setLogStatus() { - LoggerContext lc = ( LoggerContext ) LoggerFactory.getILoggerFactory(); - PatternLayoutEncoder ple = new PatternLayoutEncoder(); - ple.setPattern( "%msg%n" ); - ple.setContext( lc ); - ple.start(); - LogAppender appender = new LogAppender(); + // Get the logger context + LoggerContext context = ( LoggerContext ) LoggerFactory.getILoggerFactory(); + + // Configure the log pattern + PatternLayoutEncoder layout = new PatternLayoutEncoder(); + layout.setPattern( "%msg%n" ); + layout.setContext( context ); + layout.start(); - appender.setContext( lc ); + // Create and start the custom LogAppender + LogAppender appender = new LogAppender(); + appender.setContext( context ); appender.start(); + + // Get the root logger and add the appender ch.qos.logback.classic.Logger logbackLogger = ( ch.qos.logback.classic.Logger ) LoggerFactory.getLogger( Logger.ROOT_LOGGER_NAME ); logbackLogger.addAppender( appender ); @@ -102,7 +110,6 @@ public class MainAppFrame extends JFrame public MainAppFrame( Context context ) { -// this.ij = context.; this.image = context.getService( ImageDisplayService.class ); this.logService = context.getService( LogService.class ); this.setIconImages( ICONS ); @@ -160,14 +167,12 @@ public class MainAppFrame extends JFrame { ResourceBundle bundle = ResourceBundle.getBundle( "gui" );// access to properties f FXMLLoader loader = new FXMLLoader( MainAppFrame.class.getClassLoader().getResource( "fr.pasteur.ida.zellige.gui.view/Main.fxml" ), bundle ); - VBox rootLayout = loader.load(); // Get the controller and add an ImageJ context to it. MainController< T > controller = loader.getController(); controller.setMainApp( this ); - // Show the scene containing the root layout. scene = new Scene( rootLayout ); this.fxPanel.setScene( scene ); @@ -183,4 +188,6 @@ public class MainAppFrame extends JFrame } + + } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/controller/ConstructionController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/ConstructionController.java index 8a4ec17..1ce2e79 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/controller/ConstructionController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/ConstructionController.java @@ -51,6 +51,7 @@ import org.slf4j.LoggerFactory; import java.net.URL; import java.util.ResourceBundle; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; import static fr.pasteur.ida.zellige.gui.controller.MainController.showError; import static fr.pasteur.ida.zellige.gui.controller.MainController.showInfo; import static fr.pasteur.ida.zellige.gui.controller.SelectionController.setNextOutputToNull; @@ -199,7 +200,7 @@ public class ConstructionController< T extends RealType< T > & NativeType< T > > { disableGUI( true ); - LOGGER.info( "Running construction" ); + LOGGER.info(GUI_MARKER, "Running construction" ); if ( getModel().maximumsProperty().getValue() != null ) { if ( getModel().firstRoundSurfacesProperty().getValue() == null ) @@ -220,7 +221,7 @@ public class ConstructionController< T extends RealType< T > & NativeType< T > > ConstructionDisplayTask< T > task = new ConstructionDisplayTask<>( getModel().referenceSurfacesProperty().getValue() ); task.setOnSucceeded( workerStateEvent -> { - LOGGER.info( "Construction display completed." ); + LOGGER.info(GUI_MARKER, "Construction display completed." ); getModel().getImageViews().setValue( task.getValue() ); parentController.getProjectionController().getModel().getImageViews().set( task.getValue() ); // parentController.getProjectionController().getModel().getReferenceSurfaces(). diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/controller/SelectionController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/SelectionController.java index 034c83b..66059bc 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/controller/SelectionController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/SelectionController.java @@ -53,6 +53,7 @@ import org.slf4j.LoggerFactory; import java.net.URL; import java.util.ResourceBundle; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; import static fr.pasteur.ida.zellige.gui.controller.MainController.showInfo; @@ -283,7 +284,7 @@ public class SelectionController< T extends RealType< T > & NativeType< T > > im SelectionDisplayTask selectionDisplayTask = new SelectionDisplayTask( getModel().selectedPixelsProperty().getValue() ); selectionDisplayTask.setOnSucceeded( workerStateEvent -> { - LOGGER.info( "Double classification done." ); + LOGGER.info( GUI_MARKER,"Double classification done!!!!!." ); getModel().imageViewsProperty().setValue( selectionDisplayTask.getValue() ); setDisplay(); } ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ConstructionInteractor.java b/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ConstructionInteractor.java index d6482ce..d6aa533 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ConstructionInteractor.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ConstructionInteractor.java @@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; import static fr.pasteur.ida.zellige.gui.controller.MainController.showError; public class ConstructionInteractor< T extends RealType< T > & NativeType< T > > @@ -54,7 +55,7 @@ public class ConstructionInteractor< T extends RealType< T > & NativeType< T > > public void secondRound() { - LOGGER.info( "Computing second round construction..." ); + LOGGER.info( GUI_MARKER,"Computing second round construction..." ); if ( model.firstRoundSurfacesProperty().getValue() != null ) { AbstractTask< ArrayList< Surface > > secondRoundTask = new RunSecondConstructionTask( @@ -73,7 +74,7 @@ public class ConstructionInteractor< T extends RealType< T > & NativeType< T > > } else { - LOGGER.info( "Second round construction done." ); + LOGGER.info(GUI_MARKER, "Second round construction done." ); } } ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/model/ConstructionModel.java b/src/main/java/fr/pasteur/ida/zellige/gui/model/ConstructionModel.java index efa62a2..0a2c2b1 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/model/ConstructionModel.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/model/ConstructionModel.java @@ -53,6 +53,8 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class ConstructionModel< T extends RealType< T > & NativeType< T > > { @@ -91,7 +93,7 @@ public class ConstructionModel< T extends RealType< T > & NativeType< T > > public void firstRound() { - LOGGER.info( "Computing first round construction..." ); + LOGGER.info(GUI_MARKER, "Computing first round construction..." ); AbstractTask< ArrayList< Surface > > firstRoundTask = new RunFirstConstructionTask( maximums.getValue(), st1.doubleValue(), r1.intValue(), c1.doubleValue(), surfaceSize.doubleValue() / 100.0 ); firstRoundTask.setOnSucceeded( workerStateEvent -> { @@ -102,14 +104,14 @@ public class ConstructionModel< T extends RealType< T > & NativeType< T > > MainController.showError( new FirstRoundConstructionException() ); } } ); - LOGGER.info( "First round construction done." ); + LOGGER.info( GUI_MARKER,"First round construction done." ); firstRoundTask.start(); } public void secondRound() { - LOGGER.info( "Computing second round construction..." ); + LOGGER.info( GUI_MARKER,"Computing second round construction..." ); AbstractTask< ArrayList< Surface > > secondRoundTask = new RunSecondConstructionTask( firstRoundSurfacesProperty().getValue(), st2.getValue(), r2.intValue(), c2.doubleValue(), surfaceSize.doubleValue() / 100.0 ); secondRoundTask.setOnSucceeded( workerStateEvent -> { @@ -120,7 +122,7 @@ public class ConstructionModel< T extends RealType< T > & NativeType< T > > MainController.showError( new SecondRoundConstructionException() ); } } ); - LOGGER.info( "Second round construction done." ); + LOGGER.info( GUI_MARKER,"Second round construction done." ); secondRoundTask.start(); } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/AmplitudeThresholdingTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/AmplitudeThresholdingTask.java index 3077ef1..52601f9 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/AmplitudeThresholdingTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/AmplitudeThresholdingTask.java @@ -35,6 +35,8 @@ import net.imglib2.type.numeric.real.FloatType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class AmplitudeThresholdingTask extends AbstractTask< Img< BitType > > { @@ -52,9 +54,9 @@ public class AmplitudeThresholdingTask extends AbstractTask< Img< BitType > > @Override protected Img< BitType > call() { - LOGGER.info( "Computing amplitude thresholding..." ); + LOGGER.info(GUI_MARKER, "Computing amplitude thresholding..." ); Img< BitType > output = AmplitudeClassification.applyThreshold( input, amplitudeThreshold ); - LOGGER.info( "Amplitude thresholds computed..." ); + LOGGER.info( GUI_MARKER,"Amplitude thresholds computed..." ); return output; } } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/BinningTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/BinningTask.java index df35175..f017dec 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/BinningTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/BinningTask.java @@ -8,6 +8,8 @@ import net.imglib2.type.numeric.RealType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class BinningTask < T extends RealType< T > & NativeType< T > > extends AbstractTask<Img<T>> { private final static Logger LOGGER = LoggerFactory.getLogger( BinningTask.class ); @@ -22,9 +24,9 @@ public class BinningTask < T extends RealType< T > & NativeType< T > > extends A @Override protected Img<T> call() { - LOGGER.info( "Binning" ); + LOGGER.info( GUI_MARKER,"Binning" ); Img<T> binnedImage = Binning.run( input, bin ); - LOGGER.info( "Image binned !" ); + LOGGER.info( GUI_MARKER,"Image binned !" ); return binnedImage; } } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/ComputeClassificationImagesTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/ComputeClassificationImagesTask.java index e5e69db..e6abffa 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/ComputeClassificationImagesTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/ComputeClassificationImagesTask.java @@ -38,6 +38,8 @@ import net.imglib2.type.numeric.real.FloatType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class ComputeClassificationImagesTask extends AbstractTask< ClassifiedImages< FloatType > > { @@ -53,12 +55,12 @@ public class ComputeClassificationImagesTask extends AbstractTask< ClassifiedIma @Override protected ClassifiedImages< FloatType > call() throws Exception { - LOGGER.info( "Computing classified images..." ); + LOGGER.info( GUI_MARKER,"Computing classified images..." ); ImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() ); ClassifiedImages< FloatType > images = new ClassifiedImages<>(); images.setAmplitudeImg( AmplitudeClassification.computeAmplitudeImage( pretreatedImg, factory ) ); images.setOtsuImg( OtsuClassification.computeOtsuImage( pretreatedImg, factory ) ); - LOGGER.debug( "Classification images computed" ); + LOGGER.debug( GUI_MARKER,"Classification images computed" ); return images; } } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/ConstructionCompletionTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/ConstructionCompletionTask.java index 2e11661..6a3400b 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/ConstructionCompletionTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/ConstructionCompletionTask.java @@ -40,6 +40,8 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class ConstructionCompletionTask< T extends RealType< T > & NativeType< T > > extends AbstractTask< ArrayList< ReferenceSurface< T > > > { private final static Logger LOGGER = LoggerFactory.getLogger( ConstructionCompletionTask.class ); @@ -60,12 +62,12 @@ public class ConstructionCompletionTask< T extends RealType< T > & NativeType< T @Override protected ArrayList< ReferenceSurface< T > > call() { - LOGGER.info( "Processing construction completion..." ); + LOGGER.info( GUI_MARKER,"Processing construction completion..." ); ArrayList< ReferenceSurface< T > > list = ConstructionCompletion.run( input, factory, finalSurfaces , bin); - LOGGER.info( "construction completed..." ); + LOGGER.info(GUI_MARKER, "construction completed..." ); if ( list.isEmpty() ) { - LOGGER.info( "no surfaces..." ); + LOGGER.info( GUI_MARKER,"no surfaces..." ); } return list; diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/InterClassificationTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/InterClassificationTask.java index 129f208..20b064b 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/InterClassificationTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/InterClassificationTask.java @@ -35,6 +35,8 @@ import net.imglib2.type.logic.BitType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class InterClassificationTask extends AbstractTask< Img< BitType > > { @@ -53,7 +55,7 @@ public class InterClassificationTask extends AbstractTask< Img< BitType > > protected Img< BitType > call() { - LOGGER.info( "Computing inter-classification..." ); + LOGGER.info(GUI_MARKER, "Computing inter-classification..." ); return Classification.interClassification( selectedAmplitude.getValue(), selectedAmplitude.getValue().factory(), selectedOtsu.getValue() ); } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/IslandSearchTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/IslandSearchTask.java index def2e08..66a8a4c 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/IslandSearchTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/IslandSearchTask.java @@ -36,6 +36,8 @@ import net.imglib2.type.logic.BitType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class IslandSearchTask extends AbstractTask< Img< BitType > > { @@ -52,9 +54,9 @@ public class IslandSearchTask extends AbstractTask< Img< BitType > > @Override protected Img< BitType > call() { - LOGGER.info( "Computing Island Search..." ); + LOGGER.info( GUI_MARKER,"Computing Island Search..." ); Img< BitType > img = PostTreatment.runIslandSearch( image.getValue(), islandSize.intValue() ); - LOGGER.debug( "Task's end." ); + LOGGER.info( GUI_MARKER,"Task's end." ); return img; // return iSImage; } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/OtsuThresholdingTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/OtsuThresholdingTask.java index 982b552..0c47372 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/OtsuThresholdingTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/OtsuThresholdingTask.java @@ -36,6 +36,8 @@ import net.imglib2.type.numeric.real.FloatType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class OtsuThresholdingTask extends AbstractTask< Img< BitType > > { @@ -55,9 +57,9 @@ public class OtsuThresholdingTask extends AbstractTask< Img< BitType > > @Override protected Img< BitType > call() { - LOGGER.info( "Computing otsu thresholding..." ); + LOGGER.info( GUI_MARKER,"Computing otsu thresholding..." ); Img< BitType > output = OtsuClassification.applyLocalThreshold( pretreatedImage.getValue(), input, otsuThreshold ); - LOGGER.info( "Amplitude thresholds computed..." ); + LOGGER.info( GUI_MARKER,"Amplitude thresholds computed..." ); return output; } } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/PreprocessingTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/PreprocessingTask.java index 8952281..a88b965 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/PreprocessingTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/PreprocessingTask.java @@ -37,6 +37,8 @@ import net.imglib2.type.numeric.real.FloatType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class PreprocessingTask< T extends RealType< T > & NativeType< T > > extends AbstractTask< Img< FloatType > > { @@ -55,10 +57,10 @@ public class PreprocessingTask< T extends RealType< T > & NativeType< T > > exte @Override protected Img< FloatType > call() { - LOGGER.info( "Computing pretreatment..." ); + LOGGER.info(GUI_MARKER, "Computing pretreatment..." ); Img< FloatType > pretreatedImg = Pretreatment.run( input, radius, bin ); - LOGGER.debug( "Done." ); + LOGGER.info( GUI_MARKER,"Done." ); return pretreatedImg; } } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/RunFirstConstructionTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/RunFirstConstructionTask.java index 6b08062..967f50e 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/RunFirstConstructionTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/RunFirstConstructionTask.java @@ -38,6 +38,8 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class RunFirstConstructionTask extends AbstractTask< ArrayList< Surface > > { private final static Logger LOGGER = LoggerFactory.getLogger( RunFirstConstructionTask.class ); @@ -59,7 +61,7 @@ public class RunFirstConstructionTask extends AbstractTask< ArrayList< Surface > @Override protected ArrayList< Surface > call() { - LOGGER.info( "Computing first round construction..." ); + LOGGER.info( GUI_MARKER,"Computing first round construction..." ); FirstRoundConstruction step1 = new FirstRoundConstruction( maximums, startingOsSize1, overlap1, connexityRate1, surfaceMinSizeFactor ); try { @@ -67,7 +69,7 @@ public class RunFirstConstructionTask extends AbstractTask< ArrayList< Surface > } catch ( NoSurfaceFoundException e ) { - LOGGER.info( "First round : No surfaces found..." ); + LOGGER.info( GUI_MARKER,"First round : No surfaces found..." ); return null; } return step1.getSurfaces(); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/RunSecondConstructionTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/RunSecondConstructionTask.java index eb4f672..c9dcd4e 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/RunSecondConstructionTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/RunSecondConstructionTask.java @@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class RunSecondConstructionTask extends AbstractTask< ArrayList< Surface > > { private final static Logger LOGGER = LoggerFactory.getLogger( RunSecondConstructionTask.class ); @@ -58,16 +60,16 @@ public class RunSecondConstructionTask extends AbstractTask< ArrayList< Surface @Override protected ArrayList< Surface > call() { - LOGGER.info( "Computing second round construction..." ); + LOGGER.info( GUI_MARKER,"Computing second round construction..." ); SecondRoundConstruction step2 = new SecondRoundConstruction( surfaces, startingOsSize2, overlap2, connexityRate2, surfaceMinSizeFactor ); try { step2.process(); - LOGGER.info( "Second round : {} surface(s) found", step2.getSurfaces().size() ); + LOGGER.info(GUI_MARKER, "Second round : {} surface(s) found", step2.getSurfaces().size() ); } catch ( NoSurfaceFoundException e ) { - LOGGER.info( "No surface found" ); + LOGGER.info( GUI_MARKER,"No surface found" ); return null; } return step2.getSurfaces(); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/SmoothingTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/SmoothingTask.java index 51535b5..6466287 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/SmoothingTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/SmoothingTask.java @@ -38,6 +38,8 @@ import net.imglib2.type.numeric.real.FloatType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER; + public class SmoothingTask extends AbstractTask<Img < FloatType >> { @@ -56,7 +58,7 @@ public class SmoothingTask extends AbstractTask<Img < FloatType >> @Override protected Img<FloatType> call() throws Exception { - LOGGER.info( "Computing first smoothing..." ); + LOGGER.info( GUI_MARKER,"Computing first smoothing..." ); return PostTreatment.runSmoothing( islandSearchImage.getValue(), sigmaXY.intValue(), sigmaZ.intValue() ); } } diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/Utils.java b/src/main/java/fr/pasteur/ida/zellige/steps/Utils.java index 29c0929..c527c80 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/Utils.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/Utils.java @@ -34,12 +34,8 @@ import net.imglib2.img.Img; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.FloatType; -import net.imglib2.view.IterableRandomAccessibleInterval; -import net.imglib2.view.RandomAccessibleIntervalCursor; import net.imglib2.view.Views; - - /** * Some "utils" methods. */ @@ -85,7 +81,6 @@ public class Utils randomAccess.setPosition( z, 2 ); } - public static < T extends RealType< T > & NativeType< T > > T setPositionAndGet( RandomAccess< T > randomAccess, int u, int v ) { setPosition( randomAccess, u, v ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/Construction.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/Construction.java index f52b373..f1c8a0b 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/Construction.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/Construction.java @@ -1,6 +1,5 @@ package fr.pasteur.ida.zellige.steps.construction; -import fr.pasteur.ida.zellige.ReferenceSurfaceExtraction; import fr.pasteur.ida.zellige.element.ReferenceSurface; import fr.pasteur.ida.zellige.element.Surface; import fr.pasteur.ida.zellige.steps.construction.exception.NoSurfaceFoundException; diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection.java index 6d1cd56..dcdf665 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection.java @@ -43,7 +43,6 @@ import org.slf4j.LoggerFactory; public class ExtremaDetection< T extends RealType< T > & NativeType< T > > { - public static final String MAX = "max"; public static final String MIN = "min"; private final static Logger LOGGER = LoggerFactory.getLogger( ExtremaDetection.class ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection2D.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection2D.java index e4507dc..a2a5495 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection2D.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/util/ExtremaDetection2D.java @@ -40,7 +40,6 @@ import static fr.pasteur.ida.zellige.steps.selection.util.ExtremaDetection.MAX; public class ExtremaDetection2D< T extends RealType< T > & NativeType< T > > { - private final RandomAccessibleInterval< T > inputSection; private final ImgFactory< T > factory; private final RandomAccessibleInterval< T > extrema; @@ -86,15 +85,13 @@ public class ExtremaDetection2D< T extends RealType< T > & NativeType< T > > } } - /** * @param section the section considered * @param sectionDerivative the corresponding partial derivative section of the input image as a {@link RandomAccessibleInterval} */ private void computeExtrema - ( RandomAccessibleInterval< T > section, RandomAccessibleInterval< T > sectionDerivative - ) + ( RandomAccessibleInterval< T > section, RandomAccessibleInterval< T > sectionDerivative ) { RandomAccess< T > derivativeAccess = Views.extendMirrorSingle( sectionDerivative ).randomAccess(); RandomAccess< T > extremaAccess = extrema.randomAccess(); @@ -125,7 +122,7 @@ public class ExtremaDetection2D< T extends RealType< T > & NativeType< T > > * @param z - the index of the Z dimension * @return - true if the position (v, z) is a local maximum false otherwise. */ - private boolean isALocalExtrema( RandomAccess< T > derivative, int z ) //throws Exception + private boolean isALocalExtrema( RandomAccess< T > derivative, int z ) { derivative.setPosition( z, 1 ); final double tZero = derivative.get().getRealDouble(); -- GitLab