Page MenuHomePhabricator

ImageStatistics module should calculate histogram in a background thread
Closed, ResolvedPublic

Description

Currently, the application is not responding for a while when ImageStatistics View is active and an image is selected in the data manager. The lengthy histogram calculation should be done by a background thread / blueberry job to let the user continue working.

At least, a wait cursor should be displayed during computation

(not release critical, but nice to have)

Event Timeline

Michi, as Mathias will not have the time to fix this, I thought you may have a look into it.

If you are too busy as well, maybe you know somebody with the expertise to solve this bug quickly. Has anyone worked with threading recently?

This bug should be closed by next Wednesday if possible!!

i will have a look into after lunch to get an idea of how much work it will be

hmm threading is rather difficult, because the time-consuming ImageStatisticsCalculator::ComputeStatistics() method can depend on an image, mask image, planar figure and so on. executing ComputeStatistics() in a background thread and meanwhile touching these objects in the main thread (what MITK will probably do) may crash the whole thing.
the only idea would be to redesign the ImageStatisticsCalculator and to copy over all values in the setter methods in order to precollect all necessary information for ComputeStatistics(). i will have a look if this make sense at all (this would also mean to copy over the whole image/mask somehow)

i can probably do it in bugsquashing on wednesday. heres the plan for background processing of this task:

  • implement a qt thread class which gets the input image as well as the mask image/planar figure
  • the class will make a depp copy of the image(s) and the planar figure (@Mathias: maybe i need your help here)
  • the class will then instantiate an ImageStatisticsCalculator class and start the calculation
  • when finished the View gets notified by an asynchronous event and will update the GUI

OR if Wednesday is too late: i can simply add a wait cursor ;)

Adding Mathias Seitel to the CC-List

To add the waitCursor should not be too difficult =)

It would be great if you could add the waitCursor right now and have a look at it on Wednesday nonetheless. (if that is ok with your time-management?!?)

ok will invest these hours of work in giving us a wait cursor.

[SVN revision 26053]
ENH (#3104): Showing wait cursor while doing statistics calculation

has been postponed to following release in order to avoid possible bugs that may appear when something as complex as this is deployed without appropriate testing.

Moving all 3M4 bugs back to 3M3 product

adding patch with not yet working solution. the qt thread does not signal when he is finished yet

still a todo, if i cant do it next week, maybe skip it since it is a feature request

Fixed the svn patch.
Current version of the NOT working branch can be found as branch: bug-3104-CalculateHistogramInExtraThread

Good luck...

Resetting all bugs without active assignee flag to "CONFIRMED". Change status to IN_PROGRESS if you are working on it.

Added thread class to image statistics bundle and started to integrate it into the workflow. The thread handles only the statistics calculation of the ImageStatisticsCalculator.

Problems occured with emitting and recieving signals, maybe due to the use of event loops in the ImageStatisticsView.

The threaded update of the image statistics should work now, at least it does on my maschine. Can somebody please check out this branch : bug-3104- ImageStatisticsThreaded ,78a11c4eb5cf7b2c8e981f627384e0e19ef8e6a0 and test it with Linux and Mac OS?

Meanwhile I'll fix the documentation.

It compiles and seems to work properly on my Ubuntu 12.04 system.

There are some issues with the commits which I would like to have cleaned up prior to merging:

  • mitkDataNode.cpp has been touched (leading white-space). please revert
  • QmitkToFUtilView changes are included in this branch, please remove (I don't see the need for the mutex anyway because the CreateQtPartControl method is not meant to be thread-safe)
  • The license header in the new files is wrong. Please use the new ones provided by Caspar.
  • Please use "QMutex" instead of "QMutex*" as member variable type (this way, you cannot forget to delete it, which you actually did).

Release mode is working fine on Mac. However there are some issues in debug mode:

  • Errors when calculation statics for large images (which actually worked with release)
  • Crash when clicking "Close Project" (again this works with release)

I think at least the crash should not occur.

This bug was discovered during testing of 2012-06, updating version. Target milestone is unspecified until general bug review, but feel free to fix it before.

This bug was discovered during testing of 2012-06, updating version. Target milestone is unspecified until general bug review, but feel free to fix it before.

[b2e87c]: Merge branch 'bug-3104-IntegrationThreadedImageStatistics'

Merged commits:

2012-08-01 14:53:43 Sven Mersmann [af509c]
recommit stuff due to merge errors.


2012-07-04 16:23:13 Sven Mersmann [305402]
Fixed issues with timestep controll and changing selection during statistics calculation.


2012-06-27 17:59:30 Sven Mersmann [098c29]
Integration in current master and code cleanup.


2012-06-27 16:14:45 Sven Mersmann [0c440f]
Merge branch 'bug-3104-ImageStatisticsThreaded' into bug-3104-IntegrationThreadedImageStatistics

Conflicts:
Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp
Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui


2012-06-27 15:41:24 Sven Mersmann [e5451c]
revert changes in classes.


2012-06-27 15:36:40 Sven Mersmann [8d633c]
Some code clean up and documentation.


2012-06-07 12:14:43 Sven Mersmann [78a11c]
Threaded update of image statistics calculation

Please check if this bug has been fixed and can be closed for the 2012.09 release.

A GUI interaction is possible while the statistics is computing. Issue is solved. Closing bug.