Fixed bug in the reslice image option. Was producing the mirror-image instead of...
authorabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Wed, 21 Feb 2018 22:21:50 +0000 (22:21 +0000)
committerabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Wed, 21 Feb 2018 22:21:50 +0000 (22:21 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15387 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/plugins/PlugInAlgorithmWormUntwisting.java

index 75f3d0d..c856df4 100644 (file)
@@ -29,6 +29,7 @@ import gov.nih.mipav.model.algorithms.registration.AlgorithmConstrainedOAR3D;
 import gov.nih.mipav.model.algorithms.utilities.AlgorithmAddMargins;\r
 import gov.nih.mipav.model.algorithms.utilities.AlgorithmMaximumIntensityProjection;\r
 import gov.nih.mipav.model.algorithms.utilities.AlgorithmRGBConcat;\r
+import gov.nih.mipav.model.algorithms.utilities.AlgorithmRotate;\r
 import gov.nih.mipav.model.file.FileIO;\r
 import gov.nih.mipav.model.file.FileVOI;\r
 import gov.nih.mipav.model.structures.ModelImage;\r
@@ -277,7 +278,7 @@ public class PlugInAlgorithmWormUntwisting
                {                       \r
                        for ( int i = 0; i < includeRange.size(); i++ )\r
                        {\r
-                               String imageName = baseFileName + "_" + includeRange.elementAt(i) + "_straight.tif";\r
+                               String imageName = baseFileName + "_" + includeRange.elementAt(i) + "_straight.xml";\r
                                String subDirName = baseFileName + "_" + includeRange.elementAt(i) + File.separator;\r
                                String subDirNameResults = baseFileName + "_" + includeRange.elementAt(i) + "_results" + File.separator;\r
                                File imageFile = new File(baseFileDir + File.separator + subDirName + subDirNameResults + PlugInAlgorithmWormUntwisting.outputImages + File.separator + imageName);\r
@@ -285,15 +286,15 @@ public class PlugInAlgorithmWormUntwisting
                                \r
                                if ( imageFile.exists() ) {                                     \r
                                        Vector3f[] conversion = resliceRotate(imageFile, imageName, xSize, ySize, zSize );                                      \r
-                                       resliceAnnotations( baseFileDir + File.separator + subDirName + subDirNameResults + "straightened_annotations" + File.separator, "straightened_annotations", conversion);\r
-                                       resliceAnnotations( baseFileDir + File.separator + subDirName + subDirNameResults + "straightened_lattice" + File.separator, "straightened_lattice", conversion);\r
-                                       resliceAnnotations( baseFileDir + File.separator + subDirName + subDirNameResults + "straightened_seamcells" + File.separator, "straightened_seamcells", conversion);\r
+                                       resliceAnnotations( baseFileDir + File.separator + subDirName + subDirNameResults + "straightened_annotations" + File.separator, "straightened_annotations", conversion, ySize);\r
+                                       resliceAnnotations( baseFileDir + File.separator + subDirName + subDirNameResults + "straightened_lattice" + File.separator, "straightened_lattice", conversion, ySize);\r
+                                       resliceAnnotations( baseFileDir + File.separator + subDirName + subDirNameResults + "straightened_seamcells" + File.separator, "straightened_seamcells", conversion, ySize);\r
                                }\r
                                if ( imageFile2.exists() ) {\r
                                        Vector3f[] conversion = resliceRotate(imageFile2, imageName, xSize, ySize, zSize );                                     \r
-                                       resliceAnnotations( baseFileDir2 + File.separator + subDirName + subDirNameResults + "straightened_annotations" + File.separator, "straightened_annotations", conversion);\r
-                                       resliceAnnotations( baseFileDir2 + File.separator + subDirName + subDirNameResults + "straightened_lattice" + File.separator, "straightened_lattice", conversion);\r
-                                       resliceAnnotations( baseFileDir2 + File.separator + subDirName + subDirNameResults + "straightened_seamcells" + File.separator, "straightened_seamcells", conversion);\r
+                                       resliceAnnotations( baseFileDir2 + File.separator + subDirName + subDirNameResults + "straightened_annotations" + File.separator, "straightened_annotations", conversion, ySize);\r
+                                       resliceAnnotations( baseFileDir2 + File.separator + subDirName + subDirNameResults + "straightened_lattice" + File.separator, "straightened_lattice", conversion, ySize);\r
+                                       resliceAnnotations( baseFileDir2 + File.separator + subDirName + subDirNameResults + "straightened_seamcells" + File.separator, "straightened_seamcells", conversion, ySize);\r
                                }\r
                        }\r
                }\r
@@ -318,28 +319,17 @@ public class PlugInAlgorithmWormUntwisting
                        \r
                        int[] destExtents = new int[]{xSize,ySize,zSize};\r
 \r
-            ModelImage resliceImage = new ModelImage(wormImage.getType(), destExtents, JDialogBase.makeImageName(wormImage.getImageName(), "_temp.xml"));\r
+            ModelImage resliceImage = new ModelImage(wormImage.getType(), destExtents, JDialogBase.makeImageName(wormImage.getImageName(), "_temp"));\r
+            JDialogBase.updateFileInfo(wormImage, resliceImage);\r
             AlgorithmAddMargins padSlicesAlgo = new AlgorithmAddMargins(wormImage, resliceImage, marginX, marginY, marginZ);\r
             padSlicesAlgo.run();\r
-               \r
                        destExtents = new int[]{xSize,zSize,ySize};\r
 \r
-            ModelImage resultImage = new ModelImage(wormImage.getType(), destExtents, JDialogBase.makeImageName(wormImage.getImageName(), "_reslice.xml"));\r
-\r
-                       dimX = resliceImage.getExtents().length > 0 ? resliceImage.getExtents()[0] : 1;\r
-                       dimY = resliceImage.getExtents().length > 1 ? resliceImage.getExtents()[1] : 1;\r
-                       dimZ = resliceImage.getExtents().length > 2 ? resliceImage.getExtents()[2] : 1;\r
-                       for ( int z = 0; z < dimZ; z++ ) {\r
-                               for ( int y = 0; y < dimY; y++ ) {\r
-                                       for ( int x = 0; x < dimX; x++ ) {\r
-                                               if ( resliceImage.isColorImage() ) {}\r
-                                               else {\r
-                                                       float value = resliceImage.getFloat(x, y, z );\r
-                                                       resultImage.set(x, z, y, value );\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
+            AlgorithmRotate rotateAlgo = new AlgorithmRotate(resliceImage, AlgorithmRotate.X_AXIS_MINUS);\r
+            rotateAlgo.run();\r
+            ModelImage resultImage = rotateAlgo.getDestImage();\r
+            resultImage.setImageName(JDialogBase.makeImageName(wormImage.getImageName(), "_reslice"));\r
+            \r
                        ModelImage.saveImage(resultImage, resultImage.getImageName() + ".xml", imageFile.getParent() + File.separator, false);\r
                ModelImage.saveImage(resultImage, resultImage.getImageName() + ".tif", imageFile.getParent() + File.separator, false);\r
                wormImage.disposeLocal(false);\r
@@ -352,7 +342,7 @@ public class PlugInAlgorithmWormUntwisting
                return null;\r
        }\r
        \r
-       private static void resliceAnnotations( String path, String name, Vector3f[] conversion ) {\r
+       private static void resliceAnnotations( String path, String name, Vector3f[] conversion, int ySize ) {\r
 \r
                Vector3f shift = conversion[0];\r
                Vector3f offset = conversion[1];\r
@@ -377,7 +367,7 @@ public class PlugInAlgorithmWormUntwisting
                        for ( int j = 0; j < curveOrig.size(); j++ ) {\r
                                float temp = curveOrig.elementAt(j).Y;\r
                                curveOrig.elementAt(j).Y = curveOrig.elementAt(j).Z;\r
-                               curveOrig.elementAt(j).Z = temp;\r
+                               curveOrig.elementAt(j).Z = (ySize - 1) - temp;\r
                        }\r
                }\r
 \r