Dicom reader now calculates and sets z resolution values after sorting the files...
authormccreedy@NIH.GOV <mccreedy@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 13 Mar 2018 16:47:23 +0000 (16:47 +0000)
committermccreedy@NIH.GOV <mccreedy@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 13 Mar 2018 16:47:23 +0000 (16:47 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15413 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/gov/nih/mipav/model/file/FileIO.java

index 8b69f55..3722e2b 100644 (file)
@@ -826,19 +826,20 @@ public class FileIO {
                                 // tPt[2] is MIPAV's z-axis. It is the position of the patient\r
                                 // along the axis that the image was sliced on.\r
                                 zOrients[nImages] = tPt[2];\r
+                                \r
                                 computedResAlongPerpendicularLine = true;\r
                                 float dircos0 = matrix.get(2, 0);\r
                                 float dircos1 = matrix.get(2, 1);\r
                                 float dircos2 = matrix.get(2, 2);\r
                                 distanceAlongPerpendicularLine[nImages] = savedFileInfos[nImages].xLocation*dircos0 + \r
-                                               savedFileInfos[nImages].yLocation*dircos1 + savedFileInfos[nImages].zLocation*dircos2;\r
-                                if (nImages > 0) {\r
-                                       float zRes = Math.abs(distanceAlongPerpendicularLine[nImages] - distanceAlongPerpendicularLine[nImages-1]);\r
-                                       savedFileInfos[nImages-1].setResolutions(zRes,2);\r
-                                       if (nImages == nListImages - 1) {\r
-                                       savedFileInfos[nImages].setResolutions(zRes,2); \r
-                                    }\r
-                                }\r
+                                        savedFileInfos[nImages].yLocation*dircos1 + savedFileInfos[nImages].zLocation*dircos2;\r
+//                                if (nImages > 0) {\r
+//                                    float zRes = Math.abs(distanceAlongPerpendicularLine[nImages] - distanceAlongPerpendicularLine[nImages-1]);\r
+//                                    savedFileInfos[nImages-1].setResolutions(zRes,2);\r
+//                                    if (nImages == nListImages - 1) {\r
+//                                        savedFileInfos[nImages].setResolutions(zRes,2); \r
+//                                    }\r
+//                                }\r
                                 \r
                             } else {\r
                                 zOrients[nImages] = 1;\r
@@ -850,6 +851,8 @@ public class FileIO {
                             zInst[nImages] = nImages;\r
                             nImages++;\r
                         } else {\r
+                            // TODO: allow for selection of which series to open if running with a UI\r
+                            \r
                             // series number for this slice doesn't match first one -\r
                             final String message = "FileIO: Found DICOM slice with non-matching series number (slice = " + nImages + "; file = " + fileList[i]\r
                                     + ").  Two image volumes may be stored together in this directory.";\r
@@ -868,19 +871,22 @@ public class FileIO {
 \r
                         if (matrix != null) {\r
                             matrix.transform(savedFileInfos[nImages].xLocation, savedFileInfos[nImages].yLocation, savedFileInfos[nImages].zLocation, tPt);\r
+                            \r
                             computedResAlongPerpendicularLine = true;\r
                             float dircos0 = matrix.get(2, 0);\r
                             float dircos1 = matrix.get(2, 1);\r
                             float dircos2 = matrix.get(2, 2);\r
                             distanceAlongPerpendicularLine[nImages] = savedFileInfos[nImages].xLocation*dircos0 + \r
                                        savedFileInfos[nImages].yLocation*dircos1 + savedFileInfos[nImages].zLocation*dircos2;\r
-                            if (nImages > 0) {\r
-                               float zRes = Math.abs(distanceAlongPerpendicularLine[nImages] - distanceAlongPerpendicularLine[nImages-1]);\r
-                               savedFileInfos[nImages-1].setResolutions(zRes,2);\r
-                               if (nImages == nListImages - 1) {\r
-                                       savedFileInfos[nImages].setResolutions(zRes,2); \r
-                                }\r
-                            }\r
+                            \r
+//                            if (nImages > 0) {\r
+//                             float zRes = Math.abs(distanceAlongPerpendicularLine[nImages] - distanceAlongPerpendicularLine[nImages-1]);\r
+//                             savedFileInfos[nImages-1].setResolutions(zRes,2);\r
+//                             if (nImages == nListImages - 1) {\r
+//                                     savedFileInfos[nImages].setResolutions(zRes,2); \r
+//                                }\r
+//                            }\r
+                            \r
                             zOrients[nImages] = tPt[2];\r
                         } else {\r
                             zOrients[nImages] = 1;\r
@@ -1633,12 +1639,13 @@ public class FileIO {
                 if (computedResAlongPerpendicularLine) {\r
                        // Uses 0020,0032 Image Position and 0020,0037 Image Orientation\r
                        float zRes;\r
+                       \r
                        for (int m = 0; m < nImages; m++) {\r
                                if (m < nImages - 1) {\r
-                                   zRes = Math.abs(distanceAlongPerpendicularLine[m+1] - distanceAlongPerpendicularLine[m]);\r
+                            zRes = Math.abs(distanceAlongPerpendicularLine[indices[m+1]] - distanceAlongPerpendicularLine[indices[m]]);\r
                                }\r
                                else {\r
-                                       zRes = Math.abs(distanceAlongPerpendicularLine[m] - distanceAlongPerpendicularLine[m-1]);       \r
+                                       zRes = Math.abs(distanceAlongPerpendicularLine[indices[m]] - distanceAlongPerpendicularLine[indices[m-1]]);     \r
                                }\r
                         image.getFileInfo(m).setResolutions(zRes, 2);\r
                     }\r