itkwidgets
itkwidgets copied to clipboard
Viewing a itk Image works. Viewing a second does not.
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?
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 callitkwidgets.view(img)
followed byitkwidgets.view(img2)
that the problem appears.
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.
The issue persists on windows however. I agree on Ubuntu I do not get this issue.
On linux mint 21.2 (ubuntu 22.04) python==3.8 && itkwidgets == 0.32.6, this issue persists.