Skip to content

Commit

Permalink
Updated default values and UI. Added visualization for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryHeres committed May 2, 2024
1 parent 835ea1f commit 00880e2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
8 changes: 4 additions & 4 deletions SlicerBoneMorphing/Resources/UI/SlicerBoneMorphing.ui
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
<string>Preprocessing parameters</string>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="collapsed">
<bool>true</bool>
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_16">
<item row="0" column="0" colspan="2">
Expand All @@ -112,7 +112,7 @@
<item row="0" column="0">
<widget class="QLabel" name="preprocessingDownsamplingDistanceThresholdLabel">
<property name="toolTip">
<string>The higher the number, the lower the distance threshold for a neighbour point to be considered</string>
<string>Maximum distance in which points are considered neighbouring</string>
</property>
<property name="text">
<string>Downsampling distance threshold:</string>
Expand Down Expand Up @@ -1107,7 +1107,7 @@
<string>Postprocessing parameters</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_19">
<item row="0" column="0">
Expand Down
6 changes: 3 additions & 3 deletions SlicerBoneMorphing/src/logic/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
PREPROCESSING_KEY_MAX_NN_NORMALS = "mnnn"
PREPROCESSING_KEY_MAX_NN_FPFH = "mnf"

PREPROCESSING_DEFAULT_VALUE_DOWNSAMPLING_DISTANCE_THRESHOLD = 0.1
PREPROCESSING_DEFAULT_VALUE_RADIUS_NORMAL_SCALE = 4
PREPROCESSING_DEFAULT_VALUE_DOWNSAMPLING_DISTANCE_THRESHOLD = 0.05
PREPROCESSING_DEFAULT_VALUE_RADIUS_NORMAL_SCALE = 0.5
PREPROCESSING_DEFAULT_VALUE_RADIUS_FEATURE_SCALE = 10
PREPROCESSING_DEFAULT_VALUE_MAX_NN_NORMALS = 30
PREPROCESSING_DEFAULT_VALUE_MAX_NN_NORMALS = 10
PREPROCESSING_DEFAULT_VALUE_MAX_NN_FPFH = 100

### REGISTRATION PARAMETERS ###
Expand Down
35 changes: 30 additions & 5 deletions SlicerBoneMorphing/src/logic/SlicerBoneMorphingLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,30 @@
elif platform == "win32":
BCPD_EXEC += "bcpd_win32.exe"

SOURCE_VISUALIZATION_COLOR = [0, 1, 0]
TARGET_VISUALIZATION_COLOR = [1, 0, 0]


class SlicerBoneMorphingLogic(ScriptedLoadableModuleLogic):
def __init__(self, parent):
ScriptedLoadableModuleLogic.__init__(self, parent)

def __visualize(self, source, target):
"""
Only for debugging purposes
"""
models = []

if (source != None):
source.paint_uniform_color(SOURCE_VISUALIZATION_COLOR)
models.append(source)

if (target != None):
target.paint_uniform_color(TARGET_VISUALIZATION_COLOR)
models.append(target)

o3d.visualization.draw_geometries(models)

def generate_model(
self,
source_model: vtkMRMLModelNode,
Expand Down Expand Up @@ -71,11 +90,17 @@ def generate_model(
print("Cannot continue with generating. Aborting...")
return EXIT_FAILURE, None, None

source_mesh.transform(result_icp.transformation)

# self.__visualize(source_mesh, target_mesh)

# BCPD stage
deformed = self.__deformable_registration(source_mesh.transform(result_icp.transformation), target_mesh, parameters[BCPD_KEY])
deformed = self.__deformable_registration(source_mesh, target_mesh, parameters[BCPD_KEY])
if (deformed == None):
return EXIT_FAILURE, None, None

# self.__visualize(deformed, None)

generated_polydata, merged_polydata = self.__postprocess_meshes(deformed, target_mesh, parameters[POSTPROCESSING_KEY])

return EXIT_OK, generated_polydata, merged_polydata
Expand Down Expand Up @@ -240,14 +265,14 @@ def __preprocess_point_cloud(
max_nn_normals: int,
max_nn_fpfh: int
) -> Tuple[o3d.geometry.PointCloud, o3d.pipelines.registration.Feature]:
'''
'''
Perform downsampling of a mesh, normal estimation and computing FPFH feature of the point cloud.
Parameters
----------
o3d.geometry.PointCloud pcd: Source point cloud
float downsampling_distance_threshold: Distance threshold for downsampling
float normals_estimation_radius: Radius for estimating normals
float normals_estimation_radius: Radius for estimating normals
float fpfh_estimation_radius: Radius for the FPFH computation
int max_nn_normals: Maximum number of neighbours considered for normals estimation
int max_nn_fpfh: Maximum number of neighbours considered for the FPFH calculation
Expand Down Expand Up @@ -339,12 +364,12 @@ def __deformable_registration(
Parameters
----------
o3d.geometry.PointCloud sourcePcd: source point cloud
o3d.geometry.PointCloud targetPcd: target point cloud
o3d.geometry.PointCloud targetPcd: target point cloud
string bcpdParameters: parameters for the BCPD algorithm
Returns
-------
o3d.geometry.TriangleMesh representing the new deformed mesh
o3d.geometry.TriangleMesh representing the new deformed mesh
"""
source_array = np.asarray(source_pcd.vertices, dtype=np.float32)
target_array = np.asarray(target_pcd.vertices, dtype=np.float32)
Expand Down

0 comments on commit 00880e2

Please sign in to comment.