@@ -81,7 +81,7 @@ def pointcloud_surface_fitting(points: ArrayLike, crop_to_bbox=False, mask: sitk
81
81
return poisson_mesh
82
82
83
83
84
- def poisson_reconstruction (fissures : sitk .Image , mask : sitk .Image ):
84
+ def poisson_reconstruction (fissures : sitk .Image , mask : sitk .Image , return_times = False ):
85
85
print ('Performing surface fitting via Poisson Reconstruction' )
86
86
# transforming labelmap to unit spacing
87
87
# fissures = image_ops.resample_equal_spacing(fissures, target_spacing=1.)
@@ -92,6 +92,7 @@ def poisson_reconstruction(fissures: sitk.Image, mask: sitk.Image):
92
92
93
93
# fit plane to each separate fissure
94
94
labels = fissures_tensor .unique ()[1 :]
95
+ times = []
95
96
for f in labels :
96
97
print (f'Fitting fissure { f } ...' )
97
98
# extract the current fissure and construct independent image
@@ -107,6 +108,7 @@ def poisson_reconstruction(fissures: sitk.Image, mask: sitk.Image):
107
108
108
109
# extract point cloud from thinned fissures
109
110
fissure_points = mask_to_points (label_tensor , spacing )
111
+ times .append (time .time () - start )
110
112
print (f'\t Took { time .time () - start :.4f} s' )
111
113
112
114
# compute the mesh
@@ -119,6 +121,7 @@ def poisson_reconstruction(fissures: sitk.Image, mask: sitk.Image):
119
121
remove_all_but_biggest_component (poisson_mesh , right = right ,
120
122
center_x = (fissures .GetSize ()[0 ] * fissures .GetSpacing ()[0 ]) / 2 )
121
123
fissure_meshes .append (poisson_mesh )
124
+ times [- 1 ] += time .time () - start
122
125
print (f'\t Took { time .time () - start :.4f} s' )
123
126
124
127
# convert mesh to labelmap by sampling points
@@ -128,7 +131,10 @@ def poisson_reconstruction(fissures: sitk.Image, mask: sitk.Image):
128
131
regularized_fissures .CopyInformation (fissures )
129
132
130
133
print ('DONE\n ' )
131
- return regularized_fissures , fissure_meshes
134
+ if return_times :
135
+ return regularized_fissures , fissure_meshes , times
136
+ else :
137
+ return regularized_fissures , fissure_meshes
132
138
133
139
134
140
def o3d_mesh_to_labelmap (o3d_meshes : List [o3d .geometry .TriangleMesh ], shape , spacing : Tuple [float ], n_samples = 10 ** 7 ) -> torch .Tensor :
0 commit comments