Added automatic name matching of the landmark registration points for the thin-plate...
authorabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Wed, 4 Apr 2018 15:46:50 +0000 (15:46 +0000)
committerabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Wed, 4 Apr 2018 15:46:50 +0000 (15:46 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15439 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/plugins/PlugInDialogUntwistedToTwisted.java

index c47813a..d5c6228 100644 (file)
@@ -272,10 +272,27 @@ public class PlugInDialogUntwistedToTwisted extends JDialogStandalonePlugin impl
                                        // read registration points and calculate thin-plate spline transform:\r
                                        VOI targetPts = LatticeModel.readAnnotationsCSV(targetPointsFile);\r
                                        VOI inputPts = LatticeModel.readAnnotationsCSV(inputPointsFile);\r
-                                       int numTargetPts = targetPts.getCurves().size();\r
-                                       int numInputPts = inputPts.getCurves().size();\r
-                                       if ( numTargetPts != numInputPts ) {\r
-                                               MipavUtil.displayError( "Number of registration target points and input points must match" );\r
+                                       \r
+                                       Vector<String> commonNames = new Vector<String>();\r
+                                       for ( int i = 0; i < targetPts.getCurves().size(); i++ )\r
+                                       {\r
+                                               String targetName = ((VOIText)targetPts.getCurves().elementAt(i)).getText();\r
+                                               for ( int j = 0; j < inputPts.getCurves().size(); j++ )\r
+                                               {\r
+                                                       String inputName = ((VOIText)inputPts.getCurves().elementAt(j)).getText();\r
+                                                       \r
+                                                       if ( targetName.equals(inputName) )\r
+                                                       {\r
+                                                               commonNames.add(inputName);\r
+                                                               break;\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                                       \r
+                                       \r
+                                       int numTargetPts = commonNames.size();\r
+                                       if ( numTargetPts <= 0 ) {\r
+                                               MipavUtil.displayError( "Target points and input points must match" );\r
                                                return;\r
                                        }\r
                                        double[] xSource = new double[ numTargetPts ]; \r
@@ -284,11 +301,33 @@ public class PlugInDialogUntwistedToTwisted extends JDialogStandalonePlugin impl
                                        double[] xTarget = new double[ numTargetPts ]; \r
                                        double[] yTarget = new double[ numTargetPts ]; \r
                                        double[] zTarget = new double[ numTargetPts ]; \r
-                                       for ( int i = 0; i < numTargetPts; i++ ) {\r
-                                               Vector3f sourcePt = inputPts.getCurves().elementAt(i).elementAt(0);\r
-                                               Vector3f targetPt = targetPts.getCurves().elementAt(i).elementAt(0);\r
-                                               xSource[i] = sourcePt.X;                                        ySource[i] = sourcePt.Y;                                        zSource[i] = sourcePt.Z;\r
-                                               xTarget[i] = targetPt.X;                                        yTarget[i] = targetPt.Y;                                        zTarget[i] = targetPt.Z;\r
+                                       for ( int i = 0; i < commonNames.size(); i++ ) {\r
+                                               Vector3f sourcePt = null;\r
+                                               Vector3f targetPt = null;\r
+                                               for ( int j = 0; j < targetPts.getCurves().size(); j++ )\r
+                                               {\r
+                                                       String targetName = ((VOIText)targetPts.getCurves().elementAt(j)).getText();\r
+                                                       if ( targetName.equals(commonNames.elementAt(i) ) )\r
+                                                       {\r
+                                                               targetPt = targetPts.getCurves().elementAt(j).elementAt(0);\r
+                                                               break;\r
+                                                       }\r
+                                               }\r
+                                               for ( int j = 0; j < inputPts.getCurves().size(); j++ )\r
+                                               {\r
+                                                       String inputName = ((VOIText)inputPts.getCurves().elementAt(j)).getText();\r
+                                                       if ( inputName.equals(commonNames.elementAt(i) ) )\r
+                                                       {\r
+                                                               sourcePt = inputPts.getCurves().elementAt(j).elementAt(0);\r
+                                                               break;\r
+                                                       }\r
+                                               }\r
+                                               if ( sourcePt != null && targetPt != null )\r
+                                               {\r
+                                                       System.err.println( commonNames.elementAt(i) );\r
+                                                       xSource[i] = sourcePt.X;                                        ySource[i] = sourcePt.Y;                                        zSource[i] = sourcePt.Z;\r
+                                                       xTarget[i] = targetPt.X;                                        yTarget[i] = targetPt.Y;                                        zTarget[i] = targetPt.Z;\r
+                                               }\r
                                        }\r
                                        \r
                                        ModelImage inputImage = null;\r