question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doc build issues (DICOM example and charts)

See original GitHub issue

I have some issues when building docs from master, with vtk 9.1.0.

Less problematically there are warning-like printouts coming from one of the example downloads:

No DICOM magic number found, but file appears to be DICOM
Proceeding without caution.

(Two copies of this warning in quick succession.) It may be the download_prostate() example but it’s hard to tell with the updating progress printouts. We should track down and fix or silence this if we can.

More problematically I get errors during chart building (cc @dcbr):

WARNING:root:Encountered issue in callback (most recent call last):ChartMPL.toggle
  File "/home/adeak/pyvista/pyvista/plotting/renderer.py", line 381, in _render_event
    chart._render_event(*args, **kwargs)
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4027, in _render_event
    self._resize()  # Update figure dimensions if needed
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4002, in _resize
    c_w, c_h = self._canvas.get_width_height()
AttributeError: 'NoneType' object has no attribute 'get_width_height'
WARNING:root:Encountered issue in callback (most recent call last):
  File "/home/adeak/pyvista/pyvista/plotting/renderer.py", line 381, in _render_event
    chart._render_event(*args, **kwargs)
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4027, in _render_event
    self._resize()  # Update figure dimensions if needed
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4002, in _resize
    c_w, c_h = self._canvas.get_width_height()
AttributeError: 'NoneType' object has no attribute 'get_width_height'
WARNING:root:Encountered issue in callback (most recent call last):ChartMPL.visible
  File "/home/adeak/pyvista/pyvista/plotting/renderer.py", line 381, in _render_event
    chart._render_event(*args, **kwargs)
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4027, in _render_event
    self._resize()  # Update figure dimensions if needed
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4002, in _resize
    c_w, c_h = self._canvas.get_width_height()
AttributeError: 'NoneType' object has no attribute 'get_width_height'
WARNING:root:Encountered issue in callback (most recent call last):
  File "/home/adeak/pyvista/pyvista/plotting/renderer.py", line 381, in _render_event
    chart._render_event(*args, **kwargs)
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4027, in _render_event
    self._resize()  # Update figure dimensions if needed
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4002, in _resize
    c_w, c_h = self._canvas.get_width_height()
AttributeError: 'NoneType' object has no attribute 'get_width_height'

and later

/home/adeak/pyvista/pyvista/plotting/charts.py:docstring of pyvista.ChartMPL.legend_visible:18: WARNING: Exception occurred in plotting pyvista-ChartMPL-legend_visible-1
 from /home/adeak/pyvista/doc/api/plotting/charts/_autosummary/pyvista.ChartMPL.legend_visible.rst:
Traceback (most recent call last):
  File "/home/adeak/pyvista/pyvista/ext/plot_directive.py", line 309, in _run_code
    exec(code, ns)
  File "<string>", line 3, in <module>
  File "/home/adeak/pyvista/pyvista/plotting/charts.py", line 4121, in legend_visible
    legend = self._fig.axes[0].get_legend()
AttributeError: 'NoneType' object has no attribute 'axes'

This happens on matplotlib 3.5.0, the newest release is 3.5.1 but this doesn’t seem like what’s caused by a micro version bump.

Report for unambiguity:

--------------------------------------------------------------------------------
  Date: Fri Jan 07 20:12:23 2022 CET

                OS : Linux
            CPU(s) : 8
           Machine : x86_64
      Architecture : 64bit
               RAM : 15.5 GB
       Environment : Python
        GPU Vendor : Intel
      GPU Renderer : Mesa Intel(R) UHD Graphics 620 (WHL GT2)
       GPU Version : 4.6 (Core Profile) Mesa 20.3.5

  Python 3.9.2 (default, Feb 28 2021, 17:03:44)  [GCC 10.2.1 20210110]

           pyvista : 0.34.dev0
               vtk : 9.1.0
             numpy : 1.22.0
           imageio : 2.11.1
           appdirs : 1.4.4
            scooby : 0.5.6
        matplotlib : 3.5.0
           IPython : 7.19.0
          colorcet : 1.0.0
           cmocean : 2.0
        ipyvtklink : 0.2.1
             scipy : 1.7.2
        itkwidgets : 0.32.1
              tqdm : 4.61.1
            meshio : 4.3.5
--------------------------------------------------------------------------------

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
adeakcommented, Jan 7, 2022

@dcbr it’s not that big of a deal because the docs seem to build just fine. But I figured it’s better to hunt this down while it’s fresh 😃

1reaction
dcbrcommented, Jan 17, 2022

So I found this page which shows some information about the DICOM file format and I tried out following code:

import pyvista
from pyvista.examples import downloads

original_file, _ = downloads._download_file('prostate.img')
modified_file = 'P:/projects/tmp_imgs/prostate_modified.img'
with open(modified_file, 'wb') as f_mod, open(original_file, 'rb') as f_orig:
    f_mod.write(b"\x00"*128)    # Empty preamble
    f_mod.write(b"DICM")        # Prefix (DICOM magic number)
    f_mod.write(f_orig.read())  # Original file contents

dataset_orig = pyvista.read(original_file)
dataset_mod = pyvista.read(modified_file)
dataset_orig.plot(cpos="xy", text="original")
dataset_mod.plot(cpos="xy", text="modified")

which seems to work fine (I’ll verify it later). This only prints the warning twice (for the original dataset reading, so the modified dataset loads fine without warnings) and plots the same image for the original and modified dataset (on first sight).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing DICOM images: Tips and tricks for the radiologist
A DICOM image file is an outcome of the Digital Imaging and ... For example, if a radiologist encounters a good-quality MRI image...
Read more >
Sample DICOM Modality Worklist Production
Sample DICOM Modality Worklist Production. Contents. Configuring the DICOM Worklist Business Service; Creating a Business Process Class for a DICOM Worklist ...
Read more >
DICOM Grayscale Standard Display Function
DICOM Grayscale Standard Display Function. David Clunie. I 2. Outline. Inconsistent appearance of images. Why is it a problem ? What are the...
Read more >
DICOM Structured Reporting
DICOM Encoding 40 ... items that are used to construct an SR document. ... In this sense, template definitions are analogous to the...
Read more >
DICOM - 3D Slicer documentation - Read the Docs
Creating a DICOM database is a prerequisite to all DICOM operations. ... For example, you must work out agreement on such topics as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found