View Issue Details

IDProjectCategoryView StatusLast Update
0004065Slicer4Module SimpleFilterspublic2018-03-02 11:06
Reporterllaurenn Assigned Toblowekamp  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product VersionSlicer 4.4.0 
Target VersionSlicer 4.6.0Fixed in VersionSlicer 4.5.0-1 
Summary0004065: Crash when trying to apply simple itk filter after changing some parameters
Description

I implemented IsolatedWatershedImageFilter (simple itk filter in filtering module).
If I change "Threshold" or "Isolated Value Tolerance" parameters and then apply filter, slicer crashes.

TagsNo tags attached.

Relationships

related to 0004104 assignednicole Allow selecting fiducials from a list for CLIs 

Activities

jcfr

jcfr

2015-11-02 13:15

administrator   ~0013502

I was able to reproduce the problem using r24686

blowekamp

blowekamp

2015-11-03 04:22

developer   ~0013520

Last edited: 2015-11-03 06:27

I am trying this on the 4.4.0-2015-10-30 nightly and have not been able to reproduce.

When the filter is executed, there should be python code printed to the console about what is being run. Please include that so that I can easily determine if the problem lies in pure SimpleITK/ITK or if its with the GUI.

Additionally, I noticed that the default Seeds are all zeros, this may be a problem in ITK if they are both the same. An error should be generated for this case. Are you using the default seeds?

jcfr

jcfr

2015-11-03 06:25

administrator   ~0013523

Hi Brad,

The following snippet allow to reproduce the crash:

8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----
import SampleData
sampleDataLogic = SampleData.SampleDataLogic()
head = sampleDataLogic.downloadMRHead()

slicer.util.moduleSelector().selectModule('SimpleFilters')

filterName = 'IsolatedWatershedImageFilter'
filterSelector = slicer.modules.SimpleFiltersWidget.filterSelector
filterSelector.setCurrentIndex(filterSelector.findText(filterName))

slicer.modules.SimpleFiltersWidget.filterParameters.filter.SetThreshold(1)

slicer.modules.SimpleFiltersWidget.applyButton.click()
8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----

Associated output:

myFilter = IsolatedWatershedImageFilter()
myFilter.SetDebug(False)
myFilter.SetIsolatedValueTolerance(0.001)
myFilter.SetNumberOfThreads(8)
myFilter.SetReplaceValue1(1)
myFilter.SetReplaceValue2(2)
myFilter.SetSeed1((0, 0, 0))
myFilter.SetSeed2((0, 0, 0))
myFilter.SetThreshold(1.0)
myFilter.SetUpperValueLimit(1.0)

And as you expected, the seeds are both set to (0, 0, 0)

Side remarks:

Setting value on the filter using:

slicer.modules.SimpleFiltersWidget.filterParameters.filter.SetThreshold(1)

doesn't update the UI.

blowekamp

blowekamp

2015-11-03 06:35

developer   ~0013524

I have note confirmed this is a problem in pure SimpleITK and likely in ITK. I will implement a check to the error condition in ITK.

Will also look into the GUI update issue. Thank you for the Slicer code to do use the GUI; I should integrate some of that into a test.

blowekamp

blowekamp

2015-11-03 12:15

developer   ~0013535

Here is the commit to resolve the segmentation fault in ITK:http://review.source.kitware.com/#/c/20348/1

The cause is that the Threshold and the UpperValueLimit produced and empty range (1,1). From the ITK Doxygen: The user supplies a Watershed threshold. The algorithm uses a binary search to adjust the upper waterlevel, starting at UpperValueLimit. UpperValueLimit defaults to the 1.0.

Unfortunately the Simple Filters modules doesn't know about the tight interaction between parameters and what a good step size should be; this module is a little simplistic in this regards.

jcfr

jcfr

2015-11-03 12:47

administrator   ~0013536

Hi Brad,

Thanks for the patch. I cherry-picked [1], then rebuild ITK, SimpleITK and Slicer. But there are still a seg fault. I attached the backtrace to the issue.

2015-11-03 12:47

 

blowekamp

blowekamp

2015-11-04 05:14

developer   ~0013554

With the proposed ITK patch the following SimpleITK code now runs:

In [1]: import SimpleITK as sitk

In [2]: img = sitk.Image(512,512,sitk.sitkFloat32)

In [3]: myFilter = sitk.IsolatedWatershedImageFilter()

In [4]: myFilter.SetDebug(False)

In [5]: myFilter.SetIsolatedValueTolerance(0.001)
Out[5]: <SimpleITK.IsolatedWatershedImageFilter; proxy of <Swig Object of type 'itk::simple::IsolatedWatershedImageFilter::Self *' at 0x2aa5090> >

In [6]: myFilter.SetNumberOfThreads(8)

In [7]: myFilter.SetReplaceValue1(1)
Out[7]: <SimpleITK.IsolatedWatershedImageFilter; proxy of <Swig Object of type 'itk::simple::IsolatedWatershedImageFilter::Self *' at 0x2aa1e40> >

In [8]: myFilter.SetReplaceValue2(2)
Out[8]: <SimpleITK.IsolatedWatershedImageFilter; proxy of <Swig Object of type 'itk::simple::IsolatedWatershedImageFilter::Self *' at 0x2aa1db0> >

In [9]: myFilter.SetSeed1((0, 0, 0))
Out[9]: <SimpleITK.IsolatedWatershedImageFilter; proxy of <Swig Object of type 'itk::simple::IsolatedWatershedImageFilter::Self *' at 0x2aa1d20> >

In [10]: myFilter.SetSeed2((0, 0, 0))
Out[10]: <SimpleITK.IsolatedWatershedImageFilter; proxy of <Swig Object of type 'itk::simple::IsolatedWatershedImageFilter::Self *' at 0x2aa1e70> >

In [11]: myFilter.SetThreshold(1.0)
Out[11]: <SimpleITK.IsolatedWatershedImageFilter; proxy of <Swig Object of type 'itk::simple::IsolatedWatershedImageFilter::Self *' at 0x2aa1ae0> >

In [12]: myFilter.SetUpperValueLimit(1.0)
Out[12]: <SimpleITK.IsolatedWatershedImageFilter; proxy of <Swig Object of type 'itk::simple::IsolatedWatershedImageFilter::Self *' at 0x2aa19c0> >

In [13]: myFilter.Execute(img)

blowekamp

blowekamp

2015-11-04 06:42

developer   ~0013555

Opps, test is still failing I had uncommitted changes effect the filter.

jcfr

jcfr

2015-11-09 16:34

administrator   ~0013578

Last edited: 2015-11-09 16:40

Fixed in r24715 after backporting InsightSoftwareConsortium/ITK@abda78c

Change-Id: I607a8fbbc49279f394fd14c241e4ef32c62a1820

See http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&amp;revision=24715

Thanks Brad. It doesn't crash any more.

Here is what I tried:

(a) Select MRHead + leave all parameter to the default, click Apply. It seems to be Running fever. Clicking on Cancel go into Aborting mode. But it never finishes.

(b) Select MRHead, threshold of 1, both seeds to 0,0,0. After 1 sec .. it fails with:

 Exception thrown in SimpleITK IsolatedWatershedImageFilter_Execute: /home/jcfr/Projects/Slicer-Debug/ITKv4/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx:437:

itk::ERROR: itk::watershed::SegmentTreeGenerator::MergeSegments:: An unexpected and fatal error has occurred. This is probably the result of overthresholding of the input image

(c) Select MRHead, threshold at 0, one value of one seed at 5000. Click Apply. It fails immediately with:

Exception thrown in SimpleITK IsolatedWatershedImageFilter_Execute: /home/jcfr/Projects/Slicer-Debug/ITKv4/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx:119:
itk::ERROR: IsolatedWatershedImageFilter(0x7fcd7c002110): Seed2 is not within the input image!

Possible tweaks:

(1) A possible improvement could be to detect if seeds are very close within an epsilon and error out faster. Currently, it takes 1 or 2 seconds before reporting that .

(2) The exception are not logged. It would probably make sense to also use "logging.error()" when an exception is intercepted.

See http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/Style_Guide#Logging

(3) The two list of fiducial should be exclusive. I initially created one. Added two fiducials .. since they were in the same list ("F"), it ran the watershed with two seeds at the same location. Or may be the interface should detect that the same list has been selected and it it is the case ... take the first two value of the list.

jcfr

jcfr

2015-11-09 16:39

administrator   ~0013579

For reference: I created an "issue" to keep track of possible tweaks.
See https://github.com/SimpleITK/SlicerSimpleFilters/issues/3

Related Changesets

Import 2017-06-07 23:51:09: master 0374ab49

2015-11-09 20:25:00

jcfr

Details Diff
BUG: Update ITK to fix segmentation fault in 2 filters. Fixes 0004065

This commit integrates fixes backported from the ITK release branch:

$ git shortlog 0f346bf7..8989fda --no-merges
Bradley Lowekamp (1):
BUG: Fix segfault when with empty IsolatedWatershed Threshold range

Mikhail Isakov (1):
BUG: DiffusionTensor3DReconstruction segfault if no baseline image


Tested-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@24715 3bd1e089-480b-0410-8dfb-8563597acbee
mod - SuperBuild/External_ITKv4.cmake Diff File

Issue History

Date Modified Username Field Change
2015-10-15 06:39 llaurenn New Issue
2015-10-15 06:39 llaurenn Status new => assigned
2015-10-15 06:39 llaurenn Assigned To => millerjv
2015-11-02 13:12 jcfr Assigned To millerjv => blowekamp
2015-11-02 13:14 jcfr Category Core: Command Line Modules (Modules/CLI) => Module SimpleFilters
2015-11-02 13:14 jcfr Target Version => Slicer 4.5.1
2015-11-02 13:15 jcfr Note Added: 0013502
2015-11-03 04:22 blowekamp Note Added: 0013520
2015-11-03 06:25 jcfr Note Added: 0013523
2015-11-03 06:27 blowekamp Note Edited: 0013520
2015-11-03 06:35 blowekamp Note Added: 0013524
2015-11-03 12:15 blowekamp Note Added: 0013535
2015-11-03 12:47 jcfr Note Added: 0013536
2015-11-03 12:47 jcfr File Added: 4065-remaining-issue-with-ITK-patch-20348-1.png
2015-11-04 05:14 blowekamp Note Added: 0013554
2015-11-04 06:42 blowekamp Note Added: 0013555
2015-11-09 16:34 jcfr Note Added: 0013578
2015-11-09 16:34 jcfr Status assigned => resolved
2015-11-09 16:34 jcfr Fixed in Version => Slicer 4.5.0-1
2015-11-09 16:34 jcfr Resolution open => fixed
2015-11-09 16:39 jcfr Note Added: 0013579
2015-11-09 16:40 jcfr Note Edited: 0013578
2015-12-10 11:54 nicole Relationship added related to 0004104
2016-10-13 01:28 jcfr Target Version Slicer 4.5.1 => Slicer 4.6.0
2017-06-10 08:51 jcfr Changeset attached => Slicer master 0374ab49
2018-03-02 11:06 jcfr Status resolved => closed