# Exception during execution of SimpleFilter filters

**URL:** <https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442>\
**Category:** Development\
**Created:** [March 27, 2018, 6:59pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442 "2018-03-27T18:59:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricWilson](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ericwilson/32/1513_2.png) [@EricWilson](https://discourse.slicer.org/u/EricWilson)\
**Post date:** [March 27, 2018, 6:59pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/1 "2018-03-27T18:59:49Z")

</div>

I am currently trying to test different filtering methods in the UI which will later be automated through python. I am using a volume of DICOM images and I am getting an error on several different SimpleFilter filters. If i try to filter using the LaplacianImageFilter for example, using the default parameters and using my volume as input, I will get the following exception when running the filter:

Exception thrown in SimpleITK LaplacianImageFilter\_Execute: d:\d\p\slicer-481-package\simpleitk\code\common\include\sitkMemberFunctionFactory.hxx:196:  
sitk::ERROR: Pixel type: 16-bit signed integer is not supported in 3D byclass itk::simple::LaplacianImageFilter

I can’t find much about the error, does anyone know how to fix it?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 27, 2018, 7:11pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/2 "2018-03-27T19:11:25Z")

</div>

You need to cast the input images to a supported pixel type using “Cast Scalar Volume” module.

---

<div class="post-metadata">

**Author:** ![EricWilson](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ericwilson/32/1513_2.png) [@EricWilson](https://discourse.slicer.org/u/EricWilson)\
**Post date:** [March 27, 2018, 8:42pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/3 "2018-03-27T20:42:02Z")

</div>

ok, that seems to have fixed the issue. however, the information on what the supported pixel types are for a given filter aren’t easy to find. I was able to use trial and error for the LaplacianImageFilter and found that it only takes in float and double, and after looking in the header file for the declaration [here](https://itk.org/Doxygen/html/itkLaplacianImageFilter_8h_source.html), I can see that there is a check for floating point here:

```
itkConceptMacro( InputPixelTypeIsFloatingPointCheck,
     ( Concept::IsFloatingPoint< InputPixelType > ) );

```

however, this isn’t listed anywhere else that i can see on the main file, and the input parameter only says that both input and output need to be of the same dimensionality.

thanks for the response.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 27, 2018, 8:53pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/4 "2018-03-27T20:53:24Z")

</div>

> [@EricWilson](#):
>
> that seems to have fixed the issue. however, the information on what the supported pixel types are for a given filter aren’t easy to find

Yes, I sometimes find this difficult, too.

@blowekamp Do you have a suggestion how to address this?

---

<div class="post-metadata">

**Author:** ![blowekamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/blowekamp/32/1386_2.png) [@blowekamp](https://discourse.slicer.org/u/blowekamp)\
**Post date:** [March 28, 2018, 1:14pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/5 "2018-03-28T13:14:44Z")

</div>

> [@lassoan](#):
>
> Yes, I sometimes find this difficult, too.
> 
> @blowekamp Do you have a suggestion how to address this?

For filters which just take one input, it is quite easy to know what is accepted. If you look at the SimpleITK Doxygen e.g. [LaplacianImageFilter](https://itk.org/SimpleITKDoxygen110/html/classitk_1_1simple_1_1LaplacianImageFilter.html), they have a member typedef called [PixelIDTypeList](https://itk.org/SimpleITKDoxygen110/html/classitk_1_1simple_1_1LaplacianImageFilter.html#a9af38cbfce40eafe5015775d1ccfaba8) which is the input pixels types supported by the filter defined by a “typelist”.

For multi-input filters the image types are generally expected to be the same dimension and pixel type. However “Mask” images are expected to be of pixel type uint8\_t. There are a handful of filters which are “dual dispatch”, meaning the support different image types for their inputs. This include the [LabelStatisticsImageFilter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1LabelStatisticsImageFilter.html), [MaskImageFilter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1MaskImageFilter.html), [LabelIntensityStatisticsImageFilter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1LabelIntensityStatisticsImageFilter.html) etc. These conventions are documented [here](https://itk.org/SimpleITKDoxygen/html/ConventionsPage.html).

Determining the output image type is admittedly difficult. It can be dependent on the input image type(s). Even looking at the instantiated ITK filter’s template arguments does not always show the output image type. You need to look at the ImageToImageFilter ancestor of the instantiated ITK type.

Yes this situation should be improved. I am open to suggestions and a discussion on what should be done to improve it. Documentation in the SimpleITK class description? Runtime access?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 28, 2018, 1:25pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/6 "2018-03-28T13:25:43Z")

</div>

Thank you Brad. I think the main pain point is that the error message is `Exception ... Pixel type: 16-bit signed integer is not supported in 3D byclass itk::simple::LaplacianImageFilter` - it does not give a clue about what pixel type is supported.

It should not be too difficult to generate a link to the doxygen page of the filter. This could be useful for other purposes anyway, to learn what is the meaning of different parameters, etc.

However, for me it is not obvious how PixelIDTypeList tells what the accepted input pixel types are.

> typedef RealPixelIDTypeList itk::simple::LaplacianImageFilter::PixelIDTypeList  
> Define the pixels types supported by this filter  
> Definition at line 78 of file sitkLaplacianImageFilter.h.

Is it the `Real` word that indicates that it requires floating-point input?

---

<div class="post-metadata">

**Author:** ![blowekamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/blowekamp/32/1386_2.png) [@blowekamp](https://discourse.slicer.org/u/blowekamp)\
**Post date:** [March 28, 2018, 1:45pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/7 "2018-03-28T13:45:52Z")

</div>

> [@lassoan](#):
>
> Is it the Real word that indicates that it requires floating-point input?

Yes. As is frequent in Doxygen, and C++ conventions there are nested types that need to be clicked through. You can find this definition:

```auto
typedef typelist::MakeTypeList<BasicPixelID<float>, BasicPixelID<double> >::Type itk::simple::RealPixelIDTypeList

```

Although that still may not be clear to many…

So you suggestion is to improve the error message when the image types are not supported. Either by listing what is supported, or linking on where to get more information?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 28, 2018, 1:50pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/8 "2018-03-28T13:50:32Z")

</div>

> [@blowekamp](#):
>
> So you suggestion is to improve the error message when the image types are not supported.

Yes. Since currently it is a bit difficult to decipher pixel type info from doxygen, either doxygen page generation should be tuned or somehow SimpleFilters should figure out what the pixel type is and display that to the user.

---

<div class="post-metadata">

**Author:** ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)\
**Post date:** [December 22, 2019, 9:11pm UTC](https://discourse.slicer.org/t/exception-during-execution-of-simplefilter-filters/2442/9 "2019-12-22T21:11:47Z")

</div>

Is the finding of the input pixel type for the simple-filters been simplified yet or still we need to do trial and error with Cast Scalar volume ?
