Skip to content

Commit 1848ff7

Browse files
committed
Fix problem where segmentations couldn't be used with DeepSSM testing.
1 parent cd93e16 commit 1848ff7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Python/DeepSSMUtilsPackage/DeepSSMUtils/eval_utils.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def get_mesh_from_DT(DT_list, mesh_dir):
4949
if not os.path.exists(mesh_dir):
5050
os.makedirs(mesh_dir)
5151
mesh_files = []
52-
xml_filename = mesh_dir + "temp.xml"
5352
for input_file in DT_list:
5453
print(' ' + get_prefix(input_file))
5554
output_vtk = mesh_dir + "original_" + get_prefix(input_file) + ".vtk"
@@ -59,12 +58,22 @@ def get_mesh_from_DT(DT_list, mesh_dir):
5958
return sorted(mesh_files)
6059

6160

61+
def get_mesh(filename, iso_value=0):
62+
if filename.endswith('.nrrd'):
63+
image = sw.Image(filename)
64+
return image.toMesh(iso_value)
65+
else:
66+
return sw.Mesh(filename)
67+
68+
6269
def get_mesh_from_particles(particle_list, mesh_dir, template_particles, template_mesh, planes=None):
6370
if not os.path.exists(mesh_dir):
6471
os.makedirs(mesh_dir)
6572

6673
warp = sw.MeshWarper()
67-
sw_mesh = sw.Mesh(template_mesh)
74+
75+
# Create mesh from file (mesh or segmentation)
76+
sw_mesh = get_mesh(template_mesh)
6877
sw_particles = np.loadtxt(template_particles)
6978
warp.generateWarp(sw_mesh, sw_particles)
7079

@@ -135,7 +144,7 @@ def get_mesh_distances(pred_particle_files, mesh_list, template_particles, templ
135144
mean_distances.append(-1)
136145
continue
137146
print(f"Computing distance between {mesh_list[index]} and {pred_mesh_list[index]}")
138-
orig_mesh = sw.Mesh(mesh_list[index])
147+
orig_mesh = get_mesh(mesh_list[index], iso_value=0.5)
139148
if planes is not None:
140149
orig_mesh.clip(planes[index][0], planes[index][1], planes[index][2])
141150
pred_mesh = sw.Mesh(pred_mesh_list[index])

0 commit comments

Comments
 (0)