diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fccfa6a6aedbf02467344129fa2435fbd8ed4daa..0311a07b1dffbfdb28724b115a350640e0317230 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,11 +27,15 @@ release: stage: versioning when: manual script: - - curl --fail https://raw.githubusercontent.com/scijava/scijava-scripts/main/release-version.sh | bash -s -- --dry-run -# script with dry-run option -# - curl --fail https://raw.githubusercontent.com/scijava/scijava-scripts/main/release-version.sh | bash -s -- --dry-run - - + - git config user.name "$TECHUSER_NAME" + - git config user.email "$TECHUSER_MAIL" + - git remote set-url --push origin "https://oauth2:${TECHUSER_ACCESS_TOKEN}@gitlab.pasteur.fr/ctrebeau/zellige-core.git/" + - curl --fail https://raw.githubusercontent.com/scijava/scijava-scripts/main/valid-semver-bump.sh --output ../valid-semver-bump.sh + - curl --fail https://raw.githubusercontent.com/scijava/scijava-scripts/main/maven-helper.sh --output ../maven-helper.sh + - curl --fail https://raw.githubusercontent.com/scijava/scijava-scripts/main/release-version.sh --output ../release-version.sh + - "chmod +x ../release-version.sh" + - git checkout -f $CI_COMMIT_REF_NAME + - " ../release-version.sh --skip-version-check $MAJOR.$MINOR.$PATCH" pages: image: maven:3.6.3-jdk-11 @@ -47,7 +51,7 @@ pages: - public -ParamaterSweep_mouche: +ParameterSweep_mouche: image: maven:3.6.3-jdk-11 stage: test when: manual @@ -58,7 +62,7 @@ ParamaterSweep_mouche: - target/*.csv -ParamaterSweep_cochlée: +ParameterSweep_cochlée: image: maven:3.6.3-jdk-11 stage: test when: manual @@ -68,7 +72,7 @@ ParamaterSweep_cochlée: paths: - target/*.csv -ParamaterSweep_culture: +ParameterSweep_culture: image: maven:3.6.3-jdk-11 stage: test when: manual @@ -78,7 +82,7 @@ ParamaterSweep_culture: paths: - target/*.csv -ParamaterSweep_organoid: +ParameterSweep_organoid: image: maven:3.6.3-jdk-11 stage: test when: manual @@ -89,7 +93,7 @@ ParamaterSweep_organoid: - target/*.csv -ParamaterSweep_phantom: +ParameterSweep_phantom: image: maven:3.6.3-jdk-11 stage: test when: manual @@ -100,7 +104,7 @@ ParamaterSweep_phantom: - target/*.csv -doubleParamaterSweep: +doubleParameterSweep: image: maven:3.6.3-jdk-11 stage: test when: manual diff --git a/README.md b/README.md index 44efd0aaa7eaddc402e0ccafc6d7c19b026ace38..c33bea00014184bbe8aa7c2dc4ce084149be9791 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -<img src="src/main/resources/icons/Zellige_logo.png" width="150" height="150" alt="drawing"/> +<img src="src/main/resources/icons/Zellige_logo.png" width="408" height="408" alt="drawing"/> # Zellige : 3D fluorescence microscopic images surface extraction tool. diff --git a/pom.xml b/pom.xml index eb5783f2674e69a1edef75d63991fb61b41d859c..6971106d8139ef14d19f7b469448d440cbd270a3 100644 --- a/pom.xml +++ b/pom.xml @@ -39,12 +39,12 @@ <repository> <id>jzy3d-snapshots</id> <name>Jzy3d Snapshots</name> - <url>http://maven.jzy3d.org/snapshots</url> + <url>https://maven.jzy3d.org/snapshots</url> </repository> <repository> <id>jzy3d-releases</id> <name>Jzy3d Releases</name> - <url>http://maven.jzy3d.org/releases</url> + <url>https://maven.jzy3d.org/releases</url> </repository> </repositories> @@ -156,19 +156,19 @@ <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> - <version>1.2.3</version> + <version>1.2.11</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> - <version>5.7.0</version> + <version>5.9.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> - <version>5.7.0</version> + <version>5.9.0</version> </dependency> @@ -180,7 +180,7 @@ <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> - <version>3.13.2</version> + <version>3.23.1</version> <scope>test</scope> </dependency> <dependency> @@ -203,17 +203,17 @@ <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> - <version>17.0.2</version> + <version>18.0.2</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-fxml</artifactId> - <version>17.0.2</version> + <version>18.0.2</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-swing</artifactId> - <version>18-ea+4</version> + <version>18.0.2</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> @@ -263,7 +263,7 @@ <url>https://research.pasteur.fr/fr/member/celine-trebeau/</url> <email>celine.trebeau@pasteur.fr</email> <organization>Institut Pasteur</organization> - <organizationUrl>http://pasteur.fr/</organizationUrl> + <organizationUrl>https://pasteur.fr/</organizationUrl> <roles> <role>lead</role> <role>developer</role> @@ -277,7 +277,7 @@ <email>jean-yves.tinevez@pasteur.fr</email> <url>https://research.pasteur.fr/en/member/jean-yves-tinevez/</url> <organization>Institut Pasteur</organization> - <organizationUrl>http://www.pasteur.fr/</organizationUrl> + <organizationUrl>https://www.pasteur.fr/</organizationUrl> </contributor> </contributors> diff --git a/src/main/java/fr/pasteur/ida/zellige/Main.java b/src/main/java/fr/pasteur/ida/zellige/Main.java index 59cc04cce15792eb0cf66c8bb8608dc811b60512..f685c19fe716e105a0b61623ab0a82ba775fd1fe 100644 --- a/src/main/java/fr/pasteur/ida/zellige/Main.java +++ b/src/main/java/fr/pasteur/ida/zellige/Main.java @@ -55,6 +55,8 @@ public class Main { private final static Logger LOGGER = LoggerFactory.getLogger( Main.class ); + + @SuppressWarnings( "unchecked" ) public static < T extends RealType< T > & NativeType< T > > void main( String[] args ) throws Exception { // Launch ImageJ. @@ -66,7 +68,7 @@ public class Main args[ 0 ]; /* The image path goes here !!!! */ LOGGER.debug( imagePath ); /* JY version for opening files. */ - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); final Img< T > stackImage = ( Img< T > ) imgPlus.getImg(); @@ -138,11 +140,7 @@ public class Main ( stackImage, stackImage.factory() ); rse.select( pretreatmentParameters, classificationParameters, postTreatmentParameters ); rse.construct( constructionParameters ); -// for ( ReferenceSurface< T > referenceSurface : rse.getReferenceSurfaces() ) -// { -// writeHeightMap( referenceSurface.getzMap(), imgPlus.getName(), referenceSurface.getIndex() ); -// } - + rse.project( projectionParameters, displayParameters ); if ( ! GraphicsEnvironment.isHeadless() ) { try diff --git a/src/main/java/fr/pasteur/ida/zellige/ReferenceSurfaceExtraction.java b/src/main/java/fr/pasteur/ida/zellige/ReferenceSurfaceExtraction.java index eb5afa19cc8fbd3f5a1cbd3075003a2685ea78ed..c7c8071e15dc58377e685de773ac11ebb3b3caac 100644 --- a/src/main/java/fr/pasteur/ida/zellige/ReferenceSurfaceExtraction.java +++ b/src/main/java/fr/pasteur/ida/zellige/ReferenceSurfaceExtraction.java @@ -41,25 +41,15 @@ import fr.pasteur.ida.zellige.steps.projection.NoPossibleDisplayException; import fr.pasteur.ida.zellige.steps.projection.ProjectionParameters; import fr.pasteur.ida.zellige.steps.projection.ReferenceSurfaceProjection; import fr.pasteur.ida.zellige.steps.selection.Selection; -import fr.pasteur.ida.zellige.steps.selection.classification.AmplitudeClassification; -import fr.pasteur.ida.zellige.steps.selection.classification.Classification; import fr.pasteur.ida.zellige.steps.selection.classification.ClassificationParameters; -import fr.pasteur.ida.zellige.steps.selection.classification.OtsuClassification; import fr.pasteur.ida.zellige.steps.selection.exception.DataValidationException; -import fr.pasteur.ida.zellige.steps.selection.exception.EmptyOutputException; import fr.pasteur.ida.zellige.steps.selection.exception.NoClassificationException; -import fr.pasteur.ida.zellige.steps.selection.postTreatment.PostTreatment; import fr.pasteur.ida.zellige.steps.selection.postTreatment.PostTreatmentParameters; -import fr.pasteur.ida.zellige.steps.selection.pretreatment.Pretreatment; import fr.pasteur.ida.zellige.steps.selection.pretreatment.PretreatmentParameters; import net.imglib2.RandomAccessibleInterval; -import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; -import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.NativeType; -import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.RealType; -import net.imglib2.type.numeric.real.FloatType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,14 +67,6 @@ public class ReferenceSurfaceExtraction< T extends RealType< T > & NativeType< T private final RandomAccessibleInterval< T > input; private final ImgFactory< T > factory; - private final String filter = "GaussianBlur"; - private final double filterParameter = 2; - private Img< FloatType > pretreatedImg; - private Img< FloatType > amplitudeImg; - private Img< FloatType > otsuImg; - ArrayList< Surface > firstRoundSurfaces; - private Img< BitType > ISImage; - // private FloatType otsuValue; private Pixels[][] maximums; private final static double adequacy = 1; @@ -102,10 +84,6 @@ public class ReferenceSurfaceExtraction< T extends RealType< T > & NativeType< T private int SS_smallSurfaces; private int SS_goodSurfaces; private static final String derivativeMethod = FORWARD; - private Img< BitType > selectedAmplitude; - private Img< BitType > selectedOtsu; - private Img< BitType > selectionOutput; - public ReferenceSurfaceExtraction( RandomAccessibleInterval< T > input, ImgFactory< T > factory ) { @@ -118,76 +96,15 @@ public class ReferenceSurfaceExtraction< T extends RealType< T > & NativeType< T return adequacy; } - public void computeClassificationImages() throws DataValidationException - { - pretreatedImg = Pretreatment.run( input, filterParameter ); - computeImages( pretreatedImg ); - } - private void computeImages( RandomAccessibleInterval< FloatType > input ) throws DataValidationException - { - ImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() ); - amplitudeImg = AmplitudeClassification.computeAmplitudeImage( input, factory ); - otsuImg = OtsuClassification.computeOtsuImage( input, factory ); - } - public void runAmplitudeClassification( int userThreshold ) - { - LOGGER.debug( "Amplitude threshold value after user ={}", userThreshold ); - selectedAmplitude = AmplitudeClassification.applyThreshold( amplitudeImg, userThreshold ); - } - - public void runOtsuClassification( int userThreshold ) - { - selectedOtsu = OtsuClassification.applyLocalThreshold( pretreatedImg, otsuImg, userThreshold ); - } - - public void runInterClassification() - { - selectionOutput = Classification.interClassification( selectedAmplitude, selectedAmplitude.factory(), selectedOtsu ); - LOGGER.debug( "The selected output has been changed" ); - } - - public void runIslandSearch( int islandSize ) - { - ISImage = PostTreatment.runIslandSearch( selectionOutput, islandSize ); - } - - public void runSmoothing( int sigmaXY, int sigmaZ ) throws DataValidationException - { - maximums = PostTreatment.runSmoothing( ISImage, sigmaXY, sigmaZ ); - } - - public void runPostTreatment( double sigmaXY, double sigmaZ, int islandSize ) throws DataValidationException - { - runIslandSearch( islandSize ); - runSmoothing( ( int ) sigmaXY, ( int ) sigmaZ ); -// maximums = PostTreatment.run( selectionOutput, postTreatmentParameters ); - } - - - public void select( PretreatmentParameters pretreatmentParameters, ClassificationParameters classificationParameters, PostTreatmentParameters postTreatmentParameters ) throws NoClassificationException, EmptyOutputException, DataValidationException + public void select( PretreatmentParameters pretreatmentParameters, ClassificationParameters classificationParameters, PostTreatmentParameters postTreatmentParameters ) throws NoClassificationException, DataValidationException { /* First step : Pixel selection */ LOGGER.debug( "Running selection..." ); maximums = Selection.run( input, pretreatmentParameters, classificationParameters, postTreatmentParameters ); } - public void constructFirstRoundSurfaces( double startingSizeThreshold, int overlap, double connexityRate, double surfaceMinSizeFactor ) throws NoSurfaceFoundException - { - FirstRoundConstruction step1 = new FirstRoundConstruction( maximums, startingSizeThreshold, overlap, connexityRate, surfaceMinSizeFactor ); - step1.process(); - firstRoundSurfaces = step1.getSurfaces(); - } - - public void constructSecondRoundSurfacesAndCompletion( double startingSizeThreshold, int overlap, double connexityRate, double surfaceMinSizeFactor ) throws NoSurfaceFoundException - { - SecondRoundConstruction step2 = new SecondRoundConstruction( firstRoundSurfaces, startingSizeThreshold, overlap, connexityRate, surfaceMinSizeFactor ); - step2.process(); - ArrayList< Surface > finalSurfaces = step2.getSurfaces(); - referenceSurfaces.addAll( ConstructionCompletion.run( input, factory, finalSurfaces ) ); - } - public void construct( ConstructionParameters[] constructionParameters ) throws NoSurfaceFoundException { LOGGER.debug( "Running construction..." ); @@ -252,28 +169,11 @@ public class ReferenceSurfaceExtraction< T extends RealType< T > & NativeType< T } } - - public boolean iSisDone() - { - return ISImage != null; - } - - public void resetIS() - { - ISImage = null; - } - - public void setMaximums( Pixels[][] maximums ) { this.maximums = maximums; } - public Img< BitType > getSelectionOutput() - { - return selectionOutput; - } - public ArrayList< ReferenceSurface< T > > getReferenceSurfaces() { return referenceSurfaces; @@ -355,15 +255,6 @@ public class ReferenceSurfaceExtraction< T extends RealType< T > & NativeType< T return SS_startingOS_count; } - public String getFilter() - { - return filter; - } - - public double getFilterParameter() - { - return filterParameter; - } } diff --git a/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java b/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java index a95697e6086a1575bf3019072aaf5f8238ddf98f..25b184117283cb0a1e904bddf2beb3a1320a3d78 100644 --- a/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java +++ b/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java @@ -33,6 +33,7 @@ import fr.pasteur.ida.zellige.gui.MainAppFrame; import net.imagej.ImageJ; import org.scijava.command.ContextCommand; import org.scijava.plugin.Plugin; +import org.scijava.util.VersionUtils; import java.io.File; import java.io.IOException; @@ -58,11 +59,6 @@ public class Zellige extends ContextCommand // Load the image. Object obj = ij.io().open( new File( currentFolder, imageFilePath ).getAbsolutePath() ); - // for large images -// final SCIFIOConfig config = new SCIFIOConfig(); -// config.imgOpenerSetImgModes( SCIFIOConfig.ImgMode.PLANAR ); -// -// final Dataset obj = ij.scifio().datasetIO().open( imageFilePath, config ); // Display it. ij.ui().show( obj ); @@ -76,7 +72,7 @@ public class Zellige extends ContextCommand // Launch JavaFX interface MainAppFrame app = new MainAppFrame( context() ); - app.setTitle( "Zellige v1.0.2" ); + app.setTitle( "Version " + VersionUtils.getVersion( Zellige.class ) ); app.init(); } diff --git a/src/main/java/fr/pasteur/ida/zellige/element/Coordinate.java b/src/main/java/fr/pasteur/ida/zellige/element/Coordinate.java index 43a74d8e9a4ceb5eb96dd6a89d6298c7f452663c..bb1afa8c90010c454e909abd05da5b9cf7ee20a2 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/Coordinate.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/Coordinate.java @@ -93,9 +93,9 @@ public class Coordinate implements Comparable <Coordinate> //extends Pixel /** - * Computes the number of Coordinates which belong to the same surface than the current Pixel instance. + * Computes the number of Coordinates which belong to the same surface as the current Pixel instance. * - * @param pixels - the specified Pixel. + * @param pixels - the specified Pixel. * @param distance - the distance constraint (0 or 1). * @return the number of Coordinates next to the current Pixel. */ @@ -118,8 +118,8 @@ public class Coordinate implements Comparable <Coordinate> //extends Pixel * Determines the Coordinate next to the current Coordinate instance. * * @param nextPixels - the next Pixel instance. - * @param distance - the distance constraint. - * @return a new Pixel containing the coordinates that respects the distance constraint, + * @param distance - the distance constraint. + * @return a new Pixel containing the coordinates that respect the distance constraint, * null if no Coordinates are found. */ public Coordinate getNext( Pixels nextPixels, int distance ) diff --git a/src/main/java/fr/pasteur/ida/zellige/element/Pixels.java b/src/main/java/fr/pasteur/ida/zellige/element/Pixels.java index 6237d12a9f34fb894bcb5cada2191e7ae7a040bb..788becc133b95254cee85fdbf8c1b334ee13136c 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/Pixels.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/Pixels.java @@ -75,8 +75,7 @@ public class Pixels /** - * - * @param pixels - the {@link Pixels} (list of Coordinates to add} + * @param pixels - the {@link Pixels} (list of Coordinates to add to.) */ public void addAll( Pixels pixels ) { 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 541781e997fb581c4ac3b59d4c69d6638002d6d6..6abf64d3dfa9d9290f855dc6cb3a3ff3c0100810 100644 --- a/src/main/java/fr/pasteur/ida/zellige/element/Surface.java +++ b/src/main/java/fr/pasteur/ida/zellige/element/Surface.java @@ -187,7 +187,7 @@ public class Surface /** - * Checks if this object shares a majority of {@link Pixels} with an other {@link Surface} object. + * Checks if this object shares a majority of {@link Pixels} with another {@link Surface} object. * * @param other the other {@link Surface} object. * @return True if both {@link Surface} objects are similar, false otherwise. @@ -211,7 +211,7 @@ public class Surface } /** - * Combines the current instance with an other {@link Surface} instance. + * Combines the current instance with another {@link Surface} instance. * * @param otherSurface - the {@link Surface} to combine with. */ @@ -293,7 +293,7 @@ public class Surface } /** - * Sets the specified {@link SurfaceLine} at the specified index position. If the Surfaline at the specified index + * Sets the specified {@link SurfaceLine} at the specified index position. If the SurfaceLine at the specified index * not null, the both are merged. * * @param index the position of the SurfaceLine 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 e2720c4551502648ea890cad758794179927772d..cd0a7e51252015127a29e42dc18ff97abf2c9e49 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 @@ -195,7 +195,7 @@ public abstract class SurfaceLine } /** - * Combines the current SurfaceLine instance to an other SurfaceLine instance. + * Combines the current SurfaceLine instance to another SurfaceLine instance. * * @param other - the other SurfaceLine. */ 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 29fd5b6575f4ebddeea8f5eb4dda2a1665312f2c..67a5e1c7967c39cfc708397a78237c07b0820d1f 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 @@ -49,15 +49,6 @@ public class SurfaceLineX extends SurfaceLine SurfaceLineX surfaceLineX = new SurfaceLineX( this.getLength(), this.getLine() + direction ); return this.match2( os, overlap, connexity, surfaceLineX ); } - /** - * 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 j - an integer witch indicates the line of the resulting SurfaceLine. - * @param percent - the minimum percentage of match between the OS and the current instance. - * @param matched - the minimum number of matching coordinates. - * @return - a new SurfaceLine if there is a match, null otherwise. - */ /** * Constructor. diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/CheckBoxDisplay.java b/src/main/java/fr/pasteur/ida/zellige/gui/CheckBoxDisplay.java index 8c21045e1d5e3a76c6b5aa34ce1b72f03d1a73a7..4765406574f0eb1893a291ec19f898fce4b803fa 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/CheckBoxDisplay.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/CheckBoxDisplay.java @@ -34,7 +34,7 @@ import javafx.scene.control.CheckBox; public class CheckBoxDisplay extends CheckBox { - private SimpleBooleanProperty notDisplayed = new SimpleBooleanProperty( true ); + private final SimpleBooleanProperty notDisplayed = new SimpleBooleanProperty( true ); // private boolean notDisplayed = true; @@ -43,11 +43,6 @@ public class CheckBoxDisplay extends CheckBox return notDisplayed.getValue(); } - public void disable() - { - notDisplayed.setValue( false ); - } - public void enable() { notDisplayed.setValue( true ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/DisplayController.java b/src/main/java/fr/pasteur/ida/zellige/gui/DisplayController.java deleted file mode 100644 index d239a7d56bf955a4177d1e712dec1bd43b33a4c9..0000000000000000000000000000000000000000 --- a/src/main/java/fr/pasteur/ida/zellige/gui/DisplayController.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.gui; - -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.control.CheckBox; - -import java.net.URL; -import java.util.ResourceBundle; - -public class DisplayController implements Initializable -{ - - @FXML - private CheckBox extractedSurface; - - @FXML - private CheckBox heightMapStack; - - @FXML - private CheckBox heightMapStackMask; - - @FXML - private CheckBox heightmap; - - @FXML - private CheckBox projection; - - @Override - public void initialize( URL url, ResourceBundle resourceBundle ) - { - - } -} 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 e1803dd3cb0165420b5e977111c0fc433f2488e0..66e1c752f7836b0ebab8887604ceaa2515c91e91 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java @@ -30,7 +30,7 @@ package fr.pasteur.ida.zellige.gui; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.encoder.PatternLayoutEncoder; -import fr.pasteur.ida.zellige.steps.selection.exception.DataValidationException; +import fr.pasteur.ida.zellige.gui.controller.MainController; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.fxml.FXMLLoader; @@ -104,13 +104,11 @@ public class MainAppFrame extends JFrame { // this.ij = context.; this.image = context.getService( ImageDisplayService.class ); - ; this.logService = context.getService( LogService.class ); - ; this.setIconImages( ICONS ); } - public static final ImageIcon scaleImage( final ImageIcon icon, final int w, final int h ) + public static ImageIcon scaleImage( final ImageIcon icon, final int w, final int h ) { int nw = icon.getIconWidth(); int nh = icon.getIconHeight(); @@ -129,15 +127,6 @@ public class MainAppFrame extends JFrame return new ImageIcon( icon.getImage().getScaledInstance( nw, nh, Image.SCALE_SMOOTH ) ); } - public LogService getLogService() - { - return logService; - } - - public ImageJ getIj() - { - return ij; - } public ImageDisplayService getImage() { @@ -187,7 +176,7 @@ public class MainAppFrame extends JFrame this.setSize( ( int ) scene.getWidth() + 20, ( int ) scene.getHeight() + 50 ); controller.initExtraction(); } - catch ( IOException | DataValidationException e ) + catch ( IOException e ) { e.printStackTrace(); } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSlider.java b/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSlider.java index 3b59faad38020e3c758e1730deeddd50b864bea5..e030ed336304da7d21670e30cebe29c4abc8b300 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSlider.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSlider.java @@ -44,7 +44,6 @@ import java.io.IOException; public abstract class ParameterSlider extends GridPane { - public static String INTERVAL1 = "[0-9]|[1-4][0-9]|[5][0]"; private final String name; private final int minorTickUnit; private final double majorTickUnit, increment, defaultValue, min, max; @@ -55,7 +54,6 @@ public abstract class ParameterSlider extends GridPane @FXML private TextField textField; private StringProperty userValue; - private DoubleProperty sliderProperty; private Number previousValue = 1; private final String interval; private final PseudoClass errorClass = PseudoClass.getPseudoClass( "error" ); @@ -103,7 +101,7 @@ public abstract class ParameterSlider extends GridPane slider.setShowTickLabels( true ); slider.setMajorTickUnit( majorTickUnit ); slider.setMinorTickCount( minorTickUnit ); - slider.setSnapToTicks( false ); + slider.setSnapToTicks( true ); userValue = textFieldProperty(); textField.getStyleClass().add( "error" ); bindProperties(); @@ -117,11 +115,9 @@ public abstract class ParameterSlider extends GridPane public void listenerSetting() { this.userValueProperty().addListener( event -> - { - this.getTextField().pseudoClassStateChanged( - this.getErrorClass(), ! this.getTextField().getText().matches( this.getInterval() ) - ); - } ); + this.getTextField().pseudoClassStateChanged( + this.getErrorClass(), ! this.getTextField().getText().matches( this.getInterval() ) + ) ); } public abstract void bindProperties(); @@ -155,16 +151,6 @@ public abstract class ParameterSlider extends GridPane return textField.textProperty(); } - public String getLabelText() - { - return labelProperty().get(); - } - - public StringProperty labelProperty() - { - return label.textProperty(); - - } public PseudoClass getErrorClass() { @@ -181,32 +167,11 @@ public abstract class ParameterSlider extends GridPane return slider; } - public double getSliderProperty() - { - return sliderProperty.get(); - } - public DoubleProperty sliderProperty() { return getSlider().valueProperty(); } - - public void setSlider( Slider slider ) - { - this.slider = slider; - } - - public String getUserValue() - { - return userValue.get(); - } - - public void setUserValue( String userValue ) - { - this.userValue.set( userValue ); - } - public StringProperty userValueProperty() { return userValue; diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSliderDouble.java b/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSliderDouble.java index 33be7c2c1bbd71446c3ab4266110dde9598a12f0..5d9e81e7c51d651c87a0aeff46743463fde8c9da 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSliderDouble.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/ParameterSliderDouble.java @@ -67,6 +67,8 @@ public class ParameterSliderDouble extends ParameterSlider @Override public Number fromString( String s ) { + LOGGER.debug( "String value is {}", s ); + LOGGER.debug( "Number value is {}", Double.parseDouble( s ) ); try { return Double.parseDouble( s ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ZDoubleProperty.java b/src/main/java/fr/pasteur/ida/zellige/gui/ZDoubleProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..a9245da5083e4ae0f07a04953a5914e1afd1bd4a --- /dev/null +++ b/src/main/java/fr/pasteur/ida/zellige/gui/ZDoubleProperty.java @@ -0,0 +1,13 @@ +package fr.pasteur.ida.zellige.gui; + +import javafx.beans.property.SimpleDoubleProperty; +import org.apache.commons.math3.util.Precision; + +public class ZDoubleProperty extends SimpleDoubleProperty +{ + public double value() + { + return Precision.round( doubleValue(), 1 ); + + } +} diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ZSlicesSlider.java b/src/main/java/fr/pasteur/ida/zellige/gui/ZSlicesSlider.java index 80e66f279474426e1e55867d9fa991c1405632f2..425f3113c509d7b2696b5d9d9a3ae1fc87465fb6 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ZSlicesSlider.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/ZSlicesSlider.java @@ -41,7 +41,7 @@ public class ZSlicesSlider extends FlowPane @FXML Slider slider; - int userValue; + private int userValue; public ZSlicesSlider() { diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ConstructionController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/ConstructionController.java similarity index 94% rename from src/main/java/fr/pasteur/ida/zellige/gui/ConstructionController.java rename to src/main/java/fr/pasteur/ida/zellige/gui/controller/ConstructionController.java index 36598971132047dae4bb9734e52693052a19476a..e8e514f51a33a0eb1190f6b0c9809f02845fb5ae 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ConstructionController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/ConstructionController.java @@ -26,8 +26,12 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.controller; +import fr.pasteur.ida.zellige.gui.ParameterSliderDouble; +import fr.pasteur.ida.zellige.gui.ParameterSliderInteger; +import fr.pasteur.ida.zellige.gui.model.ConstructionModel; +import fr.pasteur.ida.zellige.gui.parameter.ZelligeParameters; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; import javafx.fxml.FXML; @@ -59,7 +63,7 @@ public class ConstructionController< T extends RealType< T > & NativeType< T > > @FXML private ParameterSliderDouble st2; @FXML - private ParameterSliderDouble surfaceSize; + private ParameterSliderInteger surfaceSize; @Override @@ -138,12 +142,6 @@ public class ConstructionController< T extends RealType< T > & NativeType< T > > } - - public double getSurfaceSize() - { - return surfaceSize.getSlider().getValue(); - } - public ConstructionModel< T > getConstructionModel() { return constructionModel; diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/MainController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/MainController.java similarity index 66% rename from src/main/java/fr/pasteur/ida/zellige/gui/MainController.java rename to src/main/java/fr/pasteur/ida/zellige/gui/controller/MainController.java index c6d5d2c3b61e89e0249baa6af39d8cb4ab825050..da59a7a492cb327655edfb319c1ad9fb2a35ff77 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/MainController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/MainController.java @@ -26,19 +26,25 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.controller; +import fr.pasteur.ida.zellige.gui.ClassifiedImages; +import fr.pasteur.ida.zellige.gui.LogAppender; +import fr.pasteur.ida.zellige.gui.MainAppFrame; import fr.pasteur.ida.zellige.gui.exception.NoA3DStackException; import fr.pasteur.ida.zellige.gui.exception.NoInputException; +import fr.pasteur.ida.zellige.gui.model.ConstructionModel; +import fr.pasteur.ida.zellige.gui.model.MainModel; +import fr.pasteur.ida.zellige.gui.model.ProjectionModel; +import fr.pasteur.ida.zellige.gui.model.SelectionModel; +import fr.pasteur.ida.zellige.gui.parameter.ConstructionParameter; +import fr.pasteur.ida.zellige.gui.parameter.ProjectionParameter; +import fr.pasteur.ida.zellige.gui.parameter.SelectionParameter; +import fr.pasteur.ida.zellige.gui.parameter.ZelligeParameters; import fr.pasteur.ida.zellige.gui.task.AbstractTask; import fr.pasteur.ida.zellige.gui.task.ComputeClassificationImagesTask; import fr.pasteur.ida.zellige.gui.task.DisplayDatasetChoicesTask; import fr.pasteur.ida.zellige.gui.task.PretreatmentTask; -import fr.pasteur.ida.zellige.steps.construction.exception.NoSurfaceFoundException; -import fr.pasteur.ida.zellige.steps.projection.NoPossibleDisplayException; -import fr.pasteur.ida.zellige.steps.selection.exception.DataValidationException; -import fr.pasteur.ida.zellige.steps.selection.exception.EmptyOutputException; -import fr.pasteur.ida.zellige.steps.selection.exception.NoClassificationException; import javafx.application.Platform; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleObjectProperty; @@ -89,7 +95,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme @FXML private ProjectionController< T > projectionController; @FXML - private SelectionController selectionController; + private SelectionController< T > selectionController; MainModel< T > model; @@ -154,16 +160,9 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme // run button initialization runButton.setOnAction( actionEvent -> { - try - { - disableGUI.setValue( true ); - changedParameters.setValue( false ); - run2(); - } - catch ( DataValidationException | EmptyOutputException | NoClassificationException | NoSurfaceFoundException | NoPossibleDisplayException e ) - { - showError( e ); - } + disableGUI.setValue( true ); + changedParameters.setValue( false ); + run2(); } ); /* Binding properties*/ @@ -195,101 +194,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme logInfo.setText( LogAppender.getLogMessage() ) ) ); } - // public void run() throws DataValidationException, EmptyOutputException, NoClassificationException, NoSurfaceFoundException, NoPossibleDisplayException -// { -// long[] dims = new long[ currentDataset.numDimensions() ]; -// currentDataset.dimensions( dims ); -// mainAppFrame.getLogService().info( "Zellige received the image: " + currentDataset.getName() ); -// mainAppFrame.getLogService().info( "Size: " + Util.printInterval( currentDataset ) ); -// mainAppFrame.getLogService().info( "Type: " + currentDataset.firstElement().getClass().toGenericString() ); -// mainAppFrame.getLogService().info( "Dimensionality: " + currentDataset.numDimensions() + "D" ); -// for ( int d = 0; d < currentDataset.numDimensions(); d++ ) -// { -// mainAppFrame.getLogService().info( " - dimension " + d + ": [" + currentDataset.axis( d ).type() + "], 1 unit = " + currentDataset.averageScale( d ) + " " + currentDataset.axis( d ).unit() ); -// } -// // Fixed parameters -// String filter = "GaussianBlur"; -// double filterParameter = 2; -// // End of fixed parameters -// int connexity = 4; -// -// double startingOsSize1 = constructionController.getSt1(); -// int overlap1 = constructionController.getR1(); -// double connexityRate1 = constructionController.getC1(); -// double startingOsSize2 = constructionController.getSt2(); -// int overlap2 = constructionController.getR2(); -// double connexityRate2 = constructionController.getC2(); -// double surfaceMinSizeFactor = constructionController.getSurfaceSize(); -// int delta = projectionController.getDelta(); -// String method = projectionController.getMethod(); -// /* Print parameters.*/ -// mainAppFrame.getLogService().info( "Input : " + currentDataset.getName() ); -// mainAppFrame.getLogService().info( "filter : " + filter ); -// mainAppFrame.getLogService().info( "filterParameter : " + filterParameter ); -// mainAppFrame.getLogService().info( "amplitude : " + getAmplitude() ); -// mainAppFrame.getLogService().info( "threshold : " + getOtsu() ); -// mainAppFrame.getLogService().info( "connexity : " + connexity ); -// mainAppFrame.getLogService().info( "islandSize : " + getIsland() ); -// mainAppFrame.getLogService().info( "sigmaXY : " + getSigmaXY() ); -// mainAppFrame.getLogService().info( "sigmaZ : " + getSigmaZ() ); -// mainAppFrame.getLogService().info( "startingOsSize1 : " + startingOsSize1 ); -// mainAppFrame.getLogService().info( "overlap1 : " + overlap1 ); -// mainAppFrame.getLogService().info( "connexityRate1 : " + connexityRate1 ); -// mainAppFrame.getLogService().info( "startingOsSize2 : " + startingOsSize2 ); -// mainAppFrame.getLogService().info( "overlap2 : " + overlap2 ); -// mainAppFrame.getLogService().info( "connexityRate2 : " + connexityRate2 ); -// mainAppFrame.getLogService().info( "surfaceMinimumSizeFactor : " + surfaceMinSizeFactor ); -// mainAppFrame.getLogService().info( "delta : " + delta + "\n" ); -// /* End of Print parameters.*/ -// -// SimpleObjectProperty<Pixels[][]> pixelsProperty = new SimpleObjectProperty<>(); -// fromIslandSearch(); -//// AbstractTask< Pixels[][] > runPostTreatmentTask = new RunPostTreatmentTask<>( extraction, getSigmaXY(), getSigmaZ(), getIsland(), connexity ); -//// runPostTreatmentTask.setOnSucceeded( workerStateEvent -> -//// { -//// AbstractTask< ArrayList< Surface > > runFirstConstructionTask = new RunFirstConstructionTask( -//// runPostTreatmentTask.getValue(), -//// startingOsSize1, -//// overlap1, -//// connexityRate1, -//// surfaceMinSizeFactor ); -//// runFirstConstructionTask.setOnSucceeded( workerStateEvent2 -> -//// { -//// AbstractTask< ArrayList< Surface > > runSecondConstructionTask = new RunSecondConstructionTask( -//// runFirstConstructionTask.getValue(), -//// startingOsSize2, -//// overlap2, -//// connexityRate2, -//// surfaceMinSizeFactor ); -//// runSecondConstructionTask.setOnSucceeded( workerStateEvent3 -> -//// { -//// ImgPlus< T > input = ( ImgPlus< T > ) currentDataset.getImgPlus(); -//// AbstractTask< ArrayList< ReferenceSurface< T > > > constructionCompletionTask = new ConstructionCompletionTask<>( input, input.factory(), runSecondConstructionTask.getValue() ); -//// constructionCompletionTask.setOnSucceeded( workerStateEvent4 -> -//// { -//// extraction.getReferenceSurfaces().addAll( constructionCompletionTask.getValue() ); -//// AbstractTask< Void > projectionTask = new ProjectionTask<>( constructionCompletionTask.getValue(), delta, method, -//// projectionController.getProjection(), -//// projectionController.getRawHeightmap(), -//// projectionController.getExtractedHeightMap(), -//// projectionController.getReduced3DSpace(), -//// projectionController.getSegmentedSurface(), -//// projectionController.getSegmentedSurfaceMask(), -//// projectionController.getDelta2() ); -//// projectionTask.start(); -//// } ); -//// constructionCompletionTask.start(); -//// } ); -//// runSecondConstructionTask.start(); -//// -//// } ); -//// runFirstConstructionTask.start(); -//// } ); -//// runPostTreatmentTask.start(); -// -// } - - public void initExtraction() throws DataValidationException + public void initExtraction() { LOGGER.debug( "Init Extraction" ); @@ -350,7 +255,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme // mainAppFrame.getLogService().info( "delta : " + delta + "\n" ); // /* End of Print parameters.*/ - public void run2() throws DataValidationException, EmptyOutputException, NoClassificationException, NoSurfaceFoundException, NoPossibleDisplayException + public void run2() { if ( selectionController.getSelectionModel().selectedPixelsProperty().getValue() != null ) @@ -399,6 +304,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme displayTask.start(); } + @SuppressWarnings( "unchecked" ) public void setCurrentDataset( Dataset dataset ) { if ( dataset != currentDataset.getValue() ) @@ -445,30 +351,40 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme return ( int ) selectionController.getIsland().getSlider().getValue(); } - public int getSigmaXY() - { - return ( int ) selectionController.getXyBlur().getSlider().getValue(); - } - - public int getSigmaZ() - { - return ( int ) selectionController.getzBlur().getSlider().getValue(); - } - @FXML public void saveParameters() throws IOException { SimpleDateFormat dtf = new SimpleDateFormat( "yyyyMMdd_HHmmss" ); - FileChooser fileChooser = chooseAFile( dtf.format( new Date() ) + "_zellige_param", "Sava Parameters...", "ZelligeParameters", "*.json" ); + FileChooser fileChooser = chooseAFile( dtf.format( new Date() ) + "_zellige_param", "Sava Parameters..." ); File file = fileChooser.showSaveDialog( null ); if ( file != null ) { - ZelligeParameters.serialize( new ZelligeParameters( model ), file ); + SelectionParameter sp = build( model.getSelectionModel() ); + ConstructionParameter cp = build( model.getConstructionModel() ); + ProjectionParameter pp = build( model.getProjectionModel() ); + + ZelligeParameters.serialize( new ZelligeParameters( sp, cp, pp ), file ); } } + + private SelectionParameter build( SelectionModel model ) + { + return new SelectionParameter( model.amplitudeProperty(), model.otsuProperty(), model.islandProperty(), model.xyBlurProperty(), model.zBlurProperty() ); + } + + private ConstructionParameter build( ConstructionModel< T > model ) + { + return new ConstructionParameter( model.c1Property(), model.r1Property(), model.st1Property(), model.c2Property(), model.r2Property(), model.st2Property(), model.surfaceSizeProperty() ); + } + + private ProjectionParameter build( ProjectionModel< T > model ) + { + return new ProjectionParameter( model.delta1Property(), model.delta2Property(), model.methodProperty() ); + } + @FXML - public void loadParameters() throws IOException, ClassNotFoundException + public void loadParameters() throws IOException { File f = chooseFile(); LOGGER.debug( "The file has been choose" ); @@ -481,17 +397,17 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme private File chooseFile() { - FileChooser fileChooser = chooseAFile( null, "Select a Zellige parameter file", - "ZelligeParameters", "*.json" ); + FileChooser fileChooser = chooseAFile( null, "Select a Zellige parameter file" + ); return fileChooser.showOpenDialog( null ); } - private FileChooser chooseAFile( String initialFileNme, String title, String description, String extension ) + private FileChooser chooseAFile( String initialFileNme, String title ) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle( title ); fileChooser.setInitialFileName( initialFileNme ); - FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter( description, extension ); + FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter( "ZelligeParameters", "*.json" ); fileChooser.getExtensionFilters().add( extFilter ); return fileChooser; } @@ -500,6 +416,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme { selectionController.setParameters( parameters ); constructionController.setParameters( parameters ); + projectionController.setParameters( parameters ); } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ProjectionController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/ProjectionController.java similarity index 94% rename from src/main/java/fr/pasteur/ida/zellige/gui/ProjectionController.java rename to src/main/java/fr/pasteur/ida/zellige/gui/controller/ProjectionController.java index 267a05cc319f66f653f74642700309f7a4c03649..2e312d5fae1a68f5fe6675a81910929c06f4c8e0 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ProjectionController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/ProjectionController.java @@ -26,8 +26,11 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.controller; +import fr.pasteur.ida.zellige.gui.CheckBoxDisplay; +import fr.pasteur.ida.zellige.gui.model.ProjectionModel; +import fr.pasteur.ida.zellige.gui.parameter.ZelligeParameters; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.collections.FXCollections; @@ -240,4 +243,11 @@ public class ProjectionController< T extends RealType< T > & NativeType< T > > i selected.bind( checkBox.selectedProperty() ); notDisplayed.bindBidirectional( checkBox.notDisplayedProperty() ); } + + public void setParameters( ZelligeParameters parameters ) + { + delta1.getValueFactory().setValue( parameters.getDelta1() ); + delta2.getValueFactory().setValue( parameters.getDelta2() ); + methodComboBox.getSelectionModel().select( parameters.getMethod() ); + } } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/SelectionController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/SelectionController.java similarity index 95% rename from src/main/java/fr/pasteur/ida/zellige/gui/SelectionController.java rename to src/main/java/fr/pasteur/ida/zellige/gui/controller/SelectionController.java index 9c83aca5bebdd08d497e1b55d004e2f1a10bae0f..92576a425b56a41737b522a5459f4138c18f31f3 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/SelectionController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/SelectionController.java @@ -26,8 +26,12 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.controller; +import fr.pasteur.ida.zellige.gui.ParameterSliderInteger; +import fr.pasteur.ida.zellige.gui.ZSlicesSlider; +import fr.pasteur.ida.zellige.gui.model.SelectionModel; +import fr.pasteur.ida.zellige.gui.parameter.ZelligeParameters; import fr.pasteur.ida.zellige.gui.task.ImageFXDisplayTask; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; @@ -37,14 +41,16 @@ import javafx.geometry.Pos; import javafx.scene.image.ImageView; import javafx.scene.layout.FlowPane; import net.imglib2.img.Img; +import net.imglib2.type.NativeType; import net.imglib2.type.logic.BitType; +import net.imglib2.type.numeric.RealType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.net.URL; import java.util.ResourceBundle; -public class SelectionController implements Initializable +public class SelectionController< T extends RealType< T > & NativeType< T > > implements Initializable { private final static Logger LOGGER = LoggerFactory.getLogger( SelectionController.class ); @@ -231,7 +237,7 @@ public class SelectionController implements Initializable public void setDisplay() { stack.getChildren().clear(); - ImageView i = selectionModel.imageViewsProperty().getValue()[ zSlices.userValue ]; + ImageView i = selectionModel.imageViewsProperty().getValue()[ zSlices.getUserValue() ]; stack.getChildren().add( i ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/exception/NotANumberException.java b/src/main/java/fr/pasteur/ida/zellige/gui/exception/NotANumberException.java index c434df0f0b69b45340efb3ba4c2a71ccfdf6416b..62acf2a112ca169ed5a6a2cfb7d527e6ec8873a8 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/exception/NotANumberException.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/exception/NotANumberException.java @@ -31,12 +31,10 @@ package fr.pasteur.ida.zellige.gui.exception; public class NotANumberException extends Exception { - private final String message = "Please enter a number !"; - @Override public String getMessage() { - return message; + return "Please enter a number !"; } } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ConstructionModel.java b/src/main/java/fr/pasteur/ida/zellige/gui/model/ConstructionModel.java similarity index 76% rename from src/main/java/fr/pasteur/ida/zellige/gui/ConstructionModel.java rename to src/main/java/fr/pasteur/ida/zellige/gui/model/ConstructionModel.java index 7f87307dece15d5f745142ea6d2e4475135028d7..d54f6b6a881ca2c3dc92f48d429736429e748d86 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ConstructionModel.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/model/ConstructionModel.java @@ -26,19 +26,21 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.model; import fr.pasteur.ida.zellige.element.Pixels; import fr.pasteur.ida.zellige.element.ReferenceSurface; import fr.pasteur.ida.zellige.element.Surface; +import fr.pasteur.ida.zellige.gui.ZDoubleProperty; +import fr.pasteur.ida.zellige.gui.controller.MainController; import fr.pasteur.ida.zellige.gui.task.AbstractTask; import fr.pasteur.ida.zellige.gui.task.ConstructionCompletionTask; import fr.pasteur.ida.zellige.gui.task.RunFirstConstructionTask; import fr.pasteur.ida.zellige.gui.task.RunSecondConstructionTask; import fr.pasteur.ida.zellige.steps.construction.exception.FirstRoundConstructionException; import fr.pasteur.ida.zellige.steps.construction.exception.SecondRoundConstructionException; -import javafx.beans.property.DoubleProperty; -import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.ImgFactory; @@ -54,35 +56,35 @@ public class ConstructionModel< T extends RealType< T > & NativeType< T > > private final static Logger LOGGER = LoggerFactory.getLogger( ConstructionModel.class ); - private final DoubleProperty c1; - private final DoubleProperty c2; - private final DoubleProperty r1; - private final DoubleProperty r2; - private final DoubleProperty st1; - private final DoubleProperty st2; - private final DoubleProperty surfaceSize; + private final ZDoubleProperty c1; + private final ZDoubleProperty c2; + private final IntegerProperty r1; + private final IntegerProperty r2; + private final ZDoubleProperty st1; + private final ZDoubleProperty st2; + private final ZDoubleProperty surfaceSize; private final SimpleObjectProperty< ArrayList< Surface > > firstRoundSurfaces = new SimpleObjectProperty<>(); private final SimpleObjectProperty< ArrayList< Surface > > secondRoundSurfaces = new SimpleObjectProperty<>(); private final SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > referenceSurfaces = new SimpleObjectProperty<>(); - SimpleObjectProperty< Pixels[][] > maximums = new SimpleObjectProperty<>(); + private final SimpleObjectProperty< Pixels[][] > maximums = new SimpleObjectProperty<>(); private RandomAccessibleInterval< T > input; private ImgFactory< T > factory; public ConstructionModel() { - c1 = new SimpleDoubleProperty(); - c2 = new SimpleDoubleProperty(); - r1 = new SimpleDoubleProperty(); - r2 = new SimpleDoubleProperty(); - st1 = new SimpleDoubleProperty(); - st2 = new SimpleDoubleProperty(); - surfaceSize = new SimpleDoubleProperty(); + c1 = new ZDoubleProperty(); + c2 = new ZDoubleProperty(); + r1 = new SimpleIntegerProperty(); + r2 = new SimpleIntegerProperty(); + st1 = new ZDoubleProperty(); + st2 = new ZDoubleProperty(); + surfaceSize = new ZDoubleProperty(); } public void firstRound() { LOGGER.info( "Computing first round construction..." ); - AbstractTask< ArrayList< Surface > > firstRoundTask = new RunFirstConstructionTask( maximums.getValue(), st1.doubleValue(), r1.intValue(), c1.doubleValue(), surfaceSize.doubleValue() ); + AbstractTask< ArrayList< Surface > > firstRoundTask = new RunFirstConstructionTask( maximums.getValue(), st1.doubleValue(), r1.intValue(), c1.doubleValue(), surfaceSize.doubleValue() / 100.0 ); firstRoundTask.setOnSucceeded( workerStateEvent -> { firstRoundSurfaces.setValue( firstRoundTask.getValue() ); @@ -100,7 +102,7 @@ public class ConstructionModel< T extends RealType< T > & NativeType< T > > public void secondRound() { LOGGER.info( "Computing second round construction..." ); - AbstractTask< ArrayList< Surface > > secondRoundTask = new RunSecondConstructionTask( firstRoundSurfacesProperty().getValue(), st2.getValue(), r2.intValue(), c2.doubleValue(), surfaceSize.doubleValue() ); + AbstractTask< ArrayList< Surface > > secondRoundTask = new RunSecondConstructionTask( firstRoundSurfacesProperty().getValue(), st2.getValue(), r2.intValue(), c2.doubleValue(), surfaceSize.doubleValue() / 100.0 ); secondRoundTask.setOnSucceeded( workerStateEvent -> { secondRoundSurfacesProperty().setValue( secondRoundTask.getValue() ); @@ -136,129 +138,81 @@ public class ConstructionModel< T extends RealType< T > & NativeType< T > > constructionCompletionTask.start(); } - public double getC1() - { - return c1.get(); - } - public DoubleProperty c1Property() + public ZDoubleProperty c1Property() { return c1; } - public double getC2() - { - return c2.get(); - } - - public DoubleProperty c2Property() + public ZDoubleProperty c2Property() { return c2; } - public double getR1() - { - return r1.get(); - } - - public DoubleProperty r1Property() + public IntegerProperty r1Property() { return r1; } - public double getR2() - { - return r2.get(); - } - - public DoubleProperty r2Property() + public IntegerProperty r2Property() { return r2; } - public double getSt1() - { - return st1.get(); - } - - public DoubleProperty st1Property() + public ZDoubleProperty st1Property() { return st1; } - public double getSt2() - { - return st2.get(); - } - - public DoubleProperty st2Property() + public ZDoubleProperty st2Property() { return st2; } - public double getSurfaceSize() - { - return surfaceSize.get(); - } - - public DoubleProperty surfaceSizeProperty() + public ZDoubleProperty surfaceSizeProperty() { return surfaceSize; } - public ArrayList< Surface > getFirstRoundSurfaces() - { - return firstRoundSurfaces.get(); - } - public SimpleObjectProperty< ArrayList< Surface > > firstRoundSurfacesProperty() { return firstRoundSurfaces; } - public ArrayList< Surface > getSecondRoundSurfaces() - { - return secondRoundSurfaces.get(); - } - public SimpleObjectProperty< ArrayList< Surface > > secondRoundSurfacesProperty() { return secondRoundSurfaces; } - public ArrayList< ReferenceSurface< T > > getReferenceSurfaces() - { - return referenceSurfaces.get(); - } - public SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > referenceSurfacesProperty() { return referenceSurfaces; } - public RandomAccessibleInterval< T > getInput() + public void setInput( RandomAccessibleInterval< T > input ) { - return input; + this.input = input; } - public void setInput( RandomAccessibleInterval< T > input ) + + public void setFactory( ImgFactory< T > factory ) { - this.input = input; + this.factory = factory; } - public ImgFactory< T > getFactory() + public double getC1() { - return factory; + return c1.get(); } - public void setFactory( ImgFactory< T > factory ) + public RandomAccessibleInterval< T > getInput() { - this.factory = factory; + return input; } - public Pixels[][] getMaximums() + public ImgFactory< T > getFactory() { - return maximums.get(); + return factory; } public SimpleObjectProperty< Pixels[][] > maximumsProperty() diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/MainModel.java b/src/main/java/fr/pasteur/ida/zellige/gui/model/MainModel.java similarity index 98% rename from src/main/java/fr/pasteur/ida/zellige/gui/MainModel.java rename to src/main/java/fr/pasteur/ida/zellige/gui/model/MainModel.java index 57762809ebb881c56746c300c3c536dd04b0dcfd..3d0934940b8f40b1afd27cc19004f8a41f7ef727 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/MainModel.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/model/MainModel.java @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.model; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ProjectionModel.java b/src/main/java/fr/pasteur/ida/zellige/gui/model/ProjectionModel.java similarity index 99% rename from src/main/java/fr/pasteur/ida/zellige/gui/ProjectionModel.java rename to src/main/java/fr/pasteur/ida/zellige/gui/model/ProjectionModel.java index 4b3e6d90fd2b7f78c38f68541bc1885f6d8335bb..1c48ffe29728f4cf8dc458daddaa6edcbefbf7df 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ProjectionModel.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/model/ProjectionModel.java @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.model; import fr.pasteur.ida.zellige.element.Projection; import fr.pasteur.ida.zellige.element.ReferenceSurface; diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/SelectionModel.java b/src/main/java/fr/pasteur/ida/zellige/gui/model/SelectionModel.java similarity index 99% rename from src/main/java/fr/pasteur/ida/zellige/gui/SelectionModel.java rename to src/main/java/fr/pasteur/ida/zellige/gui/model/SelectionModel.java index a86aca3f7fd07aa2fb0486c2d7fecffd3b852819..4b1d8d341d4bc8fb020e1d7385782beb48b2dd9d 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/SelectionModel.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/model/SelectionModel.java @@ -26,9 +26,10 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.model; import fr.pasteur.ida.zellige.element.Pixels; +import fr.pasteur.ida.zellige.gui.ClassifiedImages; import fr.pasteur.ida.zellige.gui.task.*; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleBooleanProperty; diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ConstructionParameter.java b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ConstructionParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..d665ebdcc0097642917c6e5735b5b1498f638222 --- /dev/null +++ b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ConstructionParameter.java @@ -0,0 +1,62 @@ +package fr.pasteur.ida.zellige.gui.parameter; + +import fr.pasteur.ida.zellige.gui.ZDoubleProperty; +import javafx.beans.property.IntegerProperty; + +public class ConstructionParameter +{ + + private final double c1; + private final int r1; + private final double st1; + private final double c2; + private final int r2; + private final double st2; + private final int surfaceSize; + + public ConstructionParameter( ZDoubleProperty c1, IntegerProperty r1, ZDoubleProperty st1, ZDoubleProperty c2, IntegerProperty r2, ZDoubleProperty st2, ZDoubleProperty surfaceSize ) + { + this.c1 = c1.value(); + this.r1 = r1.intValue(); + this.st1 = st1.value(); + this.c2 = c2.value(); + this.r2 = r2.intValue(); + this.st2 = st2.value(); + this.surfaceSize = surfaceSize.intValue(); + } + + public double getC1() + { + return c1; + } + + public int getR1() + { + return r1; + } + + public double getSt1() + { + return st1; + } + + public double getC2() + { + return c2; + } + + public int getR2() + { + return r2; + } + + public double getSt2() + { + return st2; + } + + public int getSurfaceSize() + { + return surfaceSize; + } +} diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ProjectionParameter.java b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ProjectionParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..a9fd199bdd1d159eec908966c5128d7ccdac4055 --- /dev/null +++ b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ProjectionParameter.java @@ -0,0 +1,34 @@ +package fr.pasteur.ida.zellige.gui.parameter; + +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.StringProperty; + +public class ProjectionParameter +{ + + private final int delta1; + private final int delta2; + private final String method; + + public ProjectionParameter( IntegerProperty delta1, IntegerProperty delta2, StringProperty method ) + { + this.delta1 = delta1.intValue(); + this.delta2 = delta2.intValue(); + this.method = method.get(); + } + + public int getDelta1() + { + return delta1; + } + + public int getDelta2() + { + return delta2; + } + + public String getMethod() + { + return method; + } +} diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/parameter/SelectionParameter.java b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/SelectionParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..1af00ac5cc7ad7ae8d140f087ebfbb023e37bdb3 --- /dev/null +++ b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/SelectionParameter.java @@ -0,0 +1,46 @@ +package fr.pasteur.ida.zellige.gui.parameter; + +import javafx.beans.property.DoubleProperty; + +public class SelectionParameter +{ + private final int amplitude; + private final int otsu; + private final int island; + private final int xyBlur; + private final int zBlur; + + public SelectionParameter( DoubleProperty amplitude, DoubleProperty otsu, DoubleProperty island, DoubleProperty xyBlur, DoubleProperty zBlur ) + { + this.amplitude = amplitude.intValue(); + this.otsu = otsu.intValue(); + this.island = island.intValue(); + this.xyBlur = xyBlur.intValue(); + this.zBlur = zBlur.intValue(); + } + + public int getAmplitude() + { + return amplitude; + } + + public int getOtsu() + { + return otsu; + } + + public int getIsland() + { + return island; + } + + public int getXyBlur() + { + return xyBlur; + } + + public int getzBlur() + { + return zBlur; + } +} diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/ZelligeParameters.java b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ZelligeParameters.java similarity index 66% rename from src/main/java/fr/pasteur/ida/zellige/gui/ZelligeParameters.java rename to src/main/java/fr/pasteur/ida/zellige/gui/parameter/ZelligeParameters.java index a7cb76be31cea74cebf964fc53d7aba2d46f9264..23fb31197cd66e3dfed658bedc75c1528f754477 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/ZelligeParameters.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/parameter/ZelligeParameters.java @@ -6,13 +6,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,15 +26,18 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package fr.pasteur.ida.zellige.gui; +package fr.pasteur.ida.zellige.gui.parameter; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import java.io.*; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Collectors; +import java.util.stream.Stream; public class ZelligeParameters { @@ -52,39 +55,36 @@ public class ZelligeParameters private final double c2; private final int r2; private final double st2; - private final double surfaceSize; + private final int surfaceSize; //projection private final int delta1; private final int delta2; private final String method; - public ZelligeParameters( MainModel model ) + public ZelligeParameters( SelectionParameter sp, ConstructionParameter cp, ProjectionParameter pp ) { - - SelectionModel selectionModel = model.getSelectionModel(); - ConstructionModel constructionModel = model.getConstructionModel(); - ProjectionModel projectionModel = model.getProjectionModel(); // selection - amplitude = selectionModel.amplitudeProperty().intValue(); - otsu = selectionModel.otsuProperty().intValue(); - island = selectionModel.islandProperty().intValue(); - xyBlur = selectionModel.xyBlurProperty().intValue(); - zBlur = selectionModel.zBlurProperty().intValue(); + amplitude = sp.getAmplitude(); + otsu = sp.getOtsu(); + island = sp.getIsland(); + xyBlur = sp.getXyBlur(); + zBlur = sp.getzBlur(); // construction - c1 = constructionModel.c1Property().doubleValue(); - r1 = constructionModel.r1Property().intValue(); - st1 = constructionModel.st1Property().doubleValue(); - c2 = constructionModel.c2Property().doubleValue(); - r2 = constructionModel.r2Property().intValue(); - st2 = constructionModel.st2Property().doubleValue(); - surfaceSize = constructionModel.surfaceSizeProperty().doubleValue(); + c1 = cp.getC1(); + r1 = cp.getR1(); + st1 = cp.getSt1(); + c2 = cp.getC2(); + r2 = cp.getR2(); + st2 = cp.getSt2(); + surfaceSize = cp.getSurfaceSize(); // projection - delta1 = projectionModel.delta1Property().intValue(); - delta2 = projectionModel.delta2Property().intValue(); - method = projectionModel.methodProperty().get(); + delta1 = pp.getDelta1(); + delta2 = pp.getDelta2(); + method = pp.getMethod(); } + public static void serialize( final ZelligeParameters parameters, final File file ) throws IOException { final Gson gson = new GsonBuilder().setPrettyPrinting().create(); @@ -94,22 +94,24 @@ public class ZelligeParameters { writer.append( str ); } - } - - public static ZelligeParameters deserialize( final File file ) throws FileNotFoundException, IOException, ClassNotFoundException + public static ZelligeParameters deserialize( final File file + ) throws IOException, SecurityException { - try ( FileReader ignored = new FileReader( file ) ) + try ( Stream< String > streams = Files.lines( Paths.get( file.getAbsolutePath() ) ) ) { - final String str = Files.lines( Paths.get( file.getAbsolutePath() ) ) - .collect( Collectors.joining( System.lineSeparator() ) ); + if ( streams != null ) + { + String s = streams.collect( Collectors.joining( System.lineSeparator() ) ); + final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + return ( s.isEmpty() ) + ? null + : gson.fromJson( s, ZelligeParameters.class ); + } - return ( str == null || str.isEmpty() ) - ? null - : gson.fromJson( str, ZelligeParameters.class ); + return null; } } @@ -173,6 +175,11 @@ public class ZelligeParameters return surfaceSize; } + public String getMethod() + { + return method; + } + public int getDelta1() { return delta1; @@ -182,9 +189,4 @@ public class ZelligeParameters { return delta2; } - - public String getMethod() - { - return method; - } } 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 5e68372ca03bda790d4e31c520f7228e9e2667f3..50494dd4d2ec16cbadaf36db0709dd374cbdcee9 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 @@ -52,7 +52,7 @@ public class AmplitudeThresholdingTask extends AbstractTask< Img< BitType > > } @Override - protected Img< BitType > call() throws Exception + protected Img< BitType > call() { LOGGER.info( "Computing amplitude thresholding..." ); return AmplitudeClassification.applyThreshold( images.getValue().getAmplitudeImg(), amplitudeThreshold ); 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 0181077e2d9bf66e0fe9433ebd3e46407882fc2c..3ff1d90bd3beb502d4900dbc86f24c50936f6f7e 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 @@ -56,7 +56,7 @@ public class ConstructionCompletionTask< T extends RealType< T > & NativeType< T } @Override - protected ArrayList< ReferenceSurface< T > > call() throws Exception + protected ArrayList< ReferenceSurface< T > > call() { LOGGER.info( "Processing construction completion..." ); return ConstructionCompletion.run( input, factory, finalSurfaces ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/DisplayDatasetChoicesTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/DisplayDatasetChoicesTask.java index b3826bd0bb3af32b7f6a457551c42ea9ce084039..074f3d916b72613bde83ca1c83bcd03d983fcd92 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/DisplayDatasetChoicesTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/DisplayDatasetChoicesTask.java @@ -47,7 +47,7 @@ public class DisplayDatasetChoicesTask extends AbstractTask< ArrayList< Dataset } @Override - protected ArrayList< Dataset > call() throws Exception + protected ArrayList< Dataset > call() { ArrayList< ImageDisplay > imageDisplays = ( ArrayList< ImageDisplay > ) imageDisplayService.getImageDisplays(); ArrayList< Dataset > tempDatasets = new ArrayList<>( imageDisplays.size() ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/ImageFXDisplayTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/ImageFXDisplayTask.java index 1a92c8479ec842b7f822129d70cd3739486d052a..5c8feb3ba78cb082e25eb82ab2b1ad6f1560e5a7 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/ImageFXDisplayTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/ImageFXDisplayTask.java @@ -48,7 +48,7 @@ public class ImageFXDisplayTask extends AbstractTask< ImageView[] > @Override - protected ImageView[] call() throws Exception + protected ImageView[] call() { ImageFXDisplay display = new ImageFXDisplay( input.getValue() ); display.set(); 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 7fbe48400d1cbf89f54f82d8b24954c6516e44fe..cb86733367484a1abd8393ce161c737caadb1925 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 @@ -50,7 +50,7 @@ public class InterClassificationTask extends AbstractTask< Img< BitType > > @Override - protected Img< BitType > call() throws Exception + protected Img< BitType > call() { LOGGER.info( "Computing inter-classification..." ); 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 2f5d8d41e2517557e879f8a6edf7cb6750f8acda..7e71fac25ece610fbfa4a4514d229779fc4671a4 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 @@ -50,7 +50,7 @@ public class IslandSearchTask extends AbstractTask< Img< BitType > > } @Override - protected Img< BitType > call() throws Exception + protected Img< BitType > call() { LOGGER.info( "Computing Island Search..." ); Img< BitType > img = PostTreatment.runIslandSearch( image.getValue(), islandSize.intValue() ); 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 32e3fb20f780deb6c60ca77bf4028d1d5b4476e8..4fafcd4a2d39094c48caedeb68a498170e31d63c 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 @@ -54,7 +54,7 @@ public class OtsuThresholdingTask extends AbstractTask< Img< BitType > > } @Override - protected Img< BitType > call() throws Exception + protected Img< BitType > call() { LOGGER.info( "Computing otsu thresholding..." ); return OtsuClassification.applyLocalThreshold( pretreatedImage.getValue(), images.getValue().getOtsuImg(), otsuThreshold ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/PretreatmentTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/PretreatmentTask.java index f23053a020d010a1899fbf0ab8ce08ea54244bf9..7cc65fb66123a301189914773b30025a9b40a754 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/PretreatmentTask.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/task/PretreatmentTask.java @@ -50,7 +50,8 @@ public class PretreatmentTask< T extends RealType< T > & NativeType< T > > exten } @Override - protected Img< FloatType > call() throws Exception + @SuppressWarnings( "unchecked" ) + protected Img< FloatType > call() { LOGGER.info( "Computing pretreatment..." ); ImgPlus< T > input = ( ImgPlus< T > ) dataset.getImgPlus(); 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 f4572b2a2c9a5227d11d0c18ddbc2cd00b28d5c5..429746ab65b52ab3a1c549dd9b10cd84034ad656 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 @@ -56,7 +56,7 @@ public class RunFirstConstructionTask extends AbstractTask< ArrayList< Surface > } @Override - protected ArrayList< Surface > call() throws Exception + protected ArrayList< Surface > call() { LOGGER.info( "Computing first round construction..." ); FirstRoundConstruction step1 = new FirstRoundConstruction( maximums, startingOsSize1, overlap1, connexityRate1, surfaceMinSizeFactor ); 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 c30b4800fbf4ecaa0ef1c3e67f94ddfcbe7d1ecf..b32f7a9b0b53100fe0db027c90aec769b8ac3b27 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 @@ -56,7 +56,7 @@ public class RunSecondConstructionTask extends AbstractTask< ArrayList< Surface } @Override - protected ArrayList< Surface > call() throws Exception + protected ArrayList< Surface > call() { LOGGER.info( "Computing second round construction..." ); SecondRoundConstruction step2 = new SecondRoundConstruction( surfaces, startingOsSize2, overlap2, connexityRate2, surfaceMinSizeFactor ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/task/SetCurrentDatasetTask.java b/src/main/java/fr/pasteur/ida/zellige/gui/task/SetCurrentDatasetTask.java deleted file mode 100644 index 7a83c081b7c73b94c3d8fa50d857930eb70cac74..0000000000000000000000000000000000000000 --- a/src/main/java/fr/pasteur/ida/zellige/gui/task/SetCurrentDatasetTask.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.gui.task; - - -import net.imagej.Dataset; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SetCurrentDatasetTask extends AbstractTask< Dataset > - -{ - private final Logger LOGGER = LoggerFactory.getLogger( SetCurrentDatasetTask.class ); - private final Dataset dataset; - - - public SetCurrentDatasetTask( Dataset dataset ) - { - this.dataset = dataset; - LOGGER.debug( " constructor" ); - } - - @Override - protected Dataset call() throws Exception - { - LOGGER.debug( "Task's start." ); - if ( dataset.numDimensions() != 3 ) - { - LOGGER.debug( "This input is not a z-stack" ); - return null; - } - return dataset; - } - - - // - @Override - protected void succeeded() - { - super.succeeded(); - LOGGER.debug( "Task successful" ); - } - - -} 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 fc8cb4befa639d97bb2d56d963566c69a819d2a1..6845b02527ac58e1857c43ebb014bcaa09fe1e2c 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/Utils.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/Utils.java @@ -52,7 +52,7 @@ public class Utils * @param <T> - source and output type * @param input - the source image as a {@link RandomAccessibleInterval} * @param output - the filtered image as a {@link RandomAccessibleInterval} - * @param sigma - a array containing the standard deviations for each dimension. + * @param sigma - an array containing the standard deviations for each dimension. */ public static < T extends RealType< T > & NativeType< T > > void gaussianConvolution( RandomAccessibleInterval< T > input, RandomAccessibleInterval< T > output, diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/ConstructionCompletion.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/ConstructionCompletion.java index 7bcfadfdf0062beff482ba6daa728a3d66eaf5cd..9ae18abbfa5bfb29702ef2346bbb947279174947 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/ConstructionCompletion.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/ConstructionCompletion.java @@ -47,7 +47,7 @@ import java.util.ArrayList; /** - * This class allows to get a height map from a {@link Surface} by averaging the Z values or discarding them if not possible (gteZmap()) + * This class allows to get a height map from a {@link Surface} by averaging the Z values or discarding them if not possible (getZMap()) * and by interpolating when possible if there is any missing internal values (processZMap()). * * @param <T> the input type @@ -123,13 +123,6 @@ public class ConstructionCompletion< T extends RealType< T > & NativeType< T > > randomAccess.get().set( new UnsignedShortType( z + 1 ) ); } } - else - { - if ( pixel != null ) - { -// LOGGER.debug( "more than two : " + pixel ); - } - } } } } diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/Interpolation.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/Interpolation.java index 3c624ad6740fb4d92fa0c9787fe220d84fce7340..23a9daee943b4c4dd6f9210167cecc17500ee80f 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/Interpolation.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/Interpolation.java @@ -114,9 +114,9 @@ public class Interpolation } /** - * Determines the constant b of the linear equation y = ax + b given one point P1(x1, y1) and the slope a. + * Determines the constant b of the linear equation y = ax + b given one point P1(x1, y1) and the slope 'a'. * - * @param a - the slope a of the linear equation y = ax + b. + * @param a - the slope 'a' of the linear equation y = ax + b. * @param x1 - x coordinates for the first point. * @param z1 - z coordinates for the first point. * @return the b constant of the linear equation y = ax + b. @@ -131,7 +131,7 @@ public class Interpolation * Determines the unknown z coordinate of a point P given its x coordinate, * the slope and the constant of the linear equation y = ax + b. * - * @param a - the slope a of the linear equation y = ax + b. + * @param a - the slope 'a' of the linear equation y = ax + b. * @param b - the b constant of the linear equation y = ax + b. * @param x - the x coordinate of a point with unknown z coordinate. * @return - the z coordinate corresponding to the x coordinate. diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionParameters.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionParameters.java index 9607bec078e5734335b29c5fedbd04ffc2e091cd..ed44fc6b818b982ab595cdfe0e38ae03eef0998c 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionParameters.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionParameters.java @@ -34,7 +34,7 @@ public class ConstructionParameters private final double startingSizeThreshold; private final int overlap; private final double connexityRate; - private double surfaceMinSizeFactor; + private final double surfaceMinSizeFactor; public ConstructionParameters( double startingSizeThreshold, int overlap, double connexityRate, double surfaceMinSizeFactor ) { diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java index e43a6282511b69195f5285a8917d3731ab13e8ac..fd54a703876d58f3cdff2e7550377000a94d69be 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java @@ -202,8 +202,4 @@ public abstract class ConstructionRound return startingOSCount; } - public void setStartingOSCount( int startingOSCount ) - { - this.startingOSCount = startingOSCount; - } } diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstruction.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstruction.java index 7f22314c37d86cbfd260ca2c6ee2fa14eba8c3f6..f393d0f897441fbd2578943f4be100a18b8c2f59 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstruction.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstruction.java @@ -71,7 +71,7 @@ public abstract class OseConstruction /** * This method finds all the possible 2D surfaces that can be created from the coordinates detected as - * local maximums on a array of {@link }. + * local maximums on an array of {@link }. * * @param rawCoordinates - the raw Coordinates from the projection. * @return all the orthogonal surfaces for the projection as an {@link ArrayList <AbstractOSE>}. diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstructionYZ.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstructionYZ.java index 9e124fdc5441904daf36907923825446464b75f7..c3fe75f9ea04cb34b2267d146e5b5247151fa48e 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstructionYZ.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ose/OseConstructionYZ.java @@ -86,10 +86,12 @@ public class OseConstructionYZ extends OseConstruction for ( Pixels [] pixelLine : this.getMaximums() ) { - for (Pixels pixels : pixelLine) - if ( pixels != null ) + for ( Pixels pixels : pixelLine ) { - pixels.resetSideCoordinate(); + if ( pixels != null ) + { + pixels.resetSideCoordinate(); + } } } LOGGER.debug( "Ose reset" ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/projection/ReferenceSurfaceProjection.java b/src/main/java/fr/pasteur/ida/zellige/steps/projection/ReferenceSurfaceProjection.java index 60b33a7021f8fdbda3628600646dcaaa2ebdd312..1645246f2dc4f4c34518926acb814b6f786d8c6a 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/projection/ReferenceSurfaceProjection.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/projection/ReferenceSurfaceProjection.java @@ -50,21 +50,15 @@ import static fr.pasteur.ida.zellige.steps.Utils.setPosition; * @author ctrebeau * Methods to extract the reference surface from a stack with the height map obtained with the program. */ +@SuppressWarnings( "Duplicates" ) public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T > > { - private final int delta; - - public ReferenceSurfaceProjection( int delta ) - { - this.delta = delta; - } - public static < T extends RealType< T > & NativeType< T > > void run( ReferenceSurface< T > referenceSurface, ProjectionParameters projectionParameters, DisplayParameters displayParameters ) throws NoPossibleDisplayException { - ReferenceSurfaceProjection< T > referenceSurfaceProjection = new ReferenceSurfaceProjection<>( projectionParameters.getDelta() ); + ReferenceSurfaceProjection< T > referenceSurfaceProjection = new ReferenceSurfaceProjection<>(); referenceSurfaceProjection.set( referenceSurface, projectionParameters ); referenceSurfaceProjection.display( referenceSurface, projectionParameters, displayParameters ); } @@ -79,7 +73,7 @@ public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T boolean segmentedSurfaceMaskDisplay, int delta2 ) throws NoPossibleDisplayException { - ReferenceSurfaceProjection< T > referenceSurfaceProjection = new ReferenceSurfaceProjection<>( delta ); + ReferenceSurfaceProjection< T > referenceSurfaceProjection = new ReferenceSurfaceProjection<>(); referenceSurfaceProjection.set( referenceSurface, delta, projectionType, delta2 ); referenceSurfaceProjection.display( referenceSurface, delta, projectionType, projectionDisplay, @@ -137,7 +131,7 @@ public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T /** * @param referenceSurface the considered reference surface * @param delta the desired user volume value - * @param <T> the type of the referece surface + * @param <T> the type of the reference surface * @return the extracted height map subStack */ public static < T extends RealType< T > & NativeType< T > > Img< T > getExtractedHeightMapSubStack @@ -323,7 +317,7 @@ public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T * * @param stackAccess - the {@link RandomAccess} of original stack * @param stop - the maximum value that z can take. - * @param delta - the delta to which the search will occurred. + * @param delta - the delta to which the search will occur. * @param <T> - the type of the {@link RandomAccess} * @return - the z value for which the pixel intensity is maximal. */ @@ -404,7 +398,6 @@ public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T referenceSurface.getProjection().setExtractedHeightMap( getProjectionHeightMap( referenceSurface, projectionType, delta ) ); referenceSurface.getProjection().setReduced3DSpace( getExtractedHeightMapSubStack( referenceSurface, delta ) ); referenceSurface.getProjection().setProjection( projection1( referenceSurface, projectionType ) ); -// referenceSurface.getProjection().setSegmentedSurface( getSegmentedSurface( referenceSurface, delta ) ); referenceSurface.getProjection().setSegmentedSurface( getSegmentedSurface( referenceSurface.getProjection().getExtractedHeightMap(), referenceSurface.getInput(), referenceSurface.getFactory() ) ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/Selection.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/Selection.java index 5f96d0769d0d0e44b901ba861c7674d4c3a7267a..67adf573f422ad9a28e3c97ed1b4fb4cc42b2b77 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/Selection.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/Selection.java @@ -34,7 +34,6 @@ import fr.pasteur.ida.zellige.steps.selection.classification.Classification; import fr.pasteur.ida.zellige.steps.selection.classification.ClassificationParameters; import fr.pasteur.ida.zellige.steps.selection.classification.OtsuClassification; import fr.pasteur.ida.zellige.steps.selection.exception.DataValidationException; -import fr.pasteur.ida.zellige.steps.selection.exception.EmptyOutputException; import fr.pasteur.ida.zellige.steps.selection.exception.NoClassificationException; import fr.pasteur.ida.zellige.steps.selection.postTreatment.PostTreatment; import fr.pasteur.ida.zellige.steps.selection.postTreatment.PostTreatmentParameters; @@ -77,7 +76,7 @@ public class Selection< T extends RealType< T > & NativeType< T > > } public static < T extends RealType< T > & NativeType< T > > Pixels[][] - run( RandomAccessibleInterval< T > input, PretreatmentParameters pretreatmentParameters, ClassificationParameters classificationParameters, PostTreatmentParameters postTreatmentParameters ) throws EmptyOutputException, NoClassificationException, DataValidationException + run( RandomAccessibleInterval< T > input, PretreatmentParameters pretreatmentParameters, ClassificationParameters classificationParameters, PostTreatmentParameters postTreatmentParameters ) throws NoClassificationException, DataValidationException { LOGGER.debug( "Starting process..." ); Selection< T > selection = new Selection<>( pretreatmentParameters, classificationParameters, postTreatmentParameters, input ); @@ -108,11 +107,10 @@ public class Selection< T extends RealType< T > & NativeType< T > > } /** - * @throws EmptyOutputException if the input image is empty * @throws NoClassificationException if the no classification was performed * @throws DataValidationException if one of the input parameters is not valid */ - public void run() throws EmptyOutputException, NoClassificationException, DataValidationException + public void run() throws NoClassificationException, DataValidationException { /* Pretreatment of the image.*/ Img< FloatType > pretreatedImage = Pretreatment.run( input, radius ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/AmplitudeClassification.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/AmplitudeClassification.java index 37c2ace40228a29a75e84d182686d5ffaebff3ea..e5c10449f285d3b05f337a5090589d7d549ce4bf 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/AmplitudeClassification.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/AmplitudeClassification.java @@ -57,7 +57,6 @@ public class AmplitudeClassification< T extends RealType< T > & NativeType< T > private double userThreshold; private Img< BitType > output; private static long processingTime; - private static double firstMaxValue; private final static Logger LOGGER = LoggerFactory.getLogger( AmplitudeClassification.class ); @@ -92,13 +91,6 @@ public class AmplitudeClassification< T extends RealType< T > & NativeType< T > return classification.getOutput(); } - public static < T extends RealType< T > & NativeType< T > > Img< BitType > - applyThreshold( Img< T > input, T value, double userThreshold ) - { - value.mul( userThreshold ); - return Thresholder.threshold( input, value, true, 5 ); - } - public static < T extends RealType< T > & NativeType< T > > Img< BitType > applyThreshold( Img< T > input, int userThreshold ) { @@ -228,11 +220,6 @@ public class AmplitudeClassification< T extends RealType< T > & NativeType< T > return maxValue; } - public static double getFirstMaxValue() - { - return firstMaxValue; - } - // public void run() throws DataValidationException { diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/Classification.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/Classification.java index 678409ca69099c2944b2195d4709d65fb05d4c44..daf19da0c8bfc4363fe45be718024f3007095cd5 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/Classification.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/Classification.java @@ -68,8 +68,6 @@ public class Classification< T extends RealType< T > & NativeType< T > > this.factory = factory; } - - /** * Static method to provide a 2-part classification on a 3D image * @@ -79,23 +77,22 @@ public class Classification< T extends RealType< T > & NativeType< T > > * @param parameters - the parameters for the 2-parts classification * @return a binary image * @throws NoClassificationException if the binary image is empty. - * @throws DataValidationException} if the value of parameter amplitudeThreshold is not valid. + * @throws DataValidationException if the value of parameter amplitudeThreshold is not valid. */ public static < T extends RealType< T > & NativeType< T > > Img< BitType > run( RandomAccessibleInterval< T > input, ImgFactory< T > factory, ClassificationParameters parameters ) throws NoClassificationException, DataValidationException { Classification< T > classification = new Classification<>( input, factory ); - classification.process( factory, parameters ); + classification.process( parameters ); return classification.output; } /** - * @param factory - the input {@link ImgFactory} * @param parameters - the user parameters to set the classifications * @throws NoClassificationException if both classifications are set to Zero * @throws DataValidationException if one of the user thresholds is incorrect */ - void process( ImgFactory< T > factory, ClassificationParameters parameters ) throws NoClassificationException, DataValidationException + void process( ClassificationParameters parameters ) throws NoClassificationException, DataValidationException { LOGGER.debug( "Starting classification..." ); int amplitudeThreshold = parameters.getAmplitudeThreshold(); @@ -177,37 +174,4 @@ public class Classification< T extends RealType< T > & NativeType< T > > return output; } - - /** - * @param amplitude an {@link BitType}{@link Img} - * @param factory the same {@link BitType} {@link ImgFactory} as amplitude - * @param thresholds another {@link BitType}{@link Img} - * @return the intersection of both image - */ - public static Img< BitType > runInterClassification( IterableInterval< BitType > amplitude, - ImgFactory< BitType > factory, - RandomAccessibleInterval< BitType > thresholds ) - { - Img< BitType > output = factory.create( thresholds ); - Cursor< BitType > amplitudeCursor = amplitude.localizingCursor(); - RandomAccess< BitType > thresholdAccess - = thresholds.randomAccess(); - RandomAccess< BitType > outputAccess = output.randomAccess(); - while ( amplitudeCursor.hasNext() ) - { - amplitudeCursor.fwd(); - if ( amplitudeCursor.get().getRealDouble() != 0 ) - { - thresholdAccess.setPosition( amplitudeCursor ); - if ( thresholdAccess.get().get() ) - { - outputAccess.setPosition( amplitudeCursor ); - outputAccess.get().setOne(); - } - } - } - return output; - } - - } diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/HistogramZ.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/HistogramZ.java index b6e4419910e97cef4b6facc06bee5a45cc0300d8..89ab05e12ac43ebb850844dd31b29731e0d76c0d 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/HistogramZ.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/HistogramZ.java @@ -147,11 +147,11 @@ public class HistogramZ< T > implements Algorithm, Benchmark } /** - * Creates and returns the a Type whose value corresponds to the center of - * the bin indexed by i. + * Creates and returns the {@link Type} whose value corresponds to the center of + * the bin indexed by the value i. * * @param i the requested bin index. - * @return a Type whose value corresponds to the requested bin center. + * @return a {@link Type} whose value corresponds to the requested bin center. */ public T getBinCenter( final int i ) { @@ -167,7 +167,7 @@ public class HistogramZ< T > implements Algorithm, Benchmark */ public ArrayList< T > getBinCenters() { - final ArrayList< T > binCenters = new ArrayList< T >( histogram.length ); + final ArrayList< T > binCenters = new ArrayList<>( histogram.length ); for ( int i = 0; i < histogram.length; ++ i ) { binCenters.add( i, getBinMapper().invMap( i ) ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/OtsuClassification.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/OtsuClassification.java index ce5ee18af7e89876119c390b66567b13c7544c45..3aa5c5a16109a561316ce88e1db379e4d1bec75d 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/OtsuClassification.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/classification/OtsuClassification.java @@ -57,7 +57,7 @@ public class OtsuClassification< T extends RealType< T > & NativeType< T > > * @param input the input image as a {@link RandomAccessibleInterval} * @param factory the input factory * @param output the resulting binary image as a {@link Img<BitType> } - * @param userThreshold the the user's intensity threshold + * @param userThreshold the user's intensity threshold */ private OtsuClassification( final RandomAccessibleInterval< T > input, final ImgFactory< T > factory, final Img< BitType > output, int userThreshold ) { diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/PostTreatment.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/PostTreatment.java index 2e53cd32f4aa95ddc0aa4c33e52c85c4b6425567..ee89938b1dd90e69acfd0ec8a8f3e8852159fe2f 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/PostTreatment.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/PostTreatment.java @@ -163,7 +163,7 @@ public class PostTreatment public static Pixels[][] runSmoothing( Img< BitType > ISImage, int sigmaXY, int sigmaZ ) throws DataValidationException { Img< FloatType > converted = convertBitTypeIntoFloatType( ISImage ); - // Use of Converter.convert() not possible because classifiedPixel type do not extends RealType + // Use of Converter.convert() not possible because classifiedPixel type do not extend RealType /* Dilatation of the resulting image*/ runDilatation( converted, sigmaXY, sigmaZ ); @@ -185,7 +185,7 @@ public class PostTreatment } /* Conversion into FloatType before dilatation */ Img< FloatType > converted = convertBitTypeIntoFloatType( temp ); - // Use of Converter.convert() not possible because classifiedPixel type do not extends RealType + // Use of Converter.convert() not possible because classifiedPixel type do not extend RealType /* Dilatation of the resulting image*/ runDilatation( converted, parameters ); @@ -207,7 +207,7 @@ public class PostTreatment } /* Conversion into FloatType before dilatation */ Img< FloatType > converted = convertBitTypeIntoFloatType( temp ); - // Use of Converter.convert() not possible because classifiedPixel type do not extends RealType + // Use of Converter.convert() not possible because classifiedPixel type do not extend RealType /* Dilatation of the resulting image*/ runDilatation( converted, sigmaXY, sigmaZ ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/islandSearch/IslandSearch.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/islandSearch/IslandSearch.java index 7ef954790535ac7c203997059e90edce924c09c5..8528599d4ac438ec957f38a204f424d82a20b6dd 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/islandSearch/IslandSearch.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/postTreatment/islandSearch/IslandSearch.java @@ -87,15 +87,6 @@ public class IslandSearch return output; } - public static int getInputCount() - { - return inputCount; - } - - public static int getPixelRemovedCount() - { - return pixelRemovedCount; - } /** * Computes the island search @@ -105,6 +96,8 @@ public class IslandSearch World world = convertImgIntoWorld(); world.run(); convertWorldIntoImg( world, output ); + LOGGER.debug( "Input count : {}.", inputCount ); + LOGGER.debug( "Number of pixels removed : {}.", pixelRemovedCount ); } /** diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/Pretreatment.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/Pretreatment.java index b8fcda26ebc0c7988f26b6df5b00800f134ed0af..b1e897c994954207a62d32f5bd42a5c55a0988b6 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/Pretreatment.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/Pretreatment.java @@ -88,7 +88,7 @@ public class Pretreatment< T extends RealType< T > & NativeType< T > > * * @param <T> - the type of the input Img. * @param image - the input Img. - * @param factory + * @param factory - the image factory. * @return a new Img with normalize pixel intensity values. */ private static < T extends RealType< T > & NativeType< T > > Img< T > normalizeImage( @@ -123,7 +123,7 @@ public class Pretreatment< T extends RealType< T > & NativeType< T > > /** * @param input - the source image as a {@link RandomAccessibleInterval} * @param factory - the source and output factory - * @param sigma - a array containing the standard deviations for each dimension. + * @param sigma - an array containing the standard deviations for each dimension. * @param <T> - source and output type * @return - the filtered image as a {@link RandomAccessibleInterval} */ diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/PretreatmentParameters.java b/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/PretreatmentParameters.java index 7b78c63564b9023ec0be88e88f5de8f2df8f2e45..c48493a782b4245894d31df6c68b9ad0eacf6fc0 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/PretreatmentParameters.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/selection/pretreatment/PretreatmentParameters.java @@ -62,7 +62,7 @@ public class PretreatmentParameters * Checks the length of the parameters according to the method choose * * @param parameter the method arguments - * @throws DataValidationException if at the pramaters legnth (the number of arguments) is not valid according to the method choose + * @throws DataValidationException if at the parameters' length (the number of arguments) is not valid according to the method choose */ private void checkParametersLength( double parameter ) throws DataValidationException { diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/Util.java b/src/main/java/fr/pasteur/ida/zellige/utils/Util.java new file mode 100644 index 0000000000000000000000000000000000000000..44f41014b0deb393eaf9e0db7fadbee0dd3e6d76 --- /dev/null +++ b/src/main/java/fr/pasteur/ida/zellige/utils/Util.java @@ -0,0 +1,30 @@ +package fr.pasteur.ida.zellige.utils; + +import net.imglib2.RandomAccess; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.type.NativeType; +import net.imglib2.type.numeric.RealType; + +import static fr.pasteur.ida.zellige.steps.Utils.setPositionAndGet; + +public class Util +{ + + public static < S extends RealType< S > & NativeType< S > > float[][] convert( RandomAccessibleInterval< S > input, int subtract ) + { + float[][] array = new float[ ( int ) input.dimension( 1 ) ][ ( int ) input.dimension( 0 ) ]; + RandomAccess< S > access = input.randomAccess(); + for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ ) + { + for ( int y = 0; y < ( int ) input.dimension( 1 ); y++ ) + { + float value = setPositionAndGet( access, x, y ).getRealFloat(); + if ( value + subtract != 0 ) + { + array[ y ][ x ] = value; + } + } + } + return array; + } +} diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/All_GT_Display.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/All_GT_Display.java index 45a937baa1eab953e1225d3f6b85a2a76213af72..a108c4c646774c8874cffcdf3fcc768a22b01957 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/All_GT_Display.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/All_GT_Display.java @@ -28,14 +28,13 @@ */ package fr.pasteur.ida.zellige.utils.jzy3D; +import fr.pasteur.ida.zellige.utils.Util; import io.scif.img.IO; import io.scif.img.SCIFIOImgPlus; -import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; -import net.imglib2.type.numeric.real.FloatType; import org.jzy3d.analysis.AbstractAnalysis; import org.jzy3d.analysis.AnalysisLauncher; import org.jzy3d.chart.factories.AWTChartComponentFactory; @@ -48,13 +47,11 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; -import static fr.pasteur.ida.zellige.steps.Utils.setPositionAndGet; - public class All_GT_Display< T extends RealType< T > & NativeType< T > > extends AbstractAnalysis { private final static Logger LOGGER = LoggerFactory.getLogger( All_GT_Display.class ); private final ArrayList< RandomAccessibleInterval< T > > groundTruths; - private String[] gtColors = { "#283D66", "#A1B9EA", "#5A88E6", "#465166", "#466AB3", "", "", "" }; + private final String[] gtColors = { "#283D66", "#A1B9EA", "#5A88E6", "#465166", "#466AB3", "", "", "" }; public All_GT_Display( ArrayList< RandomAccessibleInterval< T > > groundTruths ) { @@ -62,7 +59,8 @@ public class All_GT_Display< T extends RealType< T > & NativeType< T > > extends init(); } - public static void main( String[] args ) + @SuppressWarnings( "unchecked" ) + public static < T extends RealType< T > & NativeType< T > > void main( String[] args ) { final String[] refImagePath = new String[]{ @@ -73,12 +71,14 @@ public class All_GT_Display< T extends RealType< T > & NativeType< T > > extends "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\Mouche_c01_f0001_p013\\GT\\Ground truth Height map_4.tif" }; - ArrayList< RandomAccessibleInterval< FloatType > > GTs = new ArrayList<>(); + + ArrayList< RandomAccessibleInterval< T > > GTs = new ArrayList<>(); + for ( String path : refImagePath ) { LOGGER.debug( path ); - SCIFIOImgPlus< ? > refImgPlus = IO.openImgs( path ).get( 0 ); - GTs.add( ( Img< FloatType > ) refImgPlus.getImg() ); + SCIFIOImgPlus< ? > refImgPlus = IO.openAll( path ).get( 0 ); + GTs.add( ( Img< T > ) refImgPlus.getImg() ); } All_GT_Display.display( GTs ); } @@ -94,7 +94,7 @@ public class All_GT_Display< T extends RealType< T > & NativeType< T > > extends { try { - All_GT_Display display = new All_GT_Display( groundTruths ); + All_GT_Display< T > display = new All_GT_Display<>( groundTruths ); AnalysisLauncher.open( display ); } catch ( Exception e ) @@ -110,7 +110,7 @@ public class All_GT_Display< T extends RealType< T > & NativeType< T > > extends ArrayList< float[][] > GTs = new ArrayList<>(); for ( RandomAccessibleInterval< T > GT : groundTruths ) { - GTs.add( convert( GT, 0 ) ); + GTs.add( Util.convert( GT, 0 ) ); } int count = 0; for ( float[][] gt : GTs ) @@ -144,32 +144,14 @@ public class All_GT_Display< T extends RealType< T > & NativeType< T > > extends chart.getScene().add( scatter ); } - public < S extends RealType< S > & NativeType< S > > float[][] convert( RandomAccessibleInterval< S > input, int subtract ) - { - float[][] array = new float[ ( int ) input.dimension( 1 ) ][ ( int ) input.dimension( 0 ) ]; - RandomAccess< S > access = input.randomAccess(); - for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ ) - { - for ( int y = 0; y < ( int ) input.dimension( 0 ); y++ ) - { - float value = setPositionAndGet( access, x, y ).getRealFloat(); - if ( value + subtract != 0 ) - { - array[ y ][ x ] = value; - } - } - } - return array; - } - public int getCount( float[][] map ) { int count = 0; for ( int x = 0; x < map[ 0 ].length; x++ ) { - for ( int y = 0; y < map.length; y++ ) + for ( float[] floats : map ) { - float mapValue = map[ y ][ x ]; + float mapValue = floats[ x ]; if ( mapValue != 0 ) { count++; @@ -197,21 +179,11 @@ public class All_GT_Display< T extends RealType< T > & NativeType< T > > extends return new Color( RGB[ 0 ], RGB[ 1 ], RGB[ 2 ] ); } - public Color getColor( int[] RGB, float alpha ) - { - return new Color( RGB[ 0 ], RGB[ 1 ], RGB[ 2 ], alpha ); - } - public Color getColor( String hex ) { return getColor( hexToRGB( hex ) ); } - public Color getColor( String hex, float alpha ) - { - return getColor( hexToRGB( hex ), alpha ); - - } } diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_DifferenceDisplay.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_DifferenceDisplay.java index 842b7268d20396202adf8bcce2d35572b8547b95..f926bc267e73ee80662ee37b10b219c08d32d196 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_DifferenceDisplay.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_DifferenceDisplay.java @@ -28,9 +28,9 @@ */ package fr.pasteur.ida.zellige.utils.jzy3D; +import fr.pasteur.ida.zellige.utils.Util; import io.scif.img.IO; import io.scif.img.SCIFIOImgPlus; -import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.type.NativeType; @@ -44,8 +44,6 @@ import org.jzy3d.maths.Coord3d; import org.jzy3d.plot3d.primitives.Scatter; import org.jzy3d.plot3d.rendering.canvas.Quality; -import static fr.pasteur.ida.zellige.steps.Utils.setPositionAndGet; - public class HM_GT_DifferenceDisplay< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > extends AbstractAnalysis { private final RandomAccessibleInterval< T > groundTruth; @@ -73,7 +71,7 @@ public class HM_GT_DifferenceDisplay< T extends RealType< T > & NativeType< T >, { try { - HM_GT_DifferenceDisplay display = new HM_GT_DifferenceDisplay( groundTruth, heightMap ); + HM_GT_DifferenceDisplay< T, R > display = new HM_GT_DifferenceDisplay<>( groundTruth, heightMap ); AnalysisLauncher.open( display ); } catch ( Exception e ) @@ -83,18 +81,17 @@ public class HM_GT_DifferenceDisplay< T extends RealType< T > & NativeType< T >, } } + @SuppressWarnings( { "unchecked", "DuplicatedCode" } ) public static void main( String[] args ) { String refImagePath = "C:\\Users\\ctrebeau\\Desktop\\Zellige Analysis\\files\\Curv\\curv_100\\phantoms_curvtest_zmap100_gt.tif"; String imagePath = "C:\\Users\\ctrebeau\\Desktop\\Zellige Analysis\\files\\Curv\\curv_100\\phantoms_curv100_HM_centralDerivative_noSmooth.tif"; - final SCIFIOImgPlus< ? > imgPlusRef = IO.openImgs( refImagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlusRef = IO.openAll( refImagePath ).get( 0 ); Img< FloatType > GT = ( Img< FloatType > ) imgPlusRef.getImg(); /* The raw image to test*/ -// final String imagePath = "doc/Cochlée1.tif"; -// final String imagePath = "C:\\Users\\ctrebeau\\Desktop\\phantom_tests_snr_1surf\\phantoms_1surf_snr0.mat.tif"; - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); Img< FloatType > HM = ( Img< FloatType > ) imgPlus.getImg(); HM_GT_DifferenceDisplay.displayDiff( GT, HM ); @@ -103,8 +100,8 @@ public class HM_GT_DifferenceDisplay< T extends RealType< T > & NativeType< T >, @Override public void init() { - float[][] GT = convert( groundTruth, 0 ); - float[][] HM = convert( projection, 0 ); + float[][] GT = Util.convert( groundTruth, 0 ); + float[][] HM = Util.convert( projection, 0 ); int count = getCount( GT ); Coord3d[] points = new Coord3d[ count ]; Color[] colors = new Color[ count ]; @@ -168,33 +165,14 @@ public class HM_GT_DifferenceDisplay< T extends RealType< T > & NativeType< T >, chart = AWTChartComponentFactory.chart( Quality.Advanced, "newt" ); chart.getScene().add( scatter ); } - - public < S extends RealType< S > & NativeType< S > > float[][] convert( RandomAccessibleInterval< S > input, int subtract ) - { - float[][] array = new float[ ( int ) input.dimension( 1 ) ][ ( int ) input.dimension( 0 ) ]; - RandomAccess< S > access = input.randomAccess(); - for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ ) - { - for ( int y = 0; y < ( int ) input.dimension( 0 ); y++ ) - { - float value = setPositionAndGet( access, x, y ).getRealFloat(); - if ( value + subtract != 0 ) - { - array[ y ][ x ] = value; - } - } - } - return array; - } - public int getCount( float[][] map ) { int count = 0; for ( int x = 0; x < map[ 0 ].length; x++ ) { - for ( int y = 0; y < map.length; y++ ) + for ( float[] floats : map ) { - float mapValue = map[ y ][ x ]; + float mapValue = floats[ x ]; if ( mapValue != 0 ) { count++; diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_Display.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_Display.java index 3548086a2b5715000612503e92958a9d194de981..a7f3e2bf61d87c06798ed9d5a1f9595e15c09c58 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_Display.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_GT_Display.java @@ -28,6 +28,7 @@ */ package fr.pasteur.ida.zellige.utils.jzy3D; +import fr.pasteur.ida.zellige.utils.Util; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.type.NativeType; @@ -69,7 +70,7 @@ public class HM_GT_Display< T extends RealType< T > & NativeType< T >, R extends { try { - HM_GT_Display display = new HM_GT_Display( groundTruth, heightMap ); + HM_GT_Display< T, R > display = new HM_GT_Display<>( groundTruth, heightMap ); AnalysisLauncher.open( display ); } catch ( Exception e ) @@ -82,8 +83,8 @@ public class HM_GT_Display< T extends RealType< T > & NativeType< T >, R extends @Override public void init() { - float[][] GT = convert( groundTruth, 0 ); - float[][] HM = convert( projection, 0 ); + float[][] GT = Util.convert( groundTruth, 0 ); + float[][] HM = Util.convert( projection, 0 ); int count = getCount( GT, HM ); Coord3d[] points = new Coord3d[ count ]; Color[] colors = new Color[ count ]; diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages.java index ce43c76d8e8865830aa758d2c6a70df24061efb4..20e432b6809f65d98d6e8a8a0b01e31493346a93 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages.java @@ -28,9 +28,9 @@ */ package fr.pasteur.ida.zellige.utils.jzy3D; +import fr.pasteur.ida.zellige.utils.Util; import io.scif.img.IO; import io.scif.img.SCIFIOImgPlus; -import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.type.NativeType; @@ -46,8 +46,6 @@ import org.jzy3d.plot3d.rendering.canvas.Quality; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static fr.pasteur.ida.zellige.steps.Utils.setPositionAndGet; - public class HM_black_GT_distanceDisplay_realImages< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > extends AbstractAnalysis { private final static Logger LOGGER = LoggerFactory.getLogger( HM_black_GT_distanceDisplay_realImages.class ); @@ -76,7 +74,7 @@ public class HM_black_GT_distanceDisplay_realImages< T extends RealType< T > & N { try { - HM_black_GT_distanceDisplay_realImages display = new HM_black_GT_distanceDisplay_realImages( groundTruth, heightMap ); + HM_black_GT_distanceDisplay_realImages< T, R > display = new HM_black_GT_distanceDisplay_realImages<>( groundTruth, heightMap ); AnalysisLauncher.open( display ); } catch ( Exception e ) @@ -86,18 +84,18 @@ public class HM_black_GT_distanceDisplay_realImages< T extends RealType< T > & N } } + + @SuppressWarnings( { "unchecked", "DuplicatedCode" } ) public static void main( String[] args ) { String refImagePath = "C:\\Users\\ctrebeau\\Desktop\\Zellige Analysis\\files\\Curv\\curv_100\\phantoms_curvtest_zmap100_gt.tif"; String imagePath = "C:\\Users\\ctrebeau\\Desktop\\Zellige Analysis\\files\\Curv\\curv_100\\phantoms_curv100_HM_centralDerivative_noSmooth.tif"; - final SCIFIOImgPlus< ? > imgPlusRef = IO.openImgs( refImagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlusRef = IO.openAll( refImagePath ).get( 0 ); Img< FloatType > GT = ( Img< FloatType > ) imgPlusRef.getImg(); /* The raw image to test*/ -// final String imagePath = "doc/Cochlée1.tif"; -// final String imagePath = "C:\\Users\\ctrebeau\\Desktop\\phantom_tests_snr_1surf\\phantoms_1surf_snr0.mat.tif"; - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); Img< FloatType > HM = ( Img< FloatType > ) imgPlus.getImg(); HM_black_GT_distanceDisplay_realImages.displayDiff( GT, HM ); @@ -106,8 +104,8 @@ public class HM_black_GT_distanceDisplay_realImages< T extends RealType< T > & N @Override public void init() { - float[][] GT = convert( groundTruth, 0 ); - float[][] HM = convert( projection, 0 ); + float[][] GT = Util.convert( groundTruth, 0 ); + float[][] HM = Util.convert( projection, 0 ); int count = getCount( GT ) + getCount( HM ); Coord3d[] points = new Coord3d[ count ]; Color[] colors = new Color[ count ]; @@ -177,32 +175,15 @@ public class HM_black_GT_distanceDisplay_realImages< T extends RealType< T > & N chart.getScene().add( scatter ); } - public < S extends RealType< S > & NativeType< S > > float[][] convert( RandomAccessibleInterval< S > input, int subtract ) - { - float[][] array = new float[ ( int ) input.dimension( 1 ) ][ ( int ) input.dimension( 0 ) ]; - RandomAccess< S > access = input.randomAccess(); - for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ ) - { - for ( int y = 0; y < ( int ) input.dimension( 0 ); y++ ) - { - float value = setPositionAndGet( access, x, y ).getRealFloat(); - if ( value + subtract != 0 ) - { - array[ y ][ x ] = value; - } - } - } - return array; - } public int getCount( float[][] map ) { int count = 0; for ( int x = 0; x < map[ 0 ].length; x++ ) { - for ( int y = 0; y < map.length; y++ ) + for ( float[] floats : map ) { - float mapValue = map[ y ][ x ]; + float mapValue = floats[ x ]; if ( mapValue != 0 ) { count++; diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages_2D.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages_2D.java index d70d85e4a8d7ef7fa7cb3b50906e5bc6de99fa35..cca852ffde11cd327c0dff71c40f1100aa92a46b 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages_2D.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HM_black_GT_distanceDisplay_realImages_2D.java @@ -28,9 +28,9 @@ */ package fr.pasteur.ida.zellige.utils.jzy3D; +import fr.pasteur.ida.zellige.utils.Util; import io.scif.img.IO; import io.scif.img.SCIFIOImgPlus; -import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.type.NativeType; @@ -46,8 +46,6 @@ import org.jzy3d.plot3d.rendering.canvas.Quality; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static fr.pasteur.ida.zellige.steps.Utils.setPositionAndGet; - public class HM_black_GT_distanceDisplay_realImages_2D< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > extends AbstractAnalysis { private final static Logger LOGGER = LoggerFactory.getLogger( HM_black_GT_distanceDisplay_realImages_2D.class ); @@ -76,7 +74,7 @@ public class HM_black_GT_distanceDisplay_realImages_2D< T extends RealType< T > { try { - HM_black_GT_distanceDisplay_realImages_2D display = new HM_black_GT_distanceDisplay_realImages_2D( groundTruth, heightMap ); + HM_black_GT_distanceDisplay_realImages_2D< T, R > display = new HM_black_GT_distanceDisplay_realImages_2D<>( groundTruth, heightMap ); AnalysisLauncher.open( display ); } catch ( Exception e ) @@ -86,18 +84,17 @@ public class HM_black_GT_distanceDisplay_realImages_2D< T extends RealType< T > } } + @SuppressWarnings( "unchecked" ) public static void main( String[] args ) { String refImagePath = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\SNR\\snr_010\\multiSurface\\phantoms_snr10.mat_HM_02.tif"; String imagePath = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\SNR\\snr_010\\multiSurface\\phantoms_snrtest_zmap3_gt.tif"; - final SCIFIOImgPlus< ? > imgPlusRef = IO.openImgs( refImagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlusRef = IO.openAll( refImagePath ).get( 0 ); Img< FloatType > GT = ( Img< FloatType > ) imgPlusRef.getImg(); /* The raw image to test*/ -// final String imagePath = "doc/Cochlée1.tif"; -// final String imagePath = "C:\\Users\\ctrebeau\\Desktop\\phantom_tests_snr_1surf\\phantoms_1surf_snr0.mat.tif"; - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); Img< FloatType > HM = ( Img< FloatType > ) imgPlus.getImg(); HM_black_GT_distanceDisplay_realImages_2D.displayDiff( GT, HM ); @@ -106,8 +103,8 @@ public class HM_black_GT_distanceDisplay_realImages_2D< T extends RealType< T > @Override public void init() { - float[][] GT = convert( groundTruth, 0 ); - float[][] HM = convert( projection, 0 ); + float[][] GT = Util.convert( groundTruth, 0 ); + float[][] HM = Util.convert( projection, 0 ); int count = getCount( GT ) + getCount( HM ); Coord3d[] points = new Coord3d[ count ]; Color[] colors = new Color[ count ]; @@ -177,32 +174,14 @@ public class HM_black_GT_distanceDisplay_realImages_2D< T extends RealType< T > chart.getScene().add( scatter ); } - public < S extends RealType< S > & NativeType< S > > float[][] convert( RandomAccessibleInterval< S > input, int subtract ) - { - float[][] array = new float[ ( int ) input.dimension( 1 ) ][ ( int ) input.dimension( 0 ) ]; - RandomAccess< S > access = input.randomAccess(); - for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ ) - { - for ( int y = 0; y < ( int ) input.dimension( 0 ); y++ ) - { - float value = setPositionAndGet( access, x, y ).getRealFloat(); - if ( value + subtract != 0 ) - { - array[ y ][ x ] = value; - } - } - } - return array; - } - public int getCount( float[][] map ) { int count = 0; for ( int x = 0; x < map[ 0 ].length; x++ ) { - for ( int y = 0; y < map.length; y++ ) + for ( float[] floats : map ) { - float mapValue = map[ y ][ x ]; + float mapValue = floats[ x ]; if ( mapValue != 0 ) { count++; diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HMvsGT_Display.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HMvsGT_Display.java index f18d3d6c0cce1eb6afd7c6543712f513be814781..2e05e87feb58d8b91d80d591ec317c6a1c87092d 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HMvsGT_Display.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HMvsGT_Display.java @@ -28,9 +28,9 @@ */ package fr.pasteur.ida.zellige.utils.jzy3D; +import fr.pasteur.ida.zellige.utils.Util; import io.scif.img.IO; import io.scif.img.SCIFIOImgPlus; -import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.type.NativeType; @@ -46,20 +46,19 @@ import org.jzy3d.plot3d.rendering.canvas.Quality; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static fr.pasteur.ida.zellige.steps.Utils.setPositionAndGet; - public class HMvsGT_Display< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > extends AbstractAnalysis { private final static Logger LOGGER = LoggerFactory.getLogger( HMvsGT_Display.class ); private final RandomAccessibleInterval< T > groundTruth; private final RandomAccessibleInterval< R > projection; - private final int subtract = - 1; + private final int subtract; public HMvsGT_Display( RandomAccessibleInterval< T > groundTruth, - RandomAccessibleInterval< R > heightMap ) + RandomAccessibleInterval< R > heightMap, int subtract ) { this.groundTruth = groundTruth; this.projection = heightMap; + this.subtract = subtract; init(); } @@ -72,12 +71,12 @@ public class HMvsGT_Display< T extends RealType< T > & NativeType< T >, R extend * @param <R> the ground truth type */ public static < T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > void displayDiff( RandomAccessibleInterval< T > groundTruth, - RandomAccessibleInterval< R > heightMap ) + RandomAccessibleInterval< R > heightMap, int subtract ) { { try { - HMvsGT_Display display = new HMvsGT_Display( groundTruth, heightMap ); + HMvsGT_Display< T, R > display = new HMvsGT_Display<>( groundTruth, heightMap, subtract ); AnalysisLauncher.open( display ); } catch ( Exception e ) @@ -87,28 +86,27 @@ public class HMvsGT_Display< T extends RealType< T > & NativeType< T >, R extend } } + @SuppressWarnings( "unchecked" ) public static void main( String[] args ) { String pathGT = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\Organoid\\Organoid_GT_HM2.tif"; String pathHM = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\Paper_012022\\Organoid\\Organoid_HM_0.tif"; - final SCIFIOImgPlus< ? > imgPlusRef = IO.openImgs( pathGT ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlusRef = IO.openAll( pathGT ).get( 0 ); Img< FloatType > GT = ( Img< FloatType > ) imgPlusRef.getImg(); /* The raw image to test*/ -// final String imagePath = "doc/Cochlée1.tif"; -// final String imagePath = "C:\\Users\\ctrebeau\\Desktop\\phantom_tests_snr_1surf\\phantoms_1surf_snr0.mat.tif"; - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( pathHM ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( pathHM ).get( 0 ); Img< FloatType > HM = ( Img< FloatType > ) imgPlus.getImg(); - HMvsGT_Display.displayDiff( GT, HM ); + HMvsGT_Display.displayDiff( GT, HM, - 1 ); } @Override public void init() { - float[][] GT = convert( groundTruth, 0 ); - float[][] HM = convert( projection, 0 ); + float[][] GT = Util.convert( groundTruth, 0 ); + float[][] HM = Util.convert( projection, 0 ); int count = getCount( GT ) + getCount( HM ) + 2; Coord3d[] points = new Coord3d[ count ]; Color[] colors = new Color[ count ]; @@ -147,32 +145,14 @@ public class HMvsGT_Display< T extends RealType< T > & NativeType< T >, R extend chart.getScene().add( scatter ); } - public < S extends RealType< S > & NativeType< S > > float[][] convert( RandomAccessibleInterval< S > input, int subtract ) - { - float[][] array = new float[ ( int ) input.dimension( 1 ) ][ ( int ) input.dimension( 0 ) ]; - RandomAccess< S > access = input.randomAccess(); - for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ ) - { - for ( int y = 0; y < ( int ) input.dimension( 1 ); y++ ) - { - float value = setPositionAndGet( access, x, y ).getRealFloat(); - if ( value + subtract != 0 ) - { - array[ y ][ x ] = value; - } - } - } - return array; - } - public int getCount( float[][] map ) { int count = 0; for ( int x = 0; x < map[ 0 ].length; x++ ) { - for ( int y = 0; y < map.length; y++ ) + for ( float[] floats : map ) { - float mapValue = map[ y ][ x ]; + float mapValue = floats[ x ]; if ( mapValue != 0 ) { count++; diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HeightMapArrayWriter.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HeightMapArrayWriter.java index ceabd5a8431e32a596f3c11a946a84d1cbb9f167..70559880d74c654cc5dd529ada63f2ee49da8bfb 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HeightMapArrayWriter.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/HeightMapArrayWriter.java @@ -61,7 +61,7 @@ public class HeightMapArrayWriter< T extends RealType< T > & NativeType< T > > e { try { - new HeightMapArrayWriter( surface, originalInput, surfaceNumber ); + new HeightMapArrayWriter<>( surface, originalInput, surfaceNumber ); } catch ( Exception e ) { @@ -69,12 +69,14 @@ public class HeightMapArrayWriter< T extends RealType< T > & NativeType< T > > e } } + + @SuppressWarnings( "unchecked" ) public static < T extends RealType< T > & NativeType< T > > void main( String[] args ) { final String imagePath = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\Paper_012022\\Organoid\\Organoid_GT_HM1.tif"; /* The image path goes here !!!! */ LOGGER.debug( imagePath ); /* JY version for opening files. */ - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); final Img< T > heightMap = ( Img< T > ) imgPlus.getImg(); writeHeightMap( heightMap, imgPlus.getName(), 2 ); @@ -87,7 +89,7 @@ public class HeightMapArrayWriter< T extends RealType< T > & NativeType< T > > e if ( surface != null ) { CSVWriter csvWriter = - new CSVWriter( originalInput + "_" + "surface" ); + new CSVWriter( originalInput + "_" + "surface " + surfaceNumber ); Cursor< T > cursor = surface.cursor(); csvWriter.writeToFile( new String[]{ "x", "y", "z" } ); while ( cursor.hasNext() ) diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/LocalMaximumsDisplay.java b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/LocalMaximumsDisplay.java index 98c5acd7e539acb4f3631d05cbd3b7bfe19580dc..31bd8bab4ebefe73a71951c2200e9cede2e7ec08 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/LocalMaximumsDisplay.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/jzy3D/LocalMaximumsDisplay.java @@ -74,9 +74,6 @@ public class LocalMaximumsDisplay extends AbstractAnalysis } } // else -// { -// LOGGER.warn( "No Graphics Environment detected" ); -// } } @Override diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/test/DistanceImageWriter.java b/src/main/java/fr/pasteur/ida/zellige/utils/test/DistanceImageWriter.java index 3d458fae73e9d65aacf741f3458ac071936ecefd..4f6d5ef13069d13a46518a49b75ef804872c795d 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/test/DistanceImageWriter.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/test/DistanceImageWriter.java @@ -28,10 +28,10 @@ */ package fr.pasteur.ida.zellige.utils.test; +import fr.pasteur.ida.zellige.utils.Util; import ij.ImageJ; import io.scif.img.IO; import io.scif.img.SCIFIOImgPlus; -import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.img.display.imagej.ImageJFunctions; @@ -43,8 +43,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; -import static fr.pasteur.ida.zellige.steps.Utils.setPositionAndGet; - public class DistanceImageWriter< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > { @@ -52,40 +50,39 @@ public class DistanceImageWriter< T extends RealType< T > & NativeType< T >, R e private final RandomAccessibleInterval< T > groundTruth; private final RandomAccessibleInterval< R > projection; private final String fileName; - private final String[][] distances; - private final int subtract = - 1; + private final int subtract; public DistanceImageWriter( RandomAccessibleInterval< T > groundTruth, - RandomAccessibleInterval< R > heightMap, String fileName ) + RandomAccessibleInterval< R > heightMap, String fileName, int subtract ) { this.groundTruth = groundTruth; this.projection = heightMap; this.fileName = fileName; - distances = new String[ ( int ) groundTruth.dimension( 1 ) ][ ( int ) groundTruth.dimension( 0 ) ]; + this.subtract = subtract; } public static < T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > void create( RandomAccessibleInterval< T > groundTruth, - RandomAccessibleInterval< R > heightMap, String fileName ) throws IOException + RandomAccessibleInterval< R > heightMap, String fileName, int subtract ) throws IOException { - DistanceImageWriter writer = new DistanceImageWriter( groundTruth, heightMap, fileName ); + DistanceImageWriter< T, R > writer = new DistanceImageWriter<>( groundTruth, heightMap, fileName, subtract ); writer.run(); -// writer.writeInfile(); } + @SuppressWarnings( { "unchecked", "DuplicatedCode" } ) public static void main( String[] args ) throws IOException { String pathGT = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\Mouche_c01_f0001_p013\\GT\\Ground truth Height map_4_crop.tif"; String pathHM = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\Paper_012022\\Mouche\\Mouche_HM_3.tif"; - final SCIFIOImgPlus< ? > imgPlusRef = IO.openImgs( pathGT ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlusRef = IO.openAll( pathGT ).get( 0 ); Img< FloatType > GT = ( Img< FloatType > ) imgPlusRef.getImg(); new ImageJ(); ImageJFunctions.show( GT ); - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( pathHM ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( pathHM ).get( 0 ); Img< FloatType > HM = ( Img< FloatType > ) imgPlus.getImg(); ImageJFunctions.show( HM ); - DistanceImageWriter.create( GT, HM, "Mouche_distance4_crop" ); + DistanceImageWriter.create( GT, HM, "Mouche_distance4_crop", - 1 ); } public void run() throws IOException @@ -93,8 +90,8 @@ public class DistanceImageWriter< T extends RealType< T > & NativeType< T >, R e CSVWriter writer = new CSVWriter( fileName ); String[] header = { "x", "y", "distance" }; writer.writeToFile( header ); - float[][] GT = convert( groundTruth, 0 ); - float[][] HM = convert( projection, 0 ); + float[][] GT = Util.convert( groundTruth, 0 ); + float[][] HM = Util.convert( projection, 0 ); double mse = 0; int count = 0; for ( int x = 0; x < GT[ 0 ].length; x++ ) @@ -107,7 +104,6 @@ public class DistanceImageWriter< T extends RealType< T > & NativeType< T >, R e { double distance = Math.abs( GTValue - ( HMValue + subtract ) ); writer.writeToFile( new String[]{ String.valueOf( x ), String.valueOf( y ), String.valueOf( distance ) } ); - distances[ y ][ x ] = String.valueOf( distance ); mse += Math.pow( distance, 2 ); count++; } @@ -122,22 +118,4 @@ public class DistanceImageWriter< T extends RealType< T > & NativeType< T >, R e writer.close(); } - - public < S extends RealType< S > & NativeType< S > > float[][] convert( RandomAccessibleInterval< S > input, int subtract ) - { - float[][] array = new float[ ( int ) input.dimension( 1 ) ][ ( int ) input.dimension( 0 ) ]; - RandomAccess< S > access = input.randomAccess(); - for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ ) - { - for ( int y = 0; y < ( int ) input.dimension( 1 ); y++ ) - { - float value = setPositionAndGet( access, x, y ).getRealFloat(); - if ( value + subtract != 0 ) - { - array[ y ][ x ] = value; - } - } - } - return array; - } } diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/test/GroundTruthConversion.java b/src/main/java/fr/pasteur/ida/zellige/utils/test/GroundTruthConversion.java index 510c1ada9ec740047f397afa0bc73a783098b7ac..4427c1f19320c6f1bb288848ae62ef03df01d810 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/test/GroundTruthConversion.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/test/GroundTruthConversion.java @@ -40,15 +40,16 @@ import net.imglib2.type.numeric.real.FloatType; public class GroundTruthConversion { + @SuppressWarnings( "unchecked" ) public static void main( String[] args ) { - ImageJ ij = new ImageJ(); + new ImageJ(); final String refImagePath = "doc/Ground truth Height map.tif"; - final SCIFIOImgPlus< ? > refImgPlus = IO.openImgs( refImagePath ).get( 0 ); + final SCIFIOImgPlus< ? > refImgPlus = IO.openAll( refImagePath ).get( 0 ); Img< FloatType > img = ( Img< FloatType > ) refImgPlus.getImg(); ImageJFunctions.show( img, "Ground truth" ); final String maskPath = "doc/STK_BG_ROI.tif"; - final SCIFIOImgPlus< ? > maskImgPlus = IO.openImgs( maskPath ).get( 0 ); + final SCIFIOImgPlus< ? > maskImgPlus = IO.openAll( maskPath ).get( 0 ); Img< UnsignedByteType > mask = ( Img< UnsignedByteType > ) maskImgPlus.getImg(); ImageJFunctions.show( mask, "BG mask" ); Cursor< UnsignedByteType > cursor = mask.localizingCursor(); diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/test/ParameterSweepFiles.java b/src/main/java/fr/pasteur/ida/zellige/utils/test/ParameterSweepFiles.java index 9d5fab1b420f93f6ae127e277cabb7385eaf4bc8..f7f95cfd4e723e2f6692c31ffbe20008217d4b20 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/test/ParameterSweepFiles.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/test/ParameterSweepFiles.java @@ -45,6 +45,7 @@ public class ParameterSweepFiles< T extends RealType< T > & NativeType< T >, R e private final Img< R > tested; private final String path; + @SuppressWarnings( "unchecked" ) public ParameterSweepFiles( final String[] refImagePath, final String imagePath, String destinationPath ) { /* The reference height maps*/ @@ -52,12 +53,12 @@ public class ParameterSweepFiles< T extends RealType< T > & NativeType< T >, R e for ( String path : refImagePath ) { LOGGER.debug( path ); - SCIFIOImgPlus< ? > refImgPlus = IO.openImgs( path ).get( 0 ); + SCIFIOImgPlus< ? > refImgPlus = IO.openAll( path ).get( 0 ); refs.add( ( Img< T > ) refImgPlus.getImg() ); } /* The raw image to test*/ - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); tested = ( Img< R > ) imgPlus.getImg(); this.path = destinationPath; diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/test/RMSEAndCoverageComputation.java b/src/main/java/fr/pasteur/ida/zellige/utils/test/RMSEAndCoverageComputation.java index 0399011f2ab3aeb166d6594b3f1e642ad962c2a8..b8b01fe35d81a20af3bd52e3e7101265591d476a 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/test/RMSEAndCoverageComputation.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/test/RMSEAndCoverageComputation.java @@ -202,19 +202,20 @@ public class RMSEAndCoverageComputation< T extends RealType< T > & NativeType< T return projection; } + @SuppressWarnings( { "unchecked", "DuplicatedCode" } ) public static void main( String[] args ) throws NotAnHeightMapException, DifferentReferenceTestedSizeException { - String pathGT = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\Covid Zellige\\C2-MucilairB spike zo1 J4 Sars-3_Ground truth Height map.tif"; - String pathHM = "C:\\Users\\ctrebeau\\Nextcloud\\Zellige\\ResultatsJYT\\C2-MucilairB_spike_zo1_J4_Sars-3_SME_ZMAP_ref1_nCH1_CF.tif"; - final SCIFIOImgPlus< ? > imgPlusRef = IO.openImgs( pathGT ).get( 0 ); + String pathGT = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\Mouche_c01_f0001_p013\\GT\\Ground truth Height map_4_crop.tif"; + String pathHM = "C:\\Users\\ctrebeau\\Desktop\\Figures mouche dif values\\blurxy10\\Raw_HM_7.tif"; + final SCIFIOImgPlus< ? > imgPlusRef = IO.openAll( pathGT ).get( 0 ); Img< FloatType > GT = ( Img< FloatType > ) imgPlusRef.getImg(); new ImageJ(); ImageJFunctions.show( GT ); - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( pathHM ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( pathHM ).get( 0 ); Img< FloatType > HM = ( Img< FloatType > ) imgPlus.getImg(); ImageJFunctions.show( HM ); - RMSEAndCoverageComputation computation = new RMSEAndCoverageComputation( GT, 0, HM ); + RMSEAndCoverageComputation< FloatType, FloatType > computation = new RMSEAndCoverageComputation<>( GT, 0, HM ); computation.compute(); LOGGER.debug( "RMSE = " + computation.RMSE ); LOGGER.debug( "Coverage = " + computation.coverage ); diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/test/ZelligePipelineAnalyse.java b/src/main/java/fr/pasteur/ida/zellige/utils/test/ZelligePipelineAnalyse.java index 96700df097e147f3f749d92ad5086803957d6c65..d56bd7abaeff302adfa8ddedf1f51189f233afe0 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/test/ZelligePipelineAnalyse.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/test/ZelligePipelineAnalyse.java @@ -59,6 +59,7 @@ public class ZelligePipelineAnalyse< T extends RealType< T > & NativeType< T >, errorList = new ArrayList<>(); } + @SuppressWarnings( { "unchecked", "rawtypes" } ) public void run( final ZParameters parameters, final Img< R > tested, final ArrayList< Img > GT ) throws Exception { long startTime = System.currentTimeMillis(); @@ -83,13 +84,12 @@ public class ZelligePipelineAnalyse< T extends RealType< T > & NativeType< T >, LOGGER.debug( "Construction processing time : {} ms", constructionProcessingTime ); ArrayList< ReferenceSurface< R > > surfaces = extraction.getReferenceSurfaces(); - for ( Img< T > refImage : GT )// Parsing of GT list. + for ( Img refImage : GT )// Parsing of GT list. { index++; ArrayList< RMSEAndCoverageComputation< T, UnsignedShortType > > tempList = new ArrayList<>(); for ( ReferenceSurface< R > rf : surfaces )// Test of each reconstructed surface { -// ImageJFunctions.show(rf.getZMap(), "Zmap"); RMSEAndCoverageComputation< T, UnsignedShortType > errors = new RMSEAndCoverageComputation<>( refImage, index, rf.getzMap() ); errors.compute(); @@ -109,7 +109,7 @@ public class ZelligePipelineAnalyse< T extends RealType< T > & NativeType< T >, stopTime = System.currentTimeMillis(); LOGGER.debug( "An NoSurfaceFoundException was raised" ); constructionProcessingTime = stopTime - extractionStartTime; - for ( Img< T > refImage : GT )// Parsing of GT list. + for ( int i = 0; i < GT.size(); i++ ) { index++; RMSEAndCoverageComputation< T, UnsignedShortType > errors = diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Construction.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Construction.fxml index 9ffbca1aa051bae8449da9de52ba6ba9731e6372..557e68b8b480d3675b68e2527a19fdd560aaced4 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Construction.fxml +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Construction.fxml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> +<!--suppress JavaFxDefaultTag --> <?import fr.pasteur.ida.zellige.gui.*?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.Label?> @@ -7,7 +8,7 @@ <StepPanel xmlns:fx="http://javafx.com/fxml" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" name="Construction" prefHeight="369.0" prefWidth="405.0" stylesheets="@theme2.css" xmlns="http://javafx.com/javafx" - fx:controller="fr.pasteur.ida.zellige.gui.ConstructionController"> + fx:controller="fr.pasteur.ida.zellige.gui.controller.ConstructionController"> <children> <GridPane alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefHeight="333.0" prefWidth="405.0" vgap="15.0"> @@ -69,8 +70,8 @@ prefHeight="36.0" prefWidth="340.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2" GridPane.vgrow="ALWAYS"> - <ParameterSliderDouble fx:id="surfaceSize" default="0.7" increment="0.05" interval="%INTERVAL3" - major="0.2" max="1" min="0" minor="1" name="Surface min size"/> + <ParameterSliderInteger fx:id="surfaceSize" default="50" increment="1" interval="%INTERVAL4" + major="20" max="100" min="0" minor="3" name="Surface min size"/> </VBox> <Label alignment="CENTER" minWidth="-Infinity" prefHeight="14.0" prefWidth="100.0" rotate="-90.0" diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Display.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Display.fxml index 6daef4a3cf2b317049f9d10bd6564adfb80fb010..511fbddd9357da31ac8c1d72515bc4db553f2881 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Display.fxml +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Display.fxml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> +<!--suppress JavaFxDefaultTag --> <?import fr.pasteur.ida.zellige.gui.*?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.Label?> @@ -37,7 +38,6 @@ </Label> </top> <styleClass> - <String fx:value="step_border"/> <String fx:value="step-title"/> </styleClass> </BorderPane> diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Main.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Main.fxml index 901d9de2731a4063bcc0ae22bb6ee525330e111c..b22f97166fbc38cef4cce29a62376af30f8fe166 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Main.fxml +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Main.fxml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> +<!--suppress JavaFxDefaultTag, JavaFxUnresolvedFxIdReference --> <?import javafx.geometry.Insets?> <?import javafx.scene.control.*?> <?import javafx.scene.image.Image?> @@ -9,7 +10,7 @@ <VBox xmlns:fx="http://javafx.com/fxml" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="786.0" prefWidth="866.0" spacing="5.0" stylesheets="@theme2.css" xmlns="http://javafx.com/javafx" - fx:controller="fr.pasteur.ida.zellige.gui.MainController"> + fx:controller="fr.pasteur.ida.zellige.gui.controller.MainController"> <padding> <Insets left="10.0" right="10.0" top="5.0"/> </padding> @@ -30,7 +31,7 @@ </HBox> <HBox alignment="CENTER_RIGHT" prefHeight="45.0" prefWidth="333.0" spacing="10.0"> <children> - <Button fx:id="load" mnemonicParsing="false" onAction="#loadParameters" text="Load parameters"> + <Button mnemonicParsing="false" onAction="#loadParameters" text="Load parameters"> <graphic> <ImageView fitHeight="15.0" fitWidth="22.0" pickOnBounds="true" preserveRatio="true"> <image> @@ -39,7 +40,7 @@ </ImageView> </graphic> </Button> - <Button fx:id="save" mnemonicParsing="false" onAction="#saveParameters" text="Save Parameters"> + <Button mnemonicParsing="false" onAction="#saveParameters" text="Save Parameters"> <graphic> <ImageView fitHeight="15.0" fitWidth="26.0" pickOnBounds="true" preserveRatio="true"> <image> diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Projection.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Projection.fxml index f96f29fd022265a0f2a639bcb5cb51143c7887bc..db6ff07a78a7dac75d7d3a88d6592d14f3d5ab90 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Projection.fxml +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Projection.fxml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> +<!--suppress JavaFxDefaultTag --> <?import fr.pasteur.ida.zellige.gui.*?> <?import javafx.geometry.*?> <?import javafx.scene.control.*?> @@ -7,7 +8,7 @@ <StepPanel xmlns:fx="http://javafx.com/fxml" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" name="Projection" prefHeight="342.0" prefWidth="400.0" stylesheets="@theme2.css" xmlns="http://javafx.com/javafx" - fx:controller="fr.pasteur.ida.zellige.gui.ProjectionController"> + fx:controller="fr.pasteur.ida.zellige.gui.controller.ProjectionController"> <children> <VBox alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" prefHeight="312.0" prefWidth="389.0"> diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Selection.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Selection.fxml index 13dfafd8bde5896ba08219f9b018e50183b28128..08e23d88d8158eb75380a12fda16204f4cac4b9b 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/Selection.fxml +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/Selection.fxml @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> +<!--suppress JavaFxDefaultTag --> <?import fr.pasteur.ida.zellige.gui.*?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.Label?> <?import javafx.scene.layout.*?> -<StepPanel xmlns:fx="http://javafx.com/fxml" fillWidth="true" maxHeight="-Infinity" maxWidth="-Infinity" +<StepPanel xmlns:fx="http://javafx.com/fxml" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" name="Selection" prefHeight="336.0" prefWidth="815.0" spacing="5.0" stylesheets="@theme2.css" xmlns="http://javafx.com/javafx" - fx:controller="fr.pasteur.ida.zellige.gui.SelectionController"> + fx:controller="fr.pasteur.ida.zellige.gui.controller.SelectionController"> <children> <HBox alignment="CENTER" minHeight="-Infinity" minWidth="-Infinity" prefHeight="293.0" prefWidth="815.0"> <children> diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/StepPanel.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/StepPanel.fxml index 1260545552c3b9ca2643961b5b6f467fa5f4bf14..b49b698657c34246376cdc01c912fcea90b2cca6 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/StepPanel.fxml +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/StepPanel.fxml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> +<!--suppress JavaFxDefaultTag --> <?import javafx.geometry.Insets?> <?import javafx.scene.control.Label?> <?import javafx.scene.control.Separator?> diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/ZSlicesSlider.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/ZSlicesSlider.fxml index 7207d188abdcaf802102f1714048d39a62b577a2..988c4996e1390cd5c0b99e852144befdfff02adc 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/ZSlicesSlider.fxml +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/ZSlicesSlider.fxml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> +<!--suppress JavaFxDefaultTag --> <?import javafx.scene.control.Slider?> <?import javafx.scene.layout.FlowPane?> <fx:root xmlns:fx="http://javafx.com/fxml" alignment="CENTER" columnHalignment="CENTER" prefHeight="47.0" diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/theme2.css b/src/main/resources/fr.pasteur.ida.zellige.gui.view/theme2.css index d1808955d3b4492bdefe1779ae476b5a84223b54..24b3e969eba0a59cc15557d7a3aadb5e98e005cf 100644 --- a/src/main/resources/fr.pasteur.ida.zellige.gui.view/theme2.css +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/theme2.css @@ -27,6 +27,7 @@ * #L% */ +/*noinspection CssInvalidFunction*/ .root { -fx-base: #ececec; -fx-color: -fx-base; @@ -92,6 +93,7 @@ parameter-slider-integer.label { } +/*noinspection ALL*/ .slider .thumb { -fx-background-color: linear-gradient(to bottom, derive(-fx-text-box-border, -20%), derive(-fx-text-box-border, -30%)), -fx-inner-border, @@ -112,6 +114,7 @@ parameter-slider-integer.label { -fx-background-radius: 1.0em; /* makes sure this remains circular */ } +/*noinspection CssInvalidFunction*/ .slider .track { -fx-background-color: #484c54A3, linear-gradient(to bottom, derive(-fx-text-box-border, -10%), -fx-text-box-border), @@ -144,6 +147,7 @@ parameter-slider-integer.label { -fx-alignment: center; } +/*noinspection CssInvalidPseudoSelector*/ .text-input:error { -fx-text-fill: black; -fx-border-insets: 0; @@ -153,6 +157,7 @@ parameter-slider-integer.label { -fx-background-color: derive(red, 99%); } +/*noinspection CssInvalidFunction*/ .text-input:focused { -fx-highlight-fill: -fx-accent; -fx-highlight-text-fill: white; diff --git a/src/main/resources/gui.properties b/src/main/resources/gui.properties index b559d6b7142be08fb7f9350fe826b80d9e48cb7f..d6c80ea2c53cd339622ae413785fc02cb351ab6e 100644 --- a/src/main/resources/gui.properties +++ b/src/main/resources/gui.properties @@ -32,4 +32,5 @@ INTERVAL1=[0-9]|[1-4][0-9]|[5][0] INTERVAL2=[0-9]|[1][0] #[0.0 - 1.0] INTERVAL3=0?\\.[0-9]|[1]\\.[0]?|[0]|[1] -# +#[0 - 100] +INTERVAL4=[0-9]|[1-9][0-9]|[1][0][0] diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/DoubleParameterSweep.java b/src/test/java/fr/pasteur/ida/zellige/behavior/DoubleParameterSweep.java deleted file mode 100644 index dba9cef9a6cda36abedcba346b1c835b0275e2f4..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/DoubleParameterSweep.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -//package fr.pasteur.ida.zellige.behavior; -// -//import fr.pasteur.ida.zellige.ReferenceSurfaceExtraction; -//import fr.pasteur.ida.zellige.utils.test.ZParameters; -//import fr.pasteur.ida.zellige.utils.test.CSVWriter; -//import fr.pasteur.ida.zellige.utils.test.ParameterSweepFiles; -//import fr.pasteur.ida.zellige.utils.test.RMSEAndCoverageComputation; -//import fr.pasteur.ida.zellige.utils.test.ZelligePipelineAnalyse; -//import net.imglib2.img.Img; -//import net.imglib2.type.numeric.real.FloatType; -//import org.junit.jupiter.api.AfterAll; -//import org.junit.jupiter.api.BeforeAll; -//import org.junit.jupiter.params.ParameterizedTest; -//import org.junit.jupiter.params.provider.CsvFileSource; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -//import java.io.IOException; -//import java.util.ArrayList; -// -// -//public class DoubleParameterSweep -//{ -// -// private final static Logger LOGGER = LoggerFactory.getLogger( DoubleParameterSweep.class ); -// static ArrayList< Img< FloatType > > ref; -// static Img< FloatType > tested; -// private static CSVWriter writer; -// -// @BeforeAll -// static void init() throws IOException -// { -// String imagePath = "src/test/resources/Mouche_c01_f0001_p013/STK_Mouche_c01_f0001_p013.tif"; -// final String[] refImagePath = new String[]{ -// "src/test/resources/Mouche_c01_f0001_p013/Ground truth Height map_1.tif", -// "src/test/resources/Mouche_c01_f0001_p013/Ground truth Height map_2.tif", -// "src/test/resources/Mouche_c01_f0001_p013/Ground truth Height map_3.tif", -// "src/test/resources/Mouche_c01_f0001_p013/Ground truth Height map_4.tif" }; -// ParameterSweepFiles files = new ParameterSweepFiles( refImagePath, imagePath, "Mouche_c01_f0001_p013_doubleSweep" ); -// ref = files.getRefs(); -// tested = files.getTested(); -// writer = new CSVWriter( files.getPath() ); -// String[] header = { "Parameter1", "Parameter1Value", "Parameter2", "Parameter2Value", -// "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "ConstructionPT", -// "FS_OS_PT", "FS_surface_PT", "SS_OS_PT", "SS_surface_PT", "Total_PT", -// "FS_OS_count", "FS_startingOS_count", "SS_OS_count", "SS_startingOS_count", -// "FS_good", "FS_small", "FS_finalised", -// "SS_good", "SS_small", "SS_finalised", "OptimizedSet" }; -// writer.writeToFile( header ); -// } -// -// @AfterAll -// static void closeBw() throws IOException -// { -// writer.close(); -// } -// -// @ParameterizedTest -// @CsvFileSource( files = "src/test/resources/Mouche_c01_f0001_p013/Mouche_c01_f0001_p013_SweepThreshold.csv", -// numLinesToSkip = 1, delimiterString = ";" ) -// void parameterSweep3( String testedParameter1, String testedParameterValue1, -// String testedParameter2, String testedParameterValue2, -// String filter, int filterParameter, -// double amplitudeThreshold, double otsuThreshold, -// int ISConnexity, int ISSize, -// double XYSmoothing, double ZSmoothing, -// double startingThreshold1, int overlap1, double connexityRate1, -// double startingThreshold2, int overlap2, double connexityRate2, -// String optimalSet ) throws Exception -// { -// LOGGER.info( "Parameter sweep " ); -// LOGGER.debug( " The parameter sweep is done for a total of {} ground truths", ref.size() ); -// ZParameters parameters = new ZParameters( filter, filterParameter, -// amplitudeThreshold, otsuThreshold, ISConnexity, ISSize, XYSmoothing, ZSmoothing, -// startingThreshold1, overlap1, connexityRate1, -// startingThreshold2, overlap2, connexityRate2 ); -// double adequacy = 1; -// ReferenceSurfaceExtraction.setAdequacy( adequacy ); -// parameters.print(); -// ZelligePipelineAnalyse analyse = new ZelligePipelineAnalyse(); -// analyse.run( parameters, tested, ref ); -// for ( RMSEAndCoverageComputation r : analyse.getErrorList() ) -// { -// String[] line = buildStringLine( -// testedParameter1, testedParameterValue1, -// testedParameter2, testedParameterValue2, -// analyse.getErrorAnalysis( r ), optimalSet ); -// writer.writeToFile( line ); -// } -// } -// -// public String[] buildStringLine( String testedParameter1, String testedParameterValue1, String testedParameter2, String testedParameterValue2, -// String[] error, String optimalSet ) -// { -// String[] line = new String[ 5 + error.length ]; -// line[ 0 ] = testedParameter1; -// line[ 1 ] = testedParameterValue1; -// line[ 2 ] = testedParameter2; -// line[ 3 ] = testedParameterValue2; -// int index = 4; -// for ( String s : error ) -// { -// line[ index ] = s; -// index++; -// } -// line[ line.length - 1 ] = optimalSet; -// return line; -// } -//} diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/OneSurfaceConstructionTest.java b/src/test/java/fr/pasteur/ida/zellige/behavior/OneSurfaceConstructionTest.java deleted file mode 100644 index b076b1a9ad1d475c5c4fa020f7267fa855e4c048..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/OneSurfaceConstructionTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.behavior; - -class OneSurfaceConstructionTest -{ - - - -} diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweep.java b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweep.java deleted file mode 100644 index 622deaee639baea4e5d5ae380b6cb3a96e5dbba3..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweep.java +++ /dev/null @@ -1,241 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.behavior; - -import fr.pasteur.ida.zellige.utils.test.*; -import net.imglib2.img.Img; -import net.imglib2.type.NativeType; -import net.imglib2.type.numeric.RealType; -import net.imglib2.type.numeric.integer.UnsignedShortType; -import org.junit.Rule; -import org.junit.internal.runners.statements.FailOnTimeout; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvFileSource; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.rules.Timeout; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.concurrent.TimeoutException; - -import static fr.pasteur.ida.zellige.behavior.Utils.buildStringLine; - -//@Ignore -public class ParameterSweep< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > -{ - - private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweep.class ); - private static CSVWriter writer; - static ArrayList< Img > ref; - static Img tested; - private final int delta = 0; - private final double surfaceMinSizeFactor = 0.05; - private static final int MIN_TIMEOUT = 200; - public String[] errorLine = - new String[]{ - "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", - "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN" }; - - @AfterAll - static void closeBw() throws IOException - { - writer.close(); - } - - @Rule - public Timeout timeout = new Timeout( MIN_TIMEOUT ) - { - public Statement apply( Statement base, Description description ) - { - return new FailOnTimeout( base, MIN_TIMEOUT ) - { - @Override - public void evaluate() throws Throwable - { - try - { - super.evaluate(); - throw new TimeoutException(); - } - catch ( Exception e ) - { - } - } - }; - } - - - }; - - // @Ignore - @BeforeAll - static void init() throws IOException - { - String imagePath = "doc/Mouche.tif"; - final String[] refImagePath = new String[]{ - "src/test/resources/Mouche/Ground truth Height map_1.tif", - "src/test/resources/Mouche/Ground truth Height map_2.tif", - "src/test/resources/Mouche/Ground truth Height map_3.tif", - "src/test/resources/Mouche/Ground truth Height map_4.tif" - - }; - ParameterSweepFiles files = new ParameterSweepFiles( refImagePath, imagePath, "Timeout" ); - ref = files.getRefs(); - tested = files.getTested(); - writer = new CSVWriter( files.getPath() ); - String[] header = { "Parameter1", "Parameter1Value", - "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", - "AmplitudePT", "OtsuPT", "IslandSearchPT", - "ConstructionPT", "FS_OS_PT", "FS_surface_PT", "SS_OS_PT", "SS_surface_PT", "Total_PT", - "FS_OS_count", "FS_startingOS_count", "SS_OS_count", "SS_startingOS_count", - "FS_good", "FS_small", "FS_finalised", - "SS_good", "SS_small", "SS_finalised", "OptimizedSet" }; - writer.writeToFile( header ); - RMSEAndCoverageComputation.setSubtract( - 1 ); - } - - // The test times out and is skipped - public void givesTimeout() throws InterruptedException - { - Thread.sleep( 1000 ); - } - - // @Ignore - @ParameterizedTest - @CsvFileSource( files = "src/test/resources/Mouche/Mouche_ParameterSweep.csv", numLinesToSkip = 1, delimiterString = ";" ) - void parameterSweep( String testedParameter, String testedParameterValue, String filter, int filterParameter, - int amplitudeThreshold, int otsuThreshold, - int ISConnexity, int ISSize, - double XYSmoothing, double ZSmoothing, - double startingThreshold1, int overlap1, double connexityRate1, - double startingThreshold2, int overlap2, double connexityRate2, - String optimalSet ) throws Exception - { - try - { - ZParameters parameters = new ZParameters( filter, filterParameter, - amplitudeThreshold, otsuThreshold, ISConnexity, ISSize, XYSmoothing, ZSmoothing, - startingThreshold1, overlap1, connexityRate1, - startingThreshold2, overlap2, connexityRate2, surfaceMinSizeFactor, delta ); - - parameters.print(); - ZelligePipelineAnalyse< T, R > analyse = new ZelligePipelineAnalyse<>(); - analyse.run( parameters, tested, ref ); - for ( RMSEAndCoverageComputation< T, UnsignedShortType > r : analyse.getErrorList() ) - { - String[] line = buildStringLine( testedParameter, testedParameterValue, analyse.getErrorAnalysis( r ), optimalSet ); - writer.writeToFile( line ); - } - } - catch ( Exception exception ) - { - for ( int i = 0; i < ref.size(); i++ ) - { - writer.writeToFile( errorLine ); - } - } - } - - - // @Disabled( "Ignored" ) - @Test - @CsvSource( value = "Amplitude;0;GaussianBlur;2;0;1;4;5;5;1;0.7;10;0.8;0.1;5;0.9;NO", - delimiterString = ";" ) - void parameterSweepSingle( String testedParameter, String testedParameterValue, String filter, int filterParameter, - int amplitudeThreshold, int otsuThreshold, - int ISConnexity, int ISSize, - double XYSmoothing, double ZSmoothing, - double startingThreshold1, int overlap1, double connexityRate1, - double startingThreshold2, int overlap2, double connexityRate2, - String optimalSet ) throws Exception - { - - try - { - ZParameters parameters = new ZParameters( filter, filterParameter, - amplitudeThreshold, otsuThreshold, ISConnexity, ISSize, XYSmoothing, ZSmoothing, - startingThreshold1, overlap1, connexityRate1, - startingThreshold2, overlap2, connexityRate2, surfaceMinSizeFactor, delta ); - - parameters.print(); - ZelligePipelineAnalyse< T, R > analyse = new ZelligePipelineAnalyse<>(); - analyse.run( parameters, tested, ref ); - for ( RMSEAndCoverageComputation< T, UnsignedShortType > r : analyse.getErrorList() ) - { - String[] line = buildStringLine( testedParameter, testedParameterValue, analyse.getErrorAnalysis( r ), optimalSet ); - writer.writeToFile( line ); - } - } - catch ( InterruptedException exception ) - { - for ( int i = 0; i < ref.size(); i++ ) - { - writer.writeToFile( errorLine ); - } - } - -// ImageJ ij = new ImageJ(); -// LOGGER.info( "Parameter sweep " ); -// LOGGER.debug( " The parameter sweep is done for a total of {} ground truths", ref.size() ); -// ZParameters parameters = new ZParameters( filter, filterParameter, -// amplitudeThreshold, otsuThreshold, ISConnexity, ISSize, XYSmoothing, ZSmoothing, -// startingThreshold1, overlap1, connexityRate1, -// startingThreshold2, overlap2, connexityRate2, surfaceMinSizeFactor, delta ); -// -// parameters.print(); -// ZelligePipelineAnalyse< T, R > analyse = new ZelligePipelineAnalyse(); -// analyse.run( parameters, tested, ref ); -// for ( RMSEAndCoverageComputation r : analyse.getErrorList() ) -// { -// String[] line = buildStringLine( testedParameter, testedParameterValue, analyse.getErrorAnalysis( r ), optimalSet ); -// writer.writeToFile( line ); -// } - - int index = 0; -// for ( RandomAccessibleInterval rai : ref ) -// { -// HM_GT_DifferenceDisplay.displayDiff( ref.get( index ), analyse.getErrorList().get( index ).getProjection() ); -// ImageJFunctions.show( ref.get( index ), "GT" ); -// ImageJFunctions.show( analyse.getErrorList().get( index ).getProjection(), "HM" ); -// index++; -// } -// while ( true ) -// { -// -// } - } - -} diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCochlee2.java b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCochlee2Test.java similarity index 95% rename from src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCochlee2.java rename to src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCochlee2Test.java index 833947d9c82ae6e32c84e8f481b66fe814d94fba..8ad2baa3fee4772dc6738523adb287014492b30c 100644 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCochlee2.java +++ b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCochlee2Test.java @@ -6,13 +6,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,10 +49,11 @@ import static fr.pasteur.ida.zellige.behavior.Utils.buildStringLine; import static java.util.concurrent.TimeUnit.SECONDS; -public class ParameterSweepCochlee2< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > +@SuppressWarnings( { "unchecked", "rawtypes" } ) +public class ParameterSweepCochlee2Test< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > { - private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepCochlee2.class ); + private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepCochlee2Test.class ); private static final String[] header = { "Parameter1", "Parameter1Value", "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "AmplitudePT", "OtsuPT", "IslandSearchPT", @@ -66,13 +67,14 @@ public class ParameterSweepCochlee2< T extends RealType< T > & NativeType< T >, private static final String[] refImagePath = new String[]{ "src/test/resources/Cochlée2/Ground truth Height map.tif" }; + @SuppressWarnings( "rawtype" ) static ArrayList< Img > ref; static Img tested; private static CSVWriter writer; private final int delta = 0; private final String parameterSweepCSVFile = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\Paper_012022\\ProcessingTime\\Cochlée2_PT.csv"; private final double surfaceMinSizeFactor = 0.8; - public String[] errorLine = + public final String[] errorLine = new String[]{ "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN" }; diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCulture.java b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCultureTest.java similarity index 95% rename from src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCulture.java rename to src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCultureTest.java index 085ad523558a280adc6a74f093435917e531ba6a..40483ca1ea03bb6c0d61b8a7784c91397799ead0 100644 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCulture.java +++ b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepCultureTest.java @@ -6,13 +6,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -46,10 +46,11 @@ import java.util.ArrayList; import static fr.pasteur.ida.zellige.behavior.Utils.buildStringLine; -public class ParameterSweepCulture< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > +@SuppressWarnings( { "unchecked", "rawtypes" } ) +public class ParameterSweepCultureTest< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > { - private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepCulture.class ); + private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepCultureTest.class ); private static final String[] header = { "Parameter1", "Parameter1Value", "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "AmplitudePT", "OtsuPT", "IslandSearchPT", @@ -67,9 +68,9 @@ public class ParameterSweepCulture< T extends RealType< T > & NativeType< T >, R static Img tested; private static CSVWriter writer; private final int delta = 0; - private final String parameterSweepCSVFile = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\Paper_012022\\ProcessingTime\\Cuture_PT.csv"; + private final String parameterSweepCSVFile = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\Paper_012022\\ProcessingTime\\Culture_PT.csv"; private final double surfaceMinSizeFactor = 0.3; - public String[] errorLine = + public final String[] errorLine = new String[]{ "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN" }; diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepMouche.java b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepMoucheTest.java similarity index 95% rename from src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepMouche.java rename to src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepMoucheTest.java index 41822cff07bf9e08df1b1b3a58d2aada4e09de06..df529f17e5559330dd8b46ebea25b280ce34a1ba 100644 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepMouche.java +++ b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepMoucheTest.java @@ -6,13 +6,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -46,10 +46,11 @@ import java.util.ArrayList; import static fr.pasteur.ida.zellige.behavior.Utils.buildStringLine; -public class ParameterSweepMouche< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > +@SuppressWarnings( { "unchecked", "rawtypes" } ) +public class ParameterSweepMoucheTest< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > { - private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepMouche.class ); + private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepMoucheTest.class ); private static final String[] header = { "Parameter1", "Parameter1Value", "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "AmplitudePT", "OtsuPT", "IslandSearchPT", @@ -57,7 +58,7 @@ public class ParameterSweepMouche< T extends RealType< T > & NativeType< T >, R "FS_OS_count", "FS_startingOS_count", "SS_OS_count", "SS_startingOS_count", "FS_good", "FS_small", "FS_finalised", "SS_good", "SS_small", "SS_finalised", "OptimizedSet" }; - public String[] errorLine = + public final String[] errorLine = new String[]{ "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN" }; @@ -78,7 +79,6 @@ public class ParameterSweepMouche< T extends RealType< T > & NativeType< T >, R private final String parameterSweepCSVFile = "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\Paper_012022\\ProcessingTime\\Mouche_PT.csv"; private final double surfaceMinSizeFactor = 0.05; - // @Ignore @BeforeAll static void init() throws IOException { diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepOrganoid.java b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepOrganoidTest.java similarity index 95% rename from src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepOrganoid.java rename to src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepOrganoidTest.java index 719db557eb490e74c849f888a302cda4ed2455f8..246dd51f00ed4de1e5c849c45f9dac9daae68f55 100644 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepOrganoid.java +++ b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepOrganoidTest.java @@ -46,10 +46,11 @@ import java.util.ArrayList; import static fr.pasteur.ida.zellige.behavior.Utils.buildStringLine; -public class ParameterSweepOrganoid< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > +@SuppressWarnings( { "unchecked", "rawtypes" } ) +public class ParameterSweepOrganoidTest< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > { - private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepOrganoid.class ); + private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepOrganoidTest.class ); private static final String[] header = { "Parameter1", "Parameter1Value", "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "AmplitudePT", "OtsuPT", "IslandSearchPT", @@ -57,7 +58,7 @@ public class ParameterSweepOrganoid< T extends RealType< T > & NativeType< T >, "FS_OS_count", "FS_startingOS_count", "SS_OS_count", "SS_startingOS_count", "FS_good", "FS_small", "FS_finalised", "SS_good", "SS_small", "SS_finalised", "OptimizedSet" }; - public String[] errorLine = + public final String[] errorLine = new String[]{ "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN" }; diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepPhantom.java b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepPhantomTest.java similarity index 93% rename from src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepPhantom.java rename to src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepPhantomTest.java index 5e8dd59ecc7411e7e8828b0891953f86f64e9386..4c673606b8c72bb079802a3ac8c27346e6269599 100644 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepPhantom.java +++ b/src/test/java/fr/pasteur/ida/zellige/behavior/ParameterSweepPhantomTest.java @@ -46,10 +46,10 @@ import java.util.ArrayList; import static fr.pasteur.ida.zellige.behavior.Utils.buildStringLine; -public class ParameterSweepPhantom< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > +@SuppressWarnings( { "unchecked", "rawtypes" } ) +public class ParameterSweepPhantomTest< T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > { - - private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepPhantom.class ); + private final static Logger LOGGER = LoggerFactory.getLogger( ParameterSweepPhantomTest.class ); private static final String[] header = { "Parameter1", "Parameter1Value", "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "AmplitudePT", "OtsuPT", "IslandSearchPT", @@ -57,7 +57,7 @@ public class ParameterSweepPhantom< T extends RealType< T > & NativeType< T >, R "FS_OS_count", "FS_startingOS_count", "SS_OS_count", "SS_startingOS_count", "FS_good", "FS_small", "FS_finalised", "SS_good", "SS_small", "SS_finalised", "OptimizedSet" }; - public String[] errorLine = + public final String[] errorLine = new String[]{ "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN", "NaN" }; @@ -78,7 +78,7 @@ public class ParameterSweepPhantom< T extends RealType< T > & NativeType< T >, R // @Ignore @BeforeAll - static void init() throws IOException + static < T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > void init() throws IOException { ParameterSweepFiles files = new ParameterSweepFiles( refImagePath, imagePath, "PT_" + sample ); ref = files.getRefs(); @@ -131,6 +131,4 @@ public class ParameterSweepPhantom< T extends RealType< T > & NativeType< T >, R } } } - - } diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/PipelineTest.java b/src/test/java/fr/pasteur/ida/zellige/behavior/PipelineTest.java deleted file mode 100644 index 2014e845c5228ac9fc036d9419bc1f2c073579f1..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/PipelineTest.java +++ /dev/null @@ -1,253 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -//package fr.pasteur.ida.zellige.behavior; -// -//import fr.pasteur.ida.zellige.ReferenceSurfaceExtraction; -//import fr.pasteur.ida.zellige.utils.jzy3D.HM_GT_Display; -//import fr.pasteur.ida.zellige.utils.test.ZParameters; -//import fr.pasteur.ida.zellige.utils.test.CSVWriter; -//import fr.pasteur.ida.zellige.utils.test.ParameterSweepFiles; -//import fr.pasteur.ida.zellige.utils.test.RMSEAndCoverageComputation; -//import fr.pasteur.ida.zellige.utils.test.ZelligePipelineAnalyse; -//import ij.ImageJ; -//import net.imglib2.img.Img; -//import net.imglib2.type.NativeType; -//import net.imglib2.type.numeric.RealType; -//import net.imglib2.type.numeric.real.FloatType; -//import org.junit.jupiter.api.AfterAll; -//import org.junit.jupiter.api.BeforeAll; -//import org.junit.jupiter.params.ParameterizedTest; -//import org.junit.jupiter.params.provider.CsvFileSource; -//import org.junit.jupiter.params.provider.CsvSource; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -//import java.io.IOException; -//import java.util.ArrayList; -// -// -//public class PipelineTest < T extends RealType< T > & NativeType< T >, R extends RealType < R > & NativeType < R > > -//{ -// -// private final static Logger LOGGER = LoggerFactory.getLogger( PipelineTest.class ); -// ArrayList< Img< T > > ref; -// Img< R > tested; -// private static CSVWriter writer; -// -// @BeforeAll -// void init() -// { -// String imagePath = "C:\\Users\\ctrebeau\\Desktop\\STK_Mouche_c01_f0001_p013\\STK_Mouche_c01_f0001_p013.tif"; -// final String[] refImagePath = new String[]{ -// "C:\\Users\\ctrebeau\\Desktop\\STK_Mouche_c01_f0001_p013\\GT\\Ground truth Height map_1.tif", -// "C:\\Users\\ctrebeau\\Desktop\\STK_Mouche_c01_f0001_p013\\GT\\Ground truth Height map_2.tif", -// "C:\\Users\\ctrebeau\\Desktop\\STK_Mouche_c01_f0001_p013\\GT\\Ground truth Height map_3.tif", -// "C:\\Users\\ctrebeau\\Desktop\\STK_Mouche_c01_f0001_p013\\GT\\Ground truth Height map_4.tif" }; -// ParameterSweepFiles files = new ParameterSweepFiles( refImagePath, imagePath, "Mouche_c01_f0001_p013_08" ); -// ref = files.getRefs(); -// tested = files.getTested(); -// writer = new CSVWriter( files.getPath() ); -// } -// -// @AfterAll -// static void closeBw() throws IOException -// { -// writer.close(); -// } -// -// @ParameterizedTest -// @CsvFileSource( files = "C:\\Users\\ctrebeau\\Desktop\\STK_Mouche_c01_f0001_p013\\Mouche_c01_f0001_p013_SweepSelection.csv", numLinesToSkip = 2, delimiterString = ";" ) -// void parameterSweep( String testedParameter, String testedParameterValue, String filter, int filterParameter, -// double amplitudeThreshold, double otsuThreshold, -// int ISConnexity, int ISSize, -// double XYSmoothing, double ZSmoothing, -// double startingThreshold1, int overlap1, double connexityRate1, -// double startingThreshold2, int overlap2, double connexityRate2, -// String optimalSet ) throws Exception -// { -// LOGGER.info( "Parameter sweep " ); -// LOGGER.debug( " The parameter sweep is done for a total of {} ground truths", ref.size() ); -// ZParameters parameters = new ZParameters( filter, filterParameter, -// amplitudeThreshold, otsuThreshold, ISConnexity, ISSize, XYSmoothing, ZSmoothing, -// startingThreshold1, overlap1, connexityRate1, -// startingThreshold2, overlap2, connexityRate2 ); -// double adequacy = 1; -// ReferenceSurfaceExtraction.setAdequacy( adequacy ); -// parameters.print(); -// ZelligePipelineAnalyse analyse = new ZelligePipelineAnalyse(); -// analyse.run( parameters, tested, ref ); -// for ( RMSEAndCoverageComputation r : analyse.getErrorList() ) -// { -// String[] line = buildStringLine( testedParameter, testedParameterValue, analyse.getErrorAnalysis( r ), optimalSet ); -// writer.writeToFile( line ); -// } -// } -// -// @ParameterizedTest -// @CsvFileSource( files = "C:\\Users\\ctrebeau\\Desktop\\STK_Mouche_c01_f0001_p013\\Mouche_c01_f0001_p013_SweepThreshold.csv", -// numLinesToSkip = 12, delimiterString = ";" ) -// void parameterSweep3( String testedParameter1, String testedParameterValue1, -// String testedParameter2, String testedParameterValue2, -// String filter, int filterParameter, -// double amplitudeThreshold, double otsuThreshold, -// int ISConnexity, int ISSize, -// double XYSmoothing, double ZSmoothing, -// double startingThreshold1, int overlap1, double connexityRate1, -// double startingThreshold2, int overlap2, double connexityRate2, -// String optimalSet ) throws Exception -// { -// LOGGER.info( "Parameter sweep " ); -// LOGGER.debug( " The parameter sweep is done for a total of {} ground truths", ref.size() ); -// ZParameters parameters = new ZParameters( filter, filterParameter, -// amplitudeThreshold, otsuThreshold, ISConnexity, ISSize, XYSmoothing, ZSmoothing, -// startingThreshold1, overlap1, connexityRate1, -// startingThreshold2, overlap2, connexityRate2 ); -// double adequacy = 1; -// ReferenceSurfaceExtraction.setAdequacy( adequacy ); -// parameters.print(); -// ZelligePipelineAnalyse analyse = new ZelligePipelineAnalyse(); -// analyse.run( parameters, tested, ref ); -// String[] header = { "Parameter1", "Parameter1Value", "Parameter2", "Parameter2Value", -// "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "ConstructionPT", -// "FS_OS_PT", "FS_surface_PT", "SS_OS_PT", "SS_surface_PT", "Total_PT", -// "FS_OS_count", "FS_startingOS_count", "SS_OS_count", "SS_startingOS_count", "FS_good", "FS_small", "FS_finalised", -// "SS_good", "SS_small", "SS_finalised", "OptimizedSet" }; -// writer.writeToFile( header ); -// for ( RMSEAndCoverageComputation r : analyse.getErrorList() ) -// { -// String[] line = buildStringLine( -// testedParameter1, testedParameterValue1, -// testedParameter2, testedParameterValue2, -// analyse.getErrorAnalysis( r ), optimalSet ); -// writer.writeToFile( line ); -// } -// } -// -// @ParameterizedTest -// @CsvSource( value = "AmplitudeThreshold;0.8;GaussianBlur;2;0.8;0.1;4;5;4;1;0.75;10;0.8;0.1;10;0.9;YES", -// delimiterString = ";" ) -// void parameterSweep2( String testedParameter, String testedParameterValue, String filter, int filterParameter, -// double amplitudeThreshold, double otsuThreshold, -// int ISConnexity, int ISSize, -// double XYSmoothing, double ZSmoothing, -// double startingThreshold1, int overlap1, double connexityRate1, -// double startingThreshold2, int overlap2, double connexityRate2, -// String optimalSet ) throws Exception -// { -// ImageJ ij = new ImageJ(); -// LOGGER.info( "Parameter sweep " ); -// LOGGER.debug( " The parameter sweep is done for a total of {} ground truth", ref.size() ); -// ZParameters parameters = new ZParameters( filter, filterParameter, -// amplitudeThreshold, otsuThreshold, ISConnexity, ISSize, XYSmoothing, ZSmoothing, -// startingThreshold1, overlap1, connexityRate1, -// startingThreshold2, overlap2, connexityRate2 ); -// double adequacy = 1; -// ReferenceSurfaceExtraction.setAdequacy( adequacy ); -// parameters.print(); -// -// ZelligePipelineAnalyse analyse = new ZelligePipelineAnalyse(); -// analyse.run( parameters, tested, ref ); -// String[] header = { "Parameter1", "Parameter1Value", -// "GroundTruthNb", "SelectedPixelNb", "RMSE", "Coverage", "SelectionPT", "ConstructionPT", -// "FS_OS_PT", "FS_surface_PT", "SS_OS_PT", "SS_surface_PT", "Total_PT", -// "FS_OS_count", "FS_startingOS_count", "SS_OS_count", "SS_startingOS_count", -// "FS_good", "FS_small", "FS_finalised", -// "SS_good", "SS_small", "SS_finalised", "OptimizedSet" }; -// writer.writeToFile( header ); -// if ( ! analyse.getErrorList().isEmpty() ) -// { -// for ( RMSEAndCoverageComputation r : analyse.getErrorList() ) -// { -// String[] line = buildStringLine( testedParameter, testedParameterValue, analyse.getErrorAnalysis( r ), optimalSet ); -// writer.writeToFile( line ); -// HM_GT_Display.displayDiff( r.getGroundTruth(), r.getProjection() ); -// -// } -// } -// else -// { -// for ( Img< FloatType > i : ref ) -// { -// String[] line = buildStringLine( testedParameter, testedParameterValue, analyse.getErrorAnalysis( null ), optimalSet ); -// writer.writeToFile( line ); -// } -// } -// while ( true ) -// { -// -// } -// } -// -// public String[] buildStringLine( String testedParameter1, String testedParameterValue1, -// String[] error, String optimalSet ) -// { -// String[] line = new String[ 3 + error.length ]; -// line[ 0 ] = testedParameter1; -// line[ 1 ] = testedParameterValue1; -// int index = 2; -// for ( String s : error ) -// { -// line[ index ] = s; -// index++; -// } -// line[ line.length - 1 ] = optimalSet; -// return line; -// } -// -// public String[] buildStringLine( String testedParameter1, String testedParameterValue1, String testedParameter2, String testedParameterValue2, -// String[] error, String optimalSet ) -// { -// String[] line = new String[ 5 + error.length ]; -// line[ 0 ] = testedParameter1; -// line[ 1 ] = testedParameterValue1; -// line[ 2 ] = testedParameter2; -// line[ 3 ] = testedParameterValue2; -// int index = 4; -// for ( String s : error ) -// { -// line[ index ] = s; -// index++; -// } -// line[ line.length - 1 ] = optimalSet; -// return line; -// } -// -// public String[] buildStringLine( String[] error, String optimalSet ) -// { -// String[] line = new String[ 1 + error.length ]; -// int index = 0; -// for ( String s : error ) -// { -// line[ index ] = s; -// index++; -// } -// line[ line.length - 1 ] = optimalSet; -// return line; -// } -//} diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/StartingOSE_SameSurfaceTest.java b/src/test/java/fr/pasteur/ida/zellige/behavior/StartingOSESameSurfaceTest.java similarity index 90% rename from src/test/java/fr/pasteur/ida/zellige/behavior/StartingOSE_SameSurfaceTest.java rename to src/test/java/fr/pasteur/ida/zellige/behavior/StartingOSESameSurfaceTest.java index 29003a125b59e020d2a1a1595f908101521bd4bd..c32e9d8818a24b4b8ab4ce88374c113d69e84c34 100644 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/StartingOSE_SameSurfaceTest.java +++ b/src/test/java/fr/pasteur/ida/zellige/behavior/StartingOSESameSurfaceTest.java @@ -39,7 +39,6 @@ import fr.pasteur.ida.zellige.steps.construction.rounds.surface.SurfaceConstruct import fr.pasteur.ida.zellige.steps.selection.Selection; import fr.pasteur.ida.zellige.steps.selection.classification.ClassificationParameters; import fr.pasteur.ida.zellige.steps.selection.exception.DataValidationException; -import fr.pasteur.ida.zellige.steps.selection.exception.EmptyOutputException; import fr.pasteur.ida.zellige.steps.selection.exception.NoClassificationException; import fr.pasteur.ida.zellige.steps.selection.postTreatment.PostTreatmentParameters; import fr.pasteur.ida.zellige.steps.selection.pretreatment.PretreatmentParameters; @@ -49,6 +48,7 @@ import net.imglib2.img.Img; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -57,15 +57,14 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.TreeMap; -import static org.assertj.core.api.Assertions.assertThat; - -public class StartingOSE_SameSurfaceTest +public class StartingOSESameSurfaceTest { - private final static Logger LOGGER = LoggerFactory.getLogger( StartingOSE_SameSurfaceTest.class ); + private final static Logger LOGGER = LoggerFactory.getLogger( StartingOSESameSurfaceTest.class ); + @Ignore @DisplayName( "Two starting OSE from the same surface don't necessarily produce the exact same surface" ) @Test - < T extends RealType< T > & NativeType< T > > void TwoStartingOSEFromTheSameSurface_whenUseForStartASurface_DonTProduceTheExactSameSurface() throws DataValidationException, EmptyOutputException, NoClassificationException + < T extends RealType< T > & NativeType< T > > void TwoStartingOSEFromTheSameSurface_whenUseForStartASurface_DonTProduceTheExactSameSurface() throws DataValidationException, NoClassificationException { /* Parameters*/ int amplitude = 5; @@ -80,21 +79,19 @@ public class StartingOSE_SameSurfaceTest PostTreatmentParameters postTreatmentParameters = new PostTreatmentParameters( sigmaXY, sigmaZ, 5, 8 ); final String imagePath = "doc/Phantom.tif"; - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); - + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); + @SuppressWarnings( "unchecked" ) final Img< T > source = ( Img< T > ) imgPlus.getImg(); Pixels[][] maximums = Selection.run( source, pretreatmentParameters, classificationParameters, postTreatmentParameters ); OSEListArray oseLists = OseConstructionXZ.run( maximums, startingSizeThreshold ); int width = maximums[ 0 ].length; - ArrayList< AbstractOSE > list1 = findAllStartingOSE( oseLists ); + ArrayList< AbstractOSE > osePartOfSurface = findAllStartingOSE( oseLists ); AbstractOSE ose1 = oseLists.getAStartingOse(); Surface reference = SurfaceConstruction.run( oseLists, ose1, width, overlap, connexity ); ArrayList< AbstractOSE > list2 = findAllStartingOSE( oseLists ); - - ArrayList< AbstractOSE > osePartOfSurface = list1; osePartOfSurface.removeAll( list2 ); LOGGER.debug( "surface starting ose : " + osePartOfSurface.size() ); TreeMap< Double, Integer > uniqueSurface = new TreeMap<>(); @@ -108,7 +105,7 @@ public class StartingOSE_SameSurfaceTest uniqueSurface.put( overlappingRate, ( j == null ) ? 1 : j + 1 ); } LOGGER.debug( String.valueOf( uniqueSurface ) ); - assertThat( uniqueSurface.size() > 1 ); + Assertions.assertTrue( uniqueSurface.size() > 1 ); } diff --git a/src/test/java/fr/pasteur/ida/zellige/behavior/SurfaceConstructionBehaviorTest.java b/src/test/java/fr/pasteur/ida/zellige/behavior/SurfaceConstructionBehaviorTest.java deleted file mode 100644 index 9be2483db031cc37d57a42e50a012ad292b350fd..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/behavior/SurfaceConstructionBehaviorTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.behavior; - -import net.imglib2.type.NativeType; -import net.imglib2.type.numeric.RealType; - -public class SurfaceConstructionBehaviorTest< T extends RealType< T > & NativeType< T > > -{ - -// @Test -// void testIt() throws DataValidationException, NoClassificationException, EmptyOutputException -// { -// /* Parameters*/ -// double amplitude = 0; -// double otsu = 1; -// double sigmaXY = 2; -// double sigmaZ = 0; -// double startingSizeThreshold = 0.9; -// int overlap = 10; -// double connexity = 0.7; -// int overlap1 = 30; -// double connexity1 = 0.9; -// -// PretreatmentParameters pretreatmentParameters = new PretreatmentParameters( "Median", 2 ); -// PixelClassificationParameters classificationParameters = new PixelClassificationParameters( amplitude, otsu ); -// PostTreatmentParameters postTreatmentParameters = new PostTreatmentParameters( sigmaXY, sigmaZ, 5, 8 ); -// PixelSelectionParameters pixelSelectionParameters = new PixelSelectionParameters( pretreatmentParameters, classificationParameters, postTreatmentParameters ); -// ConstructionParameters[] constructionParameters = new ConstructionParameters[]{ -// new ConstructionParameters( 0.75, overlap, connexity ), -// new ConstructionParameters( 0.1, overlap1, connexity1 )}; -// ij.ImageJ ij = new ImageJ(); -// final String imagePath = "doc/STK_08.tif"; -// final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); -// -// final Img< T > source = ( Img< T > ) imgPlus.getImg(); -// -// Pixels[][] maximums = PixelSelection.run( source, pixelSelectionParameters ); -// OSEListArray oseLists = OseConstructionXZ.runConstruction( maximums, startingSizeThreshold ); -// -//// displayMaximums( maximums ); -// -// Construction rounds = new Construction(); -// rounds.process( maximums, constructionParameters ); -// ArrayList<Surface> surfaces = rounds.getReferenceSurfaces(); -// for(Surface surface : surfaces) -// { -//// displaySurface( surface ); -// } -// -// while(true); -// } -} diff --git a/src/test/java/fr/pasteur/ida/zellige/element/PixelsTest.java b/src/test/java/fr/pasteur/ida/zellige/element/PixelsTest.java index 867573f6621f930310ff1bff14e0ad1f3f2a1c26..95410785710982ec4f862bc2cfc018f9fd61dbd5 100644 --- a/src/test/java/fr/pasteur/ida/zellige/element/PixelsTest.java +++ b/src/test/java/fr/pasteur/ida/zellige/element/PixelsTest.java @@ -50,40 +50,6 @@ class PixelsTest } - @Test - void add() - { - } - - @Test - void addAll() - { - } - - @Test - void get() - { - } - - @Test - void resetSideCoordinate() - { - } - - @Test - void size() - { - } - - @Test - void testGet() - { - } - - @Test - void containsAll() - { - } @Test void testEquals() @@ -99,8 +65,5 @@ class PixelsTest assertThat( pixels ).isEqualTo( pixels2 ); } - @Test - void testToString() - { - } + } diff --git a/src/test/java/fr/pasteur/ida/zellige/element/SurfaceTest.java b/src/test/java/fr/pasteur/ida/zellige/element/SurfaceTest.java deleted file mode 100644 index fe78a7532a94d5b0a217073841f73ab03f837065..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/element/SurfaceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.element; - -import org.junit.jupiter.api.Test; - -class SurfaceTest -{ - - @Test - void hasDuplicate() - { - } - - @Test - void sameSurface() - { - } - - @Test - void merge() - { - } - - @Test - void transpose() - { - } - - @Test - void get() - { - } - - @Test - void testGet() - { - } - - @Test - void set() - { - } - - @Test - void set1() - { - - } - - @Test - void getZMap() - { - } - - @Test - void getSize() - { - } - - @Test - void getWidth() - { - } - - @Test - void getHeight() - { - } -} diff --git a/src/test/java/fr/pasteur/ida/zellige/parameters/PixelSelectionParametersTest.java b/src/test/java/fr/pasteur/ida/zellige/parameters/PixelSelectionParametersTest.java deleted file mode 100644 index 31fd7d439805ac12f393152aa9d880ec922ebdb1..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/parameters/PixelSelectionParametersTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.parameters; - -public class PixelSelectionParametersTest -{ - -// @Test -// void rightPixelSelectionParameters_whenCreatingANewInstance_DonTRaiseAValidationDataException() -// { -// double amplitudeThreshold = 1.0; -// double otsuThreshold = 1.5; -// double sigmaXY = 2.0; -// double sigmaZ = 3.0; -// assertDoesNotThrow( () -> new PixelSelectionParameters(amplitudeThreshold, otsuThreshold, sigmaXY, sigmaZ) ); -// } -// -// -// @Test -// void amplitudeThresholdUnderZero_WhenCreatingANewInstance_raisesAValidationDataException() -// { -// double amplitudeThreshold = -1; -// double otsuThreshold = 1.5; -// double sigmaXY = 2.0; -// double sigmaZ = 3.0; -// DataValidationException exception = assertThrows(DataValidationException.class, () -> new PixelSelectionParameters(amplitudeThreshold, otsuThreshold, sigmaXY, sigmaZ) ); -// assertThat(exception).hasMessageContaining( "Amplitude" ); -// } -// -// @Test -// void otsuThresholdUnderZero_WhenCreatingANewInstance_raisesAValidationDataException() -// { -// double amplitudeThreshold = 1; -// double otsuThreshold = -1; -// double sigmaXY = 2.0; -// double sigmaZ = 3.0; -// DataValidationException exception = assertThrows(DataValidationException.class, () -> new PixelSelectionParameters(amplitudeThreshold, otsuThreshold, sigmaXY, sigmaZ) ); -// assertThat(exception).hasMessageContaining( "Otsu" ); -// } -// -// @Test -// void sigmaXYThresholdUnderZero_WhenCreatingANewInstance_raisesAValidationDataException() -// { -// double amplitudeThreshold = 1; -// double otsuThreshold = 1; -// double sigmaXY = -1; -// double sigmaZ = 3.0; -// DataValidationException exception = assertThrows(DataValidationException.class, () -> new PixelSelectionParameters(amplitudeThreshold, otsuThreshold, sigmaXY, sigmaZ) ); -// assertThat(exception).hasMessageContaining( "XY" ); -// } -// -// @Test -// void sigmaZThresholdUnderZero_WhenCreatingANewInstance_raisesAValidationDataException() -// { -// double amplitudeThreshold = 1; -// double otsuThreshold = 1; -// double sigmaXY = 1; -// double sigmaZ = -1; -// DataValidationException exception = assertThrows(DataValidationException.class, () -> new PixelSelectionParameters(amplitudeThreshold, otsuThreshold, sigmaXY, sigmaZ) ); -// assertThat(exception).hasMessageContaining( "Z" ); -// } - -} diff --git a/src/test/java/fr/pasteur/ida/zellige/parameters/PretreatmentParametersTest.java b/src/test/java/fr/pasteur/ida/zellige/parameters/PretreatmentParametersTest.java index 479fbb424b3d5125ec32688897001071414816c8..362cf1b5c2ae44358039cd8b360b8fe8e70d6119 100644 --- a/src/test/java/fr/pasteur/ida/zellige/parameters/PretreatmentParametersTest.java +++ b/src/test/java/fr/pasteur/ida/zellige/parameters/PretreatmentParametersTest.java @@ -48,7 +48,7 @@ public class PretreatmentParametersTest @DisplayName( "Any method associated with the right number of parameters should not raise any exception" ) @ParameterizedTest @CsvSource( { GAUSSIAN_BLUR + ", 1" } ) - void rightMethodWithRightParameterValue_whenChecked_doesnTRaiseAnyException( String method, double value ) + void rightMethodWithRightParameterValue_whenChecked_doesntRaiseAnyException( String method, double value ) { assertDoesNotThrow( () -> new PretreatmentParameters( method, value ) ); } diff --git a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/PixelClassificationTest.java b/src/test/java/fr/pasteur/ida/zellige/pixelSelection/PixelClassificationTest.java deleted file mode 100644 index 8ac5107482c236d9cbf002349c267faefe2a969a..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/PixelClassificationTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.pixelSelection; - -class PixelClassificationTest -{ - -// @DisplayName( "When neither of the two thresholds is equals to Zero both classifications are done" ) -// @Test -// void NoneZeroThresholdValue_usesBothClassifications() throws DataValidationException, NoClassificationException, EmptyOutputException -// { -// // Given -// PixelClassificationParameters parameters = new PixelClassificationParameters( 1, 1 ); -// ImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() ); -// RandomAccessibleInterval< FloatType > rai = factory.create( 5, 5, 5 ); -// PixelClassification< FloatType > classificationSpy = spy( new PixelClassification<>() ); -// double amplitudeThreshold = parameters.getAmplitudeThreshold(); -// double otsuThreshold = parameters.getOtsuThreshold(); -// // When -// classificationSpy.process( rai, factory, parameters ); -// // Then -// Mockito.verify( classificationSpy, Mockito.times( 1 ) ).processBothClassification( rai, factory, amplitudeThreshold,otsuThreshold ); -// } -// -// @DisplayName( "When both thresholds equal Zero a DataValidationException is raised" ) -// @Test -// void ZeroThresholdValues_raisesAnException() throws DataValidationException -// { -// // Given -// PixelClassificationParameters parameters = new PixelClassificationParameters( 0, 0 ); -// ImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() ); -// RandomAccessibleInterval< FloatType > rai = factory.create( 5, 5, 5 ); -// PixelClassification< FloatType > classification = new PixelClassification<>(); -// -// // When -// assertThrows(NoClassificationException.class, () -> classification.process( rai, factory, parameters )); -// } -// -// @DisplayName( "When Amplitude Threshold equals Zero only the Otsu classification is done" ) -// @Test -// void AnAmplitudeThresholdSetToZero_usesOnlyOtsuClassification() throws DataValidationException, NoClassificationException, EmptyOutputException -// { -// // Given -// PixelClassificationParameters parameters = new PixelClassificationParameters( 0, 0.1 ); -// ImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() ); -// RandomAccessibleInterval< FloatType > rai = factory.create( 5, 5, 5 ); -// PixelClassification< FloatType > classificationSpy = spy( new PixelClassification<>() ); -// double otsuThreshold = parameters.getOtsuThreshold(); -// // When -// classificationSpy.process( rai, factory, parameters ); -// // Then -// Mockito.verify( classificationSpy, Mockito.times( 1 ) ).processOtsuClassification( rai, factory, otsuThreshold ); -// } -// -// @DisplayName( "When Otsu Threshold equals Zero only the Amplitude classification is done" ) -// @Test -// void AnOtsuThresholdSetToZero_usesOnlyAmplitudeClassification() throws DataValidationException, NoClassificationException, EmptyOutputException -// { -// // Given -// PixelClassificationParameters parameters = new PixelClassificationParameters( 1, 0 ); -// ImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() ); -// RandomAccessibleInterval< FloatType > rai = factory.create( 5, 5, 5 ); -// PixelClassification< FloatType > classificationSpy = spy( new PixelClassification<>() ); -// double amplitudeThreshold = parameters.getAmplitudeThreshold(); -// // When -// classificationSpy.process( rai, factory, parameters ); -// // Then -// Mockito.verify( classificationSpy, Mockito.times( 1 ) ).processAmplitudeClassification( rai, factory, amplitudeThreshold ); -// } - -} diff --git a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/islandSearch/SandTest.java b/src/test/java/fr/pasteur/ida/zellige/pixelSelection/islandSearch/SandTest.java index 003149f6c2ee1cc5ade3d146ef334dbb9e7b6429..3497d2462d84d25ea6cd0208581f631d208f8228 100644 --- a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/islandSearch/SandTest.java +++ b/src/test/java/fr/pasteur/ida/zellige/pixelSelection/islandSearch/SandTest.java @@ -86,6 +86,6 @@ class SandTest { Sand sand = new Sand( 0, 0, 0 ); Sand sand2 = new Sand( 0, 0, 0 ); - assertTrue( sand.equals( sand2 ) ); + assertEquals( sand, sand2 ); } } diff --git a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/pretreatment/PreTreatmentTest.java b/src/test/java/fr/pasteur/ida/zellige/pixelSelection/pretreatment/PreTreatmentTest.java deleted file mode 100644 index 8ff4d20b92a22b11ef479a965527526fa2824e8d..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/pretreatment/PreTreatmentTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.pixelSelection.pretreatment; - -public class PreTreatmentTest -{ - - public static final String GAUSSIAN_BLUR = "GaussianBlur"; - public static final String MEDIAN = "Median"; - - -//@DisplayName("When MEDIAN is selected as method in PretreatmentParameters the medianFilterDenoising method is used" ) -// @Test -// void aMedianFilterAsParameter_whenTreated_usesTheMedianFilterDenoisingMethod() throws DataValidationException -// { -// -// PretreatmentParameters parameters = new PretreatmentParameters( MEDIAN, 2 ); -// RandomAccessibleInterval< FloatType > rai = new ArrayImgFactory<>( new FloatType() ).create( 5, 5, 5 ); -// Pretreatment<FloatType> pretreatment = new Pretreatment<>(rai, parameters); -// Pretreatment<FloatType> pretreatmentSpy = Mockito.spy( pretreatment ); -// pretreatmentSpy.run(); -// Mockito.verify(pretreatmentSpy, Mockito.times( 1 )).medianFilterDenoising(any(RandomAccessibleInterval.class)); -// } -// -// -// @DisplayName("When GAUSSIAN_BLUR is selected as method in PretreatmentParameters the gaussianBlurFilterDenoising method is used" ) -// @Test -// void aGaussianBlurFilterAsParameter_whenTreated_usesTheMedianFilterDenoisingMethod() throws DataValidationException -// { -// PretreatmentParameters parameters = new PretreatmentParameters( GAUSSIAN_BLUR, 1 ); -// RandomAccessibleInterval< FloatType > rai = new ArrayImgFactory<>( new FloatType() ).create( 5, 5, 5 ); -// Pretreatment<FloatType> pretreatment = new Pretreatment<>(rai, parameters); -// Pretreatment<FloatType> pretreatmentSpy = Mockito.spy( pretreatment ); -// pretreatmentSpy.run(); -// Mockito.verify(pretreatmentSpy, Mockito.times( 1 )).gaussianBlurFilterDenoising(any(RandomAccessibleInterval.class)); -// } -} diff --git a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/util/ExtremaDetectionTest.java b/src/test/java/fr/pasteur/ida/zellige/pixelSelection/util/ExtremaDetectionTest.java index 53dd58b78ff65116fe5631fe653180909eba9843..1cdb31be7f6127a37e35cd251212e489fc262de7 100644 --- a/src/test/java/fr/pasteur/ida/zellige/pixelSelection/util/ExtremaDetectionTest.java +++ b/src/test/java/fr/pasteur/ida/zellige/pixelSelection/util/ExtremaDetectionTest.java @@ -46,6 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Matchers.any; import static org.mockito.Mockito.spy; +@SuppressWarnings( { "unchecked", "rawtypes" } ) public class ExtremaDetectionTest { @@ -62,6 +63,7 @@ public class ExtremaDetectionTest assertThat( exception ).hasMessageContaining( "3D image" ); } + @DisplayName( "The input and the factory are the same type" ) @Test void differentTypeBetweenInputAndFactoryWhenProvidedRaisesAnException() diff --git a/src/test/java/fr/pasteur/ida/zellige/utils/LocalExtremaDetectionTest.java b/src/test/java/fr/pasteur/ida/zellige/utils/LocalExtremaDetectionTest.java deleted file mode 100644 index 52b895b755aa0d7ac2007e0db595c3c8df22ac0a..0000000000000000000000000000000000000000 --- a/src/test/java/fr/pasteur/ida/zellige/utils/LocalExtremaDetectionTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * #%L - * Zellige - * %% - * Copyright (C) 2020 - 2022 Institut Pasteur - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package fr.pasteur.ida.zellige.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class LocalExtremaDetectionTest -{ - - @Test - void findMinima() - { - } - - @Test - void findMaxima() - { - } -} diff --git a/src/test/java/fr/pasteur/ida/zellige/utils/RMSEAndCoverageComputationTest.java b/src/test/java/fr/pasteur/ida/zellige/utils/RMSEAndCoverageComputationTest.java index 73e48eb8c7c83de0c46cd3063bf42b26422a708e..dadd908c34fa8214faacd112fa3b0905095659cf 100644 --- a/src/test/java/fr/pasteur/ida/zellige/utils/RMSEAndCoverageComputationTest.java +++ b/src/test/java/fr/pasteur/ida/zellige/utils/RMSEAndCoverageComputationTest.java @@ -40,6 +40,7 @@ import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.IntType; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -101,36 +102,37 @@ public class RMSEAndCoverageComputationTest } + @SuppressWarnings( "unchecked" ) @DisplayName( "Two identical image has an RMSE equals to 0 " ) @Test < T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > void whenTheRefHMAndTheTestedHMAreIdenticalTheRMSEEqualsZero() throws Exception { final String imagePath = "doc/fakeHeightMap.tif"; - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); final Img< T > ref = ( Img< T > ) imgPlus.getImg(); final Img< R > tested = ( Img< R > ) imgPlus.getImg(); RMSEAndCoverageComputation< T, R > determination = new RMSEAndCoverageComputation<>( ref, 0, tested ); - determination.setSubtract( 0 ); + RMSEAndCoverageComputation.setSubtract( 0 ); determination.compute(); assertThat( determination.getRMSE() == 0 ).isTrue(); } + @SuppressWarnings( "unchecked" ) @DisplayName( "Two identical image has an reconstruction proportion equals to 1 " ) @Test < T extends RealType< T > & NativeType< T >, R extends RealType< R > & NativeType< R > > void whenTheRefHMAndTheTestedHMAreIdenticalTheReconstructionProportionEqualsOne() throws Exception { final String imagePath = "doc/fakeHeightMap.tif"; - final SCIFIOImgPlus< ? > imgPlus = IO.openImgs( imagePath ).get( 0 ); + final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 ); final Img< T > ref = ( Img< T > ) imgPlus.getImg(); final Img< R > tested = ( Img< R > ) imgPlus.getImg(); RMSEAndCoverageComputation< T, R > determination = new RMSEAndCoverageComputation<>( ref, 0, tested ); determination.compute(); - assertThat( determination.getCoverage() == 1 ); - + Assertions.assertEquals( determination.getCoverage(), 1 ); } }