Page MenuHomePhabricator

Enhance mitkImageStatisticsCalculator with hotspot search
Closed, ResolvedPublic

Description

Enhance mitkImageStatisticsCalculator with hotspot search:

  • enable possibility to search in a specified area for the hottest spot
    • the hottest spot is defined as a sphere
      • radius can be defined
    • the hottest spot is the spot where the mean value within the sphere is max
  • following values will be calculated:
    • HotspotMean
    • HotspotMax
    • HotspotMin
    • HotspotMaxIndex
    • HotspotMinIndex

The hotspot search can for example be used to search for the SUVpeak value within a given ROI/VOI.

Event Timeline

New remote branch pushed: bug-16236-hotspot-statistics-testing

New remote branch pushed: bug-16236-statistics-calculator

I just created a skeleton for the test cases in branch bug-16236-hotspot-statistics-testing.

The code for the actual statistics was rebased onto a good branching point. The new branch is called bug-16236-statistics-calculator

New remote branch pushed: bug-16236-statistics-testing

New remote branch pushed: bug-16236-review-dm

New remote branch pushed: bug-16236-statistics-calculator-ctd

The mitkImageStatisticsCalculator has now the ability to calculate statistics in a region with the largest appearance of intensities named hotspot.
To find the hottest spot in an image we need to calculate the average value at each position. This is done by the itkFFTConvolutionImageFilter which gets as input an image and a supersampled spherical kernel image. The kernel image
contains non-integer-values which reflects the volume part that is contained in the sphere (by calling GenerateHotspotSearchConvolutionKernel()).
To find the location of the hotspot we call CalculateExtremaWorld() which returns the maximum value and corresponding index in theoutput-image of the convolution-filter.
Next step is to generate a spherical mask which is needed to calculate the statistics in the hotspot. First of all we have to determine the size of the mask (depending on the radius) and filling then the voxels by calling FillHotspotMaskPixels().
At least a second instance of ImageStatisticsCalculator is used to compute the common statistics in the hotspot.

To verify the correctness of hotspot-calculation a special class was created (mitkImageStatisticsHotspotTest). It generates images with known hotspot and statistics. The test checks if ImageStatisticsCalculator is able to compute these statistics, too. In favour of that a number of unit-tests were created.

It is possible to calculate hotspot statistics of masked or non-masked images. Even multilabel-masks are supported.
Hotspot-calculation is optional and set to off by default. It is also optional if the whole hotspot has to be located completely inside the image.

Until now it is not possible to calculate hotspot statistics in 2D images.

New remote branch pushed: bug-16236-hotspot-search-imagestatisticscalculator

New remote branch pushed: bug-16236-hotspot-search-imagestatisticscalculator-integration-snapshot

User maleike has pushed new remote branch:

bug-16236-hotspot-search-testdefinition

Taking over Ticket. There are still some problems:

  • If the input mask image is smaller than the input image then the hotspot calculation crashes
    • Problem: the convolution image has the size of the original input image and the mask has the size of the adapted image (= input image resized to size of input mask image) and an iterator for the mask image was initialized with the region of the convolution image.
  • The calculation of the statistics of the found hotspot throws exception: "Requested region is (at least partially) outside the largest possible region"
    • Problem: The used itk::ImageExtractImageFilter adapts the region of the input image so that the the index values correspond to the index values of the mask image (only if the mask image is smaller than the input image), but the origin is not modified. The origin of the mask image was modified using the itk::ChangeInformationImageFilter so that the origin is the same as the origin of the input image. This is done so that the index values are the same for input image and mask image. This makes it easier to iterate over both. When converting the itk::Image to an mitk::Image in line 1746ff the start index of the region is reseted to the origin of the mask image which actually is outside of the largest possible region.

(In reply to Danial Saruji from comment #11)

Taking over Ticket. There are still some problems:

  • If the input mask image is smaller than the input image then the hotspot

calculation crashes

  • Problem: the convolution image has the size of the original input image

and the mask has the size of the adapted image (= input image resized to
size of input mask image) and an iterator for the mask image was initialized
with the region of the convolution image.

  • The calculation of the statistics of the found hotspot throws exception:

"Requested region is (at least partially) outside the largest possible
region"

Fixed by using the correct region of the mask.

  • Problem: The used itk::ImageExtractImageFilter adapts the region of the

input image so that the the index values correspond to the index values of
the mask image (only if the mask image is smaller than the input image), but
the origin is not modified. The origin of the mask image was modified using
the itk::ChangeInformationImageFilter so that the origin is the same as the
origin of the input image. This is done so that the index values are the
same for input image and mask image. This makes it easier to iterate over
both. When converting the itk::Image to an mitk::Image in line 1746ff the
start index of the region is reseted to the origin of the mask image which
actually is outside of the largest possible region.

Haven't found a solution yet. For now I commented out the code for the statistic calculation of the hotpot area.

User dsaruji has pushed new remote branch:

bug-16236-hotspot-search-bugfixes

I just fixed the issues noted by Danial. The tests are also passing now.

The fix required two things:

  • recognizing that min/max INDEX are not unique. Probably they are not included in the itk::LabeledImageStatisticsFilter. If we would(!) need this information, we should change its type to a set of positions or similar. ==> I removed the calculation of such indexes from the code
  • without these index positions, I could much simplify the statistics code by utilizing a simple itk::LabeledImageStatisticsFilter

Latest version of the code is now in branch

bug-16236-hotspot-search-bugfixes

and integrated into releases/snapshot-201308-v2.

Integration to master could require some changes and is still an open task.

User maleike has pushed new remote branch:

bug-16236-fix-types

User maleike has pushed new remote branch:

bug-16236-fix-types-wo-testdata

Current release is finished. Resetting target milestone

User dsaruji has pushed new remote branch:

bug-16236-final-version-for-master

It took a while to get an overview here. 3 or 4 different developers worked on this topic and multiple branches were pushed, also some of those are not included and not needed. (definitely NOT a good way!)

Here the branches which are not needed:
origin/bug-16236-statistics-calculator
origin/bug-16236-statistics-calculator-ctd
origin/bug-16236-statistics-testing
origin/personal/dsaruji/hotspot-rsna-fix-on-lokal-daniel-bug-16236-rsna

I created a final branch where based on the current master branch: bug-16236-final-version-for-master

This branch includes following branches:
origin/bug-16236-fix-types-wo-testdata
origin/bug-16236-fix-types
origin/bug-16236-hotspot-search-bugfixes
origin/bug-16236-hotspot-search-imagestatisticscalculator-integration-snapshot
origin/bug-16236-hotspot-search-imagestatisticscalculator
origin/bug-16236-hotspot-search-testdefinition
origin/bug-16236-hotspot-statistics-testing
origin/bug-16236-review-dm
snapshot/bug-16236-hotspot-search-imagestatisticscalculator

The main changes made are described in comment 7.

The final branch (bug-16236-final-version-for-master) still needs to be integrated in master.

OK, I will integrate this now..

[508875]: Merge branch 'bug-16236-final-version-for-master'

Merged commits:

2014-09-30 15:17:00 Markus Engel [2f8ccf]
fixed compile errors


2014-09-30 14:58:53 Markus Engel [3278cc]
Merge remote-tracking branch 'origin/master' into bug-16236-final-version-for-master


2014-09-02 17:03:40 Danial Saruji [26601f]
fix warnings


2014-09-02 17:03:02 Danial Saruji [2bd18e]
added missing dependencies


2014-09-02 14:32:15 Danial Saruji [360e96]
added missing include


2014-09-02 11:52:47 Danial Saruji [f771ce]
Merge branch 'bug-16236-fix-types-wo-testdata'

Conflicts:
Modules/ImageStatistics/Testing/CMakeLists.txt
Modules/ImageStatistics/Testing/mitkImageStatisticsCalculatorTest.cpp
Modules/ImageStatistics/mitkImageStatisticsCalculator.cpp
Modules/ImageStatistics/mitkImageStatisticsCalculator.h
Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsCalculationThread.cpp
Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp
Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui


2014-02-28 15:45:26 Danial Saruji [9094a2]
round when converting from double to int


2014-02-27 15:35:01 Danial Saruji [2ab5b2]
Check for negative variance from itk statistics filter


2014-02-26 10:18:58 Daniel Maleike [aaf25f]
Adapt tolerance to maximum seen in tests


2014-02-26 10:17:21 Daniel Maleike [58044f]
Comment on required cleanup


2014-02-26 10:00:15 Daniel Maleike [849d4f]
Fix handling of parameter types (still messy)


2014-02-25 15:24:05 Danial Saruji [6e5273]
removed obsolete todo


2014-02-21 11:31:47 Daniel Maleike [1ab37a]
Fix warnings


2014-02-21 11:31:30 Daniel Maleike [acdd20]
Fix calculation of statistics within hotspot region


2014-02-20 17:23:30 Daniel Maleike [c65571]
Fix test expectations, fail on exceptions

  • Remove min/max index comparisons, they do not make sense
  • FAIL on exceptions, don't just hide them!

2014-02-14 12:08:58 Danial Saruji [1002bb]
removed convolution image member

The convolution image was calculated for the whole image every time. This seems to
be very time consuming. If a mask is given we do not need to calculate the convolution
for the whole image


2014-02-13 16:08:28 Danial Saruji [f8d15a]
commented out not funtioning code for hotspot statistics calculation


2014-02-13 16:07:38 Danial Saruji [39e168]
mask Image has not the same region as the given convolution image


2014-02-11 17:08:50 Danial Saruji [53ce74]
fabs method takes double as input


2014-02-10 18:17:18 Daniel Maleike [24b717]
Fix syntax of testcase definition


2014-02-10 18:04:57 Daniel Maleike [763b46]
Rename variables, change formatting


2014-02-10 18:03:40 Daniel Maleike [714ac5]
Fix calculation of min/max index


2014-02-10 18:01:56 Daniel Maleike [a134e1]
Fix mask handling


2014-02-10 18:01:36 Daniel Maleike [f05e7e]
Fix position verification


2014-02-10 18:01:05 Daniel Maleike [cbbbee]
Update test cases


2014-02-10 10:26:51 Daniel Maleike [2da145]
Update to more clear test cases


2014-02-07 14:28:41 Daniel Maleike [6ddded]
Fix test definition


2014-02-07 14:09:26 Daniel Maleike [82b567]
Generate test cases via CMake


2014-02-07 14:09:16 Daniel Maleike [bc1d42]
Fix documentation in details


2014-02-07 14:09:01 Daniel Maleike [d58fda]
Improve test structure and output a bit


2014-01-28 16:38:50 Andreas Graf [1a0f2c]
New XML-files for hotspot-test


2014-01-28 09:17:16 Danial Saruji [a5455f]
fix compile errors on linux


2014-01-27 15:17:33 Danial Saruji [4402e1]
Merge remote-tracking branch 'origin/bug-16396-gaussian-image-generator-for-hotspots' into bug-16236-hotspot-search-imagestatisticscalculator


2014-01-27 09:15:14 Andreas Graf [4bbef6]
Changed value of epsilon


2014-01-24 09:33:14 Andreas Graf [0a9efd]
Did some changes in the documentation


2014-01-17 15:45:31 Andreas Graf [161a0a]
Fixed bugs in Hotspot-Test and convolution-kernel-calculation, added
variance again


2013-12-17 15:27:12 Andreas Graf [f40a6b]
Added another comment


2013-12-17 15:17:16 Andreas Graf [df5916]
Edited documentation, added comments and a new version of hotspotcase5-image


2013-12-16 16:33:20 Andreas Graf [9b3dcf]
Added images for documentation


2013-12-16 14:51:56 Andreas Graf [6f2e8e]
Multi-label statistic-calculation is now supported in hotspot-test


2013-12-16 14:41:16 Andreas Graf [7c0c4c]
Added case that it is optional if hotspot is completly inside image or not
and added documentation.


2013-12-06 16:50:01 Daniel Maleike [876842]
Mark locations for addition of "m_HotspotMustBeCompletelyInsideImage"


2013-12-06 15:51:49 Andreas Graf [532210]
Added operator=() overload and copy constructor for Statistics


2013-12-04 13:15:11 Daniel Maleike [6e1f94]
Simplify case of unmasked hotspot calculation


2013-12-04 13:14:05 Daniel Maleike [b5c544]
Mark TODOs for further Statistics class work


2013-12-04 11:22:22 Daniel Maleike [44c80a]
Calculate mask correctly at image borders (shrink if outside image)


2013-12-04 11:21:49 Daniel Maleike [8f97a4]
Add TODOs for 2D case ; decide for distance calculation


2013-12-04 11:20:37 Daniel Maleike [6f9f19]
Mark TODOs for calculating statistics per-label


2013-12-03 13:58:24 Andreas Graf [cc0e40]
Added use of get-functions in statisticsview


2013-12-03 11:41:27 Andreas Graf [18093e]
Struct Statistics is now a class with get- and set-functions


2013-12-02 11:06:36 Andreas Graf [8b7f22]
removed redundant code in hotspot test, statisticscalculator does now
return additional statistic-values of hotspot


2013-11-28 17:59:57 Daniel Maleike [3277d7]
Calculate hotspot position


2013-11-28 16:01:09 Daniel Maleike [bd658f]
Update convolution image only when input has changed


2013-11-28 13:45:15 Daniel Maleike [4130ac]
Add flags for modified input radius


2013-11-28 12:00:28 Daniel Maleike [ac27d3]
Change Statistics members (HotspotPeakIndex->HotspotIndex)


2014-01-22 09:57:12 Ekaterina Kovacheva [c65e58]
set the values for the normal distribution vector


2014-01-21 15:45:52 Ekaterina Kovacheva [21aa6f]
maen value in each voxel instead of a value at a point


2014-01-17 14:51:20 Ekaterina Kovacheva [c22421]
clear uncalled methods


2014-01-15 17:32:39 Ekaterina Kovacheva [55f96f]
commented; adjusted spacing; labels for ROIs added


2014-01-13 17:17:33 Ekaterina Kovacheva [fdddc2]
cut the sphere approximation when it crosses the image boundary


2014-01-10 17:26:12 Ekaterina Kovacheva [985567]
fix of recursion; allow new parameter "entireHotSpotInImage"


2013-12-17 17:37:13 Ekaterina Kovacheva [13fe07]
Added cuboid based subdivision of the sphere for analytical integration


2013-11-27 17:22:42 Andreas Graf [28edbd]

  • added member-initialization in constructor
  • fixed bug in convolutionMask-calculation
  • segmentation-mask is considered now

2013-11-26 16:35:02 Ekaterina Kovacheva [693af1]
Documentation added; use ITK instead of C++ iterators instead

Also: definition of ROI change (use ITK ImageRegion)


2013-11-26 16:34:11 Daniel Maleike [49b6d3]
More review comments

Also factored out method for convolution kernel generation


2013-11-26 12:55:17 Daniel Maleike [64efd2]
Review notes (not yet complete)


2013-11-25 16:12:59 Andreas Graf [168925]

  • Fixed bug in convolutionMask-calculation and sphereMask
  • Deleted boundaries in CalculateMinMaxIndex()
  • IsSphereInside()-function is unnecessary as well, so I deleted it

2013-11-25 14:12:54 Andreas Graf [68a49f]
Revert "- Modified CalculateMinMaxIndex(), boundaries are not required anymore (as"

This reverts commit 9e082c6b2a5f5b9b01f8ab1b16b766e725019426.


2013-11-22 17:23:59 Andreas Graf [9e082c]

  • Modified CalculateMinMaxIndex(), boundaries are not required anymore (as (well as IsSphereInsideRegion() )
  • Fixed bug in calculation of convolution mask

2013-11-20 14:05:14 Andreas Graf [76ec89]

  • Added new way to check if sphere is inside the given region, IsSphereInsideRegion()-function is unnecessary now
  • Modified MinMaxIndex-struct: delected index-lists and added index-vectors instead
  • Modified CalculateMinMaxIndex
  • Added new xml-files
  • new XML-tag in HotspotTest: "spacingX", "spacingY", "spacingZ"

2013-11-18 13:19:28 Andreas Graf [3abc0b]

  • Renamed get/set-functions of hotspotRadius
  • Deleted insignificant code
  • Added documentation
  • Added XML-files for hotspot test

2013-11-15 17:06:09 Andreas Graf [800423]
Documentation


2013-11-15 12:07:39 Andreas Graf [452a9f]

  • Added some comments in StatisticsCalculator and cleaned up the code
  • Added timer in HotspotTest
  • Added testCase-XML-File

2013-11-14 16:34:28 Andreas Graf [cffc91]

  • The hotspot test is now able to read parameters from an xml-file and

create an image out of them. The test also calculates the hotspot statistics
of the image and compares the calculated statistics with the statistics of
the xml-file.

  • The ImageStatisticsCalculator does now check if the hotspotSphere is in

the image correctly.


2013-11-14 16:00:22 Ekaterina Kovacheva [2846f6]
Min/max calculation added; documentation extended


2013-11-12 11:08:11 Andreas Graf [219824]
Merge branch 'bug-16396-gaussian-image-generator-for-hotspots' into bug-16236-statistics-testing


2013-11-12 11:03:03 Andreas Graf [9f5fad]
Merge branch 'bug-16236-statistics-calculator' into bug-16236-statistics-testing


2013-11-12 10:58:28 Andreas Graf [719a92]
Updated CalculateMinMax-function


2013-11-11 17:05:47 Ekaterina Kovacheva [960f1d]
Documentation


2013-11-08 16:00:48 Ekaterina Kovacheva [0a1d99]
First working version of ITK based multi gaussian generator


2013-10-25 17:30:37 Andreas Graf [b353bf]

  • Function caluclates if sphere is in region
  • WIP: List of peakValues

2013-10-17 15:59:12 Andreas Graf [5e24b6]
temp


2013-10-16 17:03:29 Andreas Graf [4493f5]
Finished ComputeHotspotStatistics-implementation -> ready for testing


2013-10-11 17:11:29 Andreas Graf [62f6aa]

  • Created Test in mitkImageStatisticsCalculatorTest, but will find a better way
  • CalculateHotspotStatistics() works with TestImage, have to test it with SUVpeak-Images

2013-10-04 15:57:14 Andreas Graf [a60c8e]
Created ConvolutionMask in CalculateHotspotStatistics()


2013-10-02 16:39:28 Andreas Graf [e28111]
Created ConvolutionMask in ComputeHotspotStatistics()


2013-10-02 11:23:46 Andreas Graf [dc5cb4]
CalculateMinMaxIndex() calculates right values
Results are shown in StatisticsTable


2013-09-27 15:23:31 Andreas Graf [c02e34]
Calculation of min, max and index-values


2013-09-26 10:00:00 Andreas Graf [a4a16f]
Added function CalculateMinMaxIndex()


2013-09-24 16:21:13 Andreas Graf [d9de0a]
Added Hotspot-Attributes to struct Statistics


2013-10-28 15:50:28 Andreas Graf [dfbe89]
Getter and setter for hotspot calculation


2013-09-20 15:30:44 Andreas Graf [e6270b]
WIP: add hotspot mean to statistics view


2013-11-11 16:25:59 Daniel Maleike [27ddb0]
Test skeleton for hotspot tests


2013-10-30 15:52:11 Stefan Kislinskiy [32d295]
Calculation of statistics for 2D image with planar figure as mask works.

[47395c]: COMP: Merge branch 'bug-16236-final-version-for-master'

Merged commits:

2014-10-07 17:37:09 Markus Engel [60eef7]
using int instead of unsigned int in HotSpotTest


2014-10-07 17:36:13 Markus Engel [106984]
using getter instead of trying to access private member

[33cd2c]: COMP: Merge branch 'bug-16236-final-version-for-master'

Merged commits:

2014-10-07 17:54:24 Markus Engel [115647]
trying to get rid of warning with signed/unsigned comparison

[71be84]: COMP: Merge branch 'bug-16236-final-version-for-master'

Merged commits:

2014-10-07 17:59:35 Markus Engel [ff4f47]
fixed another singed/unsigned comparison warning/error

[8b6e8e]: Merge branch 'bug-16236-final-version-for-master'

Merged commits:

2014-10-07 18:44:55 Marco Nolden [5be2d1]
COMP: Mac compile fix


2014-10-07 18:36:52 Marco Nolden [3086dc]
COMP: removed a parentheses warning

[8210eb]: Merge branch 'bug-16236-final-version-for-master'

Merged commits:

2014-10-07 19:08:22 Marco Nolden [311fca]
COMP: deactivated non-existing test


2014-10-07 18:44:55 Marco Nolden [42ed9f]
COMP: Mac compile fix


2014-10-07 18:36:52 Marco Nolden [9f25c5]
COMP: removed a parentheses warning

Ticket will be closed due to inactivity. Nothing is being done here anymore