itkwidgets icon indicating copy to clipboard operation
itkwidgets copied to clipboard

Viewing a itk Image works. Viewing a second does not.

Open marcmorcos opened this issue 2 years ago • 4 comments

Error: RuntimeError: C:\P\IPP\ITK-source\ITK\Modules\Core\Common\src\itkDataObject.cxx:355: Requested region is (at least partially) outside the largest possible region.

Steps to reproduce. 1- Import CT series (3D itk image) 2- itkwidgets.view(img) # Works fine 3- resample img to imgResampled (different spacing and size) 4- itkwidgets.view(imgResampled) # gives the above error

sitk.version = 2.1.1 itkwidgets.version = 0.32.1 python = 3.9.5

This is an issue on Windows 10. On a similar build on Ubuntu 18.04, I don't get this issue.

Also as a side question, is there a way to clear or close the viewer when done in jupyter to free up memory?

marcmorcos avatar Apr 20 '22 12:04 marcmorcos

I'm seeing this same issue on Ubuntu 20.04 using SimpleITK version 2.1.1.2 and itkwidgets version 0.32.1. I've started trying to work through the code to find the problems, and the only thing I've been able to come up with is some cached global reference. Whatever is causing the problem, though, is deep in the internals and is not intuitively obvious.

Miscellaneous observations:

  • Even deleting (del) the viewer instance and reloading the package doesn't allow for loading more than single volume. After one viewer instance has been initialized, the only thing I've found to have multiple viewer instances (that don't reference the same SimpleITK volume) in a single notebook is to restart the kernel.
  • Multiple viewer instances that reference the same SimpleITK.Image instance, even if they include additional objects such as meshes, points or labelmaps, work just fine. It's only when trying to call itkwidgets.view(img) followed by itkwidgets.view(img2) that the problem appears.

robertsoakes avatar Apr 27 '22 23:04 robertsoakes

On a lark, I checked out current master branch to do some experimentation; and I'm happy to report that the issue appears to be fixed.

robertsoakes avatar Apr 28 '22 01:04 robertsoakes

The issue persists on windows however. I agree on Ubuntu I do not get this issue.

marcmorcos avatar Apr 28 '22 15:04 marcmorcos

On linux mint 21.2 (ubuntu 22.04) python==3.8 && itkwidgets == 0.32.6, this issue persists.

turtleizzy avatar Sep 04 '23 09:09 turtleizzy