Fixed bugFixed bug in the reslice image option for the track annotations plugin.
authorabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Thu, 22 Feb 2018 22:50:22 +0000 (22:50 +0000)
committerabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Thu, 22 Feb 2018 22:50:22 +0000 (22:50 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15389 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/plugins/PlugInAlgorithmWormUntwisting.java
mipav/src/plugins/PlugInDialogTrackAnnotations.java

index c856df4..7770872 100644 (file)
@@ -344,6 +344,7 @@ public class PlugInAlgorithmWormUntwisting
        \r
        private static void resliceAnnotations( String path, String name, Vector3f[] conversion, int ySize ) {\r
 \r
+               System.err.println("resliceAnnotations shift = " + conversion[0] + "   offset = " + conversion[1] );\r
                Vector3f shift = conversion[0];\r
                Vector3f offset = conversion[1];\r
                \r
@@ -368,9 +369,11 @@ public class PlugInAlgorithmWormUntwisting
                                float temp = curveOrig.elementAt(j).Y;\r
                                curveOrig.elementAt(j).Y = curveOrig.elementAt(j).Z;\r
                                curveOrig.elementAt(j).Z = (ySize - 1) - temp;\r
+                               \r
+                               System.err.println( curveOrig.elementAt(j) );\r
                        }\r
                }\r
-\r
+               System.err.println("");\r
                LatticeModel.saveAnnotationsAsCSV(path, name + "_reslice.csv", localVOI);\r
                \r
        }\r
index 22e5243..bd1bc0a 100644 (file)
@@ -1114,7 +1114,7 @@ public class PlugInDialogTrackAnnotations extends JFrame implements ActionListen
                                        "straightened_lattice.csv");\r
                        for ( int j = 0; j < lattice.size(); j++ )\r
                        {\r
-                               imageA.registerVOI(convertToLocal(lattice.elementAt(j)));\r
+                               imageA.registerVOI(convertToLocal(lattice.elementAt(j), false));\r
                        }\r
 \r
                        // load any existing annotations from the csv file:\r
@@ -1129,7 +1129,7 @@ public class PlugInDialogTrackAnnotations extends JFrame implements ActionListen
                                if ( annotations != null )\r
                                {\r
 //                                     savedAnnotations = annotations;\r
-                                       savedAnnotations = convertToLocal(annotations);\r
+                                       savedAnnotations = convertToLocal(annotations, true);\r
                                }\r
 //                             annotations = LatticeModel.readAnnotationsCSV(baseFileDir2 + File.separator + subDirName + subDirNameResults + "tracked_annotations" + File.separator +\r
 //                                             "tracked_annotations.csv");             \r
@@ -1381,17 +1381,20 @@ public class PlugInDialogTrackAnnotations extends JFrame implements ActionListen
                return (includeRange != null);\r
        }\r
        \r
-       private VOI convertToLocal( VOI voi ) {\r
+       private VOI convertToLocal( VOI voi, boolean print ) {\r
                if ( !loadReslice.isSelected() /* && !loadRotated.isSelected() */ ) {\r
                        return voi;\r
                }\r
                int shiftX = originalExtents[0]/2;\r
                int shiftY = originalExtents[1]/2;\r
-               int xOffset = (imageA.getExtents()[0] - originalExtents[0])/2;\r
-               int yOffset = (imageA.getExtents()[1] - originalExtents[1])/2;\r
-//             if ( loadRotated.isSelected() )\r
-               {\r
-                       yOffset = (imageA.getExtents()[2] - originalExtents[1])/2;\r
+               int xSize = imageA.getExtents()[0];\r
+               int ySize = imageA.getExtents()[2];\r
+               int xOffset = (xSize - originalExtents[0])/2;\r
+               int yOffset = (ySize - originalExtents[1])/2;\r
+\r
+               if ( print ) {\r
+\r
+                       System.err.println("convertToOriginal shift = " + shiftX + " " + shiftY + "   offset = " + xOffset + " " + yOffset );\r
                }\r
                \r
                VOI localVOI = new VOI(voi);\r
@@ -1416,10 +1419,18 @@ public class PlugInDialogTrackAnnotations extends JFrame implements ActionListen
                                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
+                                       if ( print ) {\r
+                                               System.err.println( curveOrig.elementAt(j) );\r
+                                       }\r
                                }\r
                        }\r
                }\r
+               if ( print ) {\r
+                       System.err.println( "" );\r
+               }\r
                return localVOI;\r
        }\r
        \r
@@ -1430,14 +1441,15 @@ public class PlugInDialogTrackAnnotations extends JFrame implements ActionListen
 \r
                int shiftX = imageA.getExtents()[0]/2;\r
                int shiftY = imageA.getExtents()[1]/2;\r
-               int xOffset = (imageA.getExtents()[0] - originalExtents[0])/2;\r
-               int yOffset = (imageA.getExtents()[1] - originalExtents[1])/2;\r
+               int xSize = imageA.getExtents()[0];\r
+               int ySize = imageA.getExtents()[2];\r
+               int xOffset = (xSize - originalExtents[0])/2;\r
+               int yOffset = (ySize - originalExtents[1])/2;\r
 //             if ( loadRotated.isSelected() )\r
                {\r
                        shiftY = imageA.getExtents()[2]/2;\r
                        yOffset = (imageA.getExtents()[2] - originalExtents[1])/2;\r
                }\r
-               \r
                VOI localVOI = new VOI(voi);\r
                for ( int i = 0; i < localVOI.getCurves().size(); i++ ) {\r
                        VOIBase curveOrig = localVOI.getCurves().elementAt(i);\r
@@ -1446,7 +1458,7 @@ public class PlugInDialogTrackAnnotations extends JFrame implements ActionListen
                                // swap y and z coordinates:\r
                                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).Y = (ySize - 1) - curveOrig.elementAt(j).Z;\r
                                        curveOrig.elementAt(j).Z = temp;\r
                                }\r
                        }\r