SimpleITK / SlicerSimpleFilters

A Module for Slicer3D to provide a simple GUI to image filters from the Insight Toolkit.
Other
1 stars 12 forks source link

AbsImageFilter sometimes doesn't work #27

Open dzenanz opened 1 week ago

dzenanz commented 1 week ago

Trying to apply this filter on an image sometimes results in an error. Input pixel type is short. Log for latest nightly:

myFilter = AbsImageFilter()
myFilter.SetDebug(False)
myFilter.SetNumberOfThreads(24)
myFilter.SetNumberOfWorkUnits(0)
Traceback (most recent call last):
  File "C:/Users/Dzenan/AppData/Local/slicer.org/Slicer 5.7.0-2024-10-15/bin/../lib/Slicer-5.7/qt-scripted-modules/SimpleFilters.py", line 435, in thread_doit
    img = sitkFilter.Execute(*inputImages)
TypeError: Execute() missing 1 required positional argument: 'image1'
Error during execution of AbsImageFilter:

Execute() missing 1 required positional argument: 'image1'

The problem mostly occurs on the first try. It also affects Slicer 5.2.1.

lassoan commented 1 week ago

How do you run this filter? Manually, using Simple Filters module GUI? Is it possible that the image is not ready yet (e.g., the result of a CLI module processing which has not completed yet)? Do you experience issues with any other filters?

blowekamp commented 1 week ago

I am suspicious of the value of *inputimages. Perhaps an input is not being selected properly or not "sent" to the module properly when the modules GUI is initialized or something similar.

dzenanz commented 1 week ago

I think that the error occurs if I open Simple Filters before I load an image. If I load the image first, then it is OK. I am not entirely sure of this diagnosis. Attached are the sample image, and screen recording with success and error. testAbs.zip

lassoan commented 1 week ago

Thank you @dzenanz this was very helpful. The problem is due to that an incorrect signal is used for detecting node changes. nodeActivated is only called when the selection in the node combobox modified due to user action. However, when a volume is loaded and an input node is required (there is no "None" option) then that node gets selected automatically (without user interaction, without emitting nodeActivated signal).

The fix is simple: replace nodeActivated by currentNodeChanged everywhere in the file.

@dzenanz it would be great if you could test it and if it works for you then submit a pull request with the change.