Skip to content

Commit a1fc5ff

Browse files
authored
Update PyVista to 0.45.0 (#374)
* Change contour_labeled to contour_labels * Change transform inplace to False * Update geometry tutorial * Update package versions * Bump version
1 parent 76fd103 commit a1fc5ff

File tree

8 files changed

+68
-27
lines changed

8 files changed

+68
-27
lines changed

diffdrr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.0"
1+
__version__ = "0.5.1"

diffdrr/visualization.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,15 @@ def drr_to_mesh(
238238
subject.volume.data[0].cpu().numpy().flatten(order="F") > threshold
239239
)
240240
try:
241-
mesh = grid.contour_labeled(smoothing=True, progress_bar=verbose)
241+
mesh = grid.contour_labels(
242+
boundary_style="strict_external",
243+
smoothing=True,
244+
output_mesh_type="quads",
245+
pad_background=True,
246+
orient_faces=True,
247+
simplify_output=False,
248+
progress_bar=verbose,
249+
)
242250
except AttributeError as e:
243251
raise AttributeError(
244252
f"{e}, ensure you are using pyvista>=0.43 and vtk>=9.3"
@@ -249,7 +257,7 @@ def drr_to_mesh(
249257
)
250258

251259
# Transform the mesh using the affine matrix
252-
mesh = mesh.transform(subject.volume.affine.squeeze())
260+
mesh = mesh.transform(subject.volume.affine.squeeze(), inplace=False)
253261

254262
# Preprocess the mesh
255263
if extract_largest:
@@ -284,7 +292,15 @@ def labelmap_to_mesh(
284292

285293
# Run SurfaceNets
286294
grid.point_data["values"] = subject.mask.data[0].numpy().flatten(order="F")
287-
mesh = grid.contour_labeled(smoothing=True, progress_bar=verbose)
295+
mesh = grid.contour_labels(
296+
boundary_style="strict_external",
297+
smoothing=True,
298+
output_mesh_type="quads",
299+
pad_background=True,
300+
orient_faces=True,
301+
simplify_output=False,
302+
progress_bar=verbose,
303+
)
288304
mesh.smooth_taubin(
289305
n_iter=100,
290306
feature_angle=120.0,
@@ -298,7 +314,7 @@ def labelmap_to_mesh(
298314
mesh.clean(inplace=True, progress_bar=verbose)
299315

300316
# Transform the mesh using the affine matrix
301-
mesh = mesh.transform(subject.mask.affine.squeeze())
317+
mesh = mesh.transform(subject.mask.affine.squeeze(), inplace=False)
302318

303319
return mesh
304320

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ dependencies:
1818
- fastcore
1919
- scipy
2020
- tqdm
21-
- pyvista
22-
- vtk
21+
- pyvista>=0.45.0
22+
- vtk>9.4.0

notebooks/api/04_visualization.ipynb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,15 @@
349349
" subject.volume.data[0].cpu().numpy().flatten(order=\"F\") > threshold\n",
350350
" )\n",
351351
" try:\n",
352-
" mesh = grid.contour_labeled(smoothing=True, progress_bar=verbose)\n",
352+
" mesh = grid.contour_labels(\n",
353+
" boundary_style=\"strict_external\",\n",
354+
" smoothing=True, \n",
355+
" output_mesh_type='quads',\n",
356+
" pad_background=True,\n",
357+
" orient_faces=True,\n",
358+
" simplify_output=False,\n",
359+
" progress_bar=verbose,\n",
360+
" )\n",
353361
" except AttributeError as e:\n",
354362
" raise AttributeError(\n",
355363
" f\"{e}, ensure you are using pyvista>=0.43 and vtk>=9.3\"\n",
@@ -360,7 +368,7 @@
360368
" )\n",
361369
"\n",
362370
" # Transform the mesh using the affine matrix\n",
363-
" mesh = mesh.transform(subject.volume.affine.squeeze())\n",
371+
" mesh = mesh.transform(subject.volume.affine.squeeze(), inplace=False)\n",
364372
"\n",
365373
" # Preprocess the mesh\n",
366374
" if extract_largest:\n",
@@ -403,7 +411,15 @@
403411
"\n",
404412
" # Run SurfaceNets\n",
405413
" grid.point_data[\"values\"] = subject.mask.data[0].numpy().flatten(order=\"F\")\n",
406-
" mesh = grid.contour_labeled(smoothing=True, progress_bar=verbose)\n",
414+
" mesh = grid.contour_labels(\n",
415+
" boundary_style=\"strict_external\",\n",
416+
" smoothing=True, \n",
417+
" output_mesh_type='quads',\n",
418+
" pad_background=True,\n",
419+
" orient_faces=True,\n",
420+
" simplify_output=False,\n",
421+
" progress_bar=verbose,\n",
422+
" )\n",
407423
" mesh.smooth_taubin(\n",
408424
" n_iter=100,\n",
409425
" feature_angle=120.0,\n",
@@ -417,7 +433,7 @@
417433
" mesh.clean(inplace=True, progress_bar=verbose)\n",
418434
"\n",
419435
" # Transform the mesh using the affine matrix\n",
420-
" mesh = mesh.transform(subject.mask.affine.squeeze())\n",
436+
" mesh = mesh.transform(subject.mask.affine.squeeze(), inplace=False)\n",
421437
"\n",
422438
" return mesh"
423439
]

notebooks/tutorials/geometry.ipynb

Lines changed: 20 additions & 11 deletions
Large diffs are not rendered by default.

notebooks/tutorials/mask.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)