itk python blocking pyqt gui


I’ve been trying to run itk functions in a separate thread pool, so far printing the current thread from the function shows that it is not being run on the main thread. However, running itk functions on a separate thread still seem to block the GUI of pyqt. For, example, when using a slider to set the min max of the rescale intensity filter, causes the slider to lag (which should not be the case since its not running on the UI thread).

Does anyone have any experience with ITK and PyQt5 and able to give some examples or suggestions?


Python has a global interpreter lock (GIL) so only one thread can be using the python interpreter at a time. Classically, Python does not do well with light weight threading, but frequently parallel is implemented using heavy weight processes for parallelization.

The SimpleITK Python interface has spent the effort to test and support, by default, unlocking the GIL while in ITK code, while still supporting command all backs. You can see a complete Slicer modules which uses this feature here:

While ITK filter are executing the Slicer GUI is updated and maintain interactivity, as well as receiving progress reporting.


1 Like

Ok Thanks ill check it out!