Переглянути джерело

Bug fixes and z axis limit increase to 140

Luka 1 місяць тому
батько
коміт
41571ce2f5
1 змінених файлів з 10 додано та 23 видалено
  1. 10 23
      SeekTransformModule/SeekTransformModule.py

+ 10 - 23
SeekTransformModule/SeekTransformModule.py

@@ -104,7 +104,7 @@ class MyTransformModuleLogic(ScriptedLoadableModuleLogic):
 
             return region
 
-        def detect_points_region_growing(volume_name, intensity_threshold=3000, x_min=90, x_max=380, y_min=190, y_max=380, z_min=80, z_max=120, max_distance=9, centroid_merge_threshold=5):
+        def detect_points_region_growing(volume_name, yesCbct, intensity_threshold=3000, x_min=90, x_max=380, y_min=190, y_max=380, z_min=80, z_max=140, max_distance=9, centroid_merge_threshold=5):
             volume_node = slicer.util.getNode(volume_name)
             if not volume_node:
                 raise RuntimeError(f"Volume {volume_name} not found.")
@@ -114,12 +114,9 @@ class MyTransformModuleLogic(ScriptedLoadableModuleLogic):
             volume_node.GetIJKToRASMatrix(matrix)
 
             dimensions = image_data.GetDimensions()
-            detected_regions = []
+            #detected_regions = []
 
-            # Check if it's CT or CBCT
-            is_cbct = "cbct" in volume_name.lower()
-
-            if is_cbct:
+            if yesCbct: #je cbct?
                 valid_x_min, valid_x_max = 0, dimensions[0] - 1
                 valid_y_min, valid_y_max = 0, dimensions[1] - 1
                 valid_z_min, valid_z_max = 0, dimensions[2] - 1
@@ -380,11 +377,12 @@ class MyTransformModuleLogic(ScriptedLoadableModuleLogic):
         # Process loaded volumes
         for volumeNode in slicer.util.getNodesByClass("vtkMRMLScalarVolumeNode"):
             volumeName = volumeNode.GetName()
+            #print(volumeName)
             shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
             imageItem = shNode.GetItemByDataNode(volumeNode)
             
                # Pridobi vse atribute za ta element
-            attributeNames = shNode.GetItemAttributeNames(imageItem)
+            #attributeNames = shNode.GetItemAttributeNames(imageItem)
             
             #modality = shNode.GetItemAttribute(imageItem, 'DICOM.Modality')
             #manufacturer = shNode.GetItemAttribute(imageItem, 'DICOM.Manufacturer')
@@ -396,17 +394,19 @@ class MyTransformModuleLogic(ScriptedLoadableModuleLogic):
                 continue
             
             manufacturer = shNode.GetItemAttribute(imageItem, 'DICOM.Manufacturer')
-            
+            #print(manufacturer.lower())
             # Determine scan type
-            if "varian" in manufacturer.lower():
+            if "varian" in manufacturer.lower() or "elekta" in manufacturer.lower():
                 cbct_list.append(volumeName)
                 scan_type = "CBCT"
+                yesCbct = True
             else: #Siemens or phillips imamo CTje
                 ct_list.append(volumeName)
                 scan_type = "CT"
+                yesCbct = False
             
             # Detect points using region growing
-            grouped_points = detect_points_region_growing(volumeName, intensity_threshold=3000)
+            grouped_points = detect_points_region_growing(volumeName, yesCbct, intensity_threshold=3000)
             volume_points_dict[(scan_type, volumeName)] = grouped_points
 
         # Print the results
@@ -451,19 +451,6 @@ class MyTransformModuleLogic(ScriptedLoadableModuleLogic):
                     # print("Rotation Matrix:\n", quaternion_rotation_matrix)
                     # print("Translation Vector:\n", quaternion_translation_vector)
 
-                    # Primer neporavnanih točk
-                    moving_points = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
-                    fixed_points = np.array([[2, 3, 4], [5, 6, 7], [8, 9, 10]])
-
-                    # Uporaba ICP algoritma
-                    aligned_points, R, t = icp_algorithm(moving_points, fixed_points)
-
-                    print("Poravnane točke:")
-                    print(aligned_points)
-                    print("Optimalna rotacijska matrika R:")
-                    print(R)
-                    print("Optimalni translacijski vektor t:")
-                    print(t)
                     
                     
                     # Izberi metodo glede na uporabnikov izbor