Quadratic time creating ImageViews in loop

21 views
Skip to first unread message

Evan Groopman

unread,
Sep 24, 2019, 10:58:23 AM9/24/19
to pyqtgraph
Hi, and thanks for your help.

I've created an image analysis program consisting of a main window with a tabbed interface, where a particular image analysis widget is embedded in each tab. The embedded widgets are generally QMainWindows or QDialogs, which can also run independently (nice for debugging). Upon loading a file containing multiple images, one of the tabs contains a program that creates individual pyqtgraph docks, each containing an ImageView (docks and ImageViews are added in a simple loop). I've noticed some strange behavior, however:

When running the display window standalone, each dock is created in <50ms (on my machine) and in ~the same time. When using this program within the main program, however, the time taken to create each dock and ImageView increases quadratically for each image, from 50ms to 1.5s (over 18 images). All of the dock creation code runs in the same time for each loop, except im = pg.ImageView(). I have a second tab program for creating image ratios, and I observe the same behavior here. After loading, the images are sent via a signal/slot mechanism to the subwindows.

Cheers,
Evan

Evan Groopman

unread,
Sep 24, 2019, 12:47:29 PM9/24/19
to pyqtgraph
Correction: The same behavior happens regardless of whether the display window is run standalone or as part of the main program, the behavior just starts after creating many more ImageViews. This makes me think it is a memory/cache issue, not something specific to ImageView. Any thoughts are welcome, however.

Evan Groopman

unread,
Sep 25, 2019, 1:45:02 PM9/25/19
to pyqtgraph
Update 2:
I rewrote a dock widget containing most of the components of the ImageView (minus normalization and an roi, plus a few other custom bits). Widget creation is now very fast with fairly constant creation time up to more than 30 widgets. Still haven't pinpointed the cause of the issue in pg.ImageView(), but making a bunch of them in a parent widget reproducibly exhibits the O(n^2) time behavior. If anyone is interested, I can post the code for the imageview dock, though, like I said it's basically the same base components that are in the pg.ImageView() class.
Reply all
Reply to author
Forward
0 new messages