Skip to content

Commit 4ecc940

Browse files
committed
Suppress messages from VTK
1 parent 9268fd2 commit 4ecc940

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

diffdrr/visualization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,12 @@ def make_fig(ground_truth):
124124

125125
# %% ../notebooks/api/04_visualization.ipynb 9
126126
import pyvista
127+
import vtk
127128

128129
from .drr import DRR
129130

131+
vtk.vtkLogger.SetStderrVerbosity(vtk.vtkLogger.ConvertToVerbosity(-1))
132+
130133
# %% ../notebooks/api/04_visualization.ipynb 10
131134
def drr_to_mesh(
132135
drr: DRR,

notebooks/api/04_visualization.ipynb

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,11 @@
213213
"source": [
214214
"#| export\n",
215215
"import pyvista\n",
216+
"import vtk\n",
216217
"\n",
217-
"from diffdrr.drr import DRR"
218+
"from diffdrr.drr import DRR\n",
219+
"\n",
220+
"vtk.vtkLogger.SetStderrVerbosity(vtk.vtkLogger.ConvertToVerbosity(-1))"
218221
]
219222
},
220223
{
@@ -257,7 +260,7 @@
257260
" method=\"marching_cubes\",\n",
258261
" progress_bar=verbose,\n",
259262
" )\n",
260-
" \n",
263+
"\n",
261264
" # Process the mesh\n",
262265
" mesh.extract_largest(inplace=True, progress_bar=verbose)\n",
263266
" mesh.point_data.clear()\n",
@@ -275,18 +278,24 @@
275278
" mesh.decimate_pro(0.25, inplace=True, progress_bar=verbose)\n",
276279
" mesh.fill_holes(100, inplace=True, progress_bar=verbose)\n",
277280
" mesh.clean(inplace=True, progress_bar=verbose)\n",
278-
" \n",
281+
"\n",
279282
" elif method == \"surface_nets\":\n",
280-
" grid.point_data[\"values\"] = drr.volume.cpu().numpy().flatten(order=\"F\") > threshold\n",
283+
" grid.point_data[\"values\"] = (\n",
284+
" drr.volume.cpu().numpy().flatten(order=\"F\") > threshold\n",
285+
" )\n",
281286
" try:\n",
282287
" mesh = grid.contour_labeled(smoothing=True, progress_bar=verbose)\n",
283288
" except AttributeError as e:\n",
284-
" raise AttributeError(f\"{e}, ensure you are using pyvista>=0.43 and vtk>=9.3\")\n",
289+
" raise AttributeError(\n",
290+
" f\"{e}, ensure you are using pyvista>=0.43 and vtk>=9.3\"\n",
291+
" )\n",
285292
" mesh.clear_cell_data()\n",
286293
"\n",
287294
" else:\n",
288-
" raise ValueError(f\"method must be `marching_cubes` or `surface_nets`, not {method}\")\n",
289-
" \n",
295+
" raise ValueError(\n",
296+
" f\"method must be `marching_cubes` or `surface_nets`, not {method}\"\n",
297+
" )\n",
298+
"\n",
290299
" return mesh"
291300
]
292301
},
@@ -298,7 +307,9 @@
298307
"outputs": [],
299308
"source": [
300309
"#| export\n",
301-
"def img_to_mesh(drr: DRR, rotations, translations, parameterization, convention=None, **kwargs):\n",
310+
"def img_to_mesh(\n",
311+
" drr: DRR, rotations, translations, parameterization, convention=None, **kwargs\n",
312+
"):\n",
302313
" \"\"\"\n",
303314
" For a given pose (not batched), turn the camera and detector into a mesh.\n",
304315
" Additionally, render the DRR for the pose. Convert into a texture that\n",

notebooks/tutorials/visualization.ipynb

Lines changed: 1 addition & 11 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)