# SlicerRadiomics--contour voxel size

**URL:** <https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069>\
**Category:** Support\
**Tags:** radiomics\
**Created:** [December 13, 2018, 2:06pm UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069 "2018-12-13T14:06:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TingtingYu](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TingtingYu](https://discourse.slicer.org/u/TingtingYu)\
**Post date:** [December 13, 2018, 2:06pm UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/1 "2018-12-13T14:06:14Z")

</div>

Hi Slicer Developer,

I am using SlicerRadiomics to extract features. The contour is based on CT image so the voxel size of contour matrix is the same as CT image. However, the voxel size of the Input volume (MRI image) is different from the contour matrix voxel size. So, I am wondering, during the feature calculation, will the contour will be resampled to the same voxel size of input image, and then do the feature calculation? Many thanks.

Best,  
Tingting

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [December 13, 2018, 3:08pm UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/2 "2018-12-13T15:08:37Z")

</div>

You can control this in the settings, see [https://pyradiomics.readthedocs.io/en/latest/customization.html#feature-extractor-level](https://pyradiomics.readthedocs.io/en/latest/customization.html#feature-extractor-level).

You should be able to set resampled voxel size in the module GUI to 0,0,0 to resample input image to the resolution of the mask. Let us know if this does not work.

---

<div class="post-metadata">

**Author:** ![TingtingYu](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TingtingYu](https://discourse.slicer.org/u/TingtingYu)\
**Post date:** [December 14, 2018, 3:44am UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/3 "2018-12-14T03:44:17Z")

</div>

Hi Andrey,

Thank you for your reply. Actually, I want to resample contour to the resolution of input image. Could I do that easily?

Best,  
Tingting

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [December 14, 2018, 4:18am UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/4 "2018-12-14T04:18:46Z")

</div>

Yes, you can specify any resolution to use for resampling in the module interface.

---

<div class="post-metadata">

**Author:** ![TingtingYu](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TingtingYu](https://discourse.slicer.org/u/TingtingYu)\
**Post date:** [December 14, 2018, 9:00am UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/5 "2018-12-14T09:00:48Z")

</div>

Hi Andrey,

Thank you for your quick response. I still have some confusion.

1. In my case, contour, also named segment, is the same as mask. I generated a Labelmap Volume of segment named GTV, the voxel size is the same as CT image, which is 1.17mmx1.17mmx3mm. Then, I resampled this Labelmap Volume to a new Labelmap Volume with voxel size 0.75mmx0.75mmx1mm. However, this resampling method did not give me the right contour. Below is the screenshot, red represents the original contour, blue is the resampled contour, they have different size.

2. Thank you for sharing the link with me, I found a website from the link you shared talked about **Pipeline** of Radiomics, there is a function named “ **radiomics. imageoperations. checkMask** (_imageNode, maskNode, **kwargs** _)”, this function seems to check if the mask contains a valid ROI, which is exactly I want. So, when I choose input image and input region which is segment or mask based on CT image (they have different voxel sizes), two questions pop up. In SlicerRadiomics based on 3D slicer platform, first, will the input regions (mask) be resampled to the voxel size of input image automatically? If the answer is yes for the last question, then, will checkMask function be initialized to correct the mask if the size of resampled mask does not match the original mask automatically?

**P.S** I mention voxel size and size at the same time. To clear the confusion, voxel size is pixel spacing, size means how large it is.

Many thanks.

Best wishes,  
Tingting

 ![PNG](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/9/b9cd0df12f45db21a74e717a1fdb67d07b4a5c97.jpeg)

[https://pyradiomics.readthedocs.io/en/latest/radiomics.html#radiomics.imageoperations.normalizeImage](https://pyradiomics.readthedocs.io/en/latest/radiomics.html#radiomics.imageoperations.normalizeImage)

 ![Check%20Mask](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/6/d6406aaa8b4fb480009968c831eeea29ece7d81a.png)

---

<div class="post-metadata">

**Author:** ![JoostJM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joostjm/32/1091_2.png) [@JoostJM](https://discourse.slicer.org/u/JoostJM)\
**Post date:** [December 14, 2018, 2:17pm UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/6 "2018-12-14T14:17:57Z")

</div>

As you’ve mentioned, PyRadiomics indeed checks if the geometry (i.e. spacing, size and direction) of the mask matches that of the images. By default in PyRadiomics, it throws an error if there is a mismatch.

By setting `correctMask` to `True`, PyRadiomics instead tries to resample the mask to the image geometry, using nearest neighbor interpolation. If correction is needed, a warning is still displayed, but extraction will not fail  
Only constraint here is that the bounding box of the mask has to be contained in the physical space defined by the image. If that is not the case, extraction will still fail.

In SlicerRadiomics, `correctMask` is already switched on by default, as labelmaps in slicer are often represented as a cropped version of the image space (i.e. size mismatch).

As to you result, which functionality did you use?

---

<div class="post-metadata">

**Author:** ![TingtingYu](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TingtingYu](https://discourse.slicer.org/u/TingtingYu)\
**Post date:** [December 16, 2018, 9:08am UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/7 "2018-12-16T09:08:10Z")

</div>

Hi Joost,

Thank you.

I used module named **Resample Scalar Voulme** to do the resampling. I tried three methods, **linear, nearestNeighbor, Bspline** , and below are the results. Red represents the original mask with voxel size 1.17x1.17x3.3mm while blues are the resampled mask with voxel size 0.75x0.75x1mm. Bspline method gives the accurate boundary but some pixels inside the mask were not labeled. Will these pixels be labeled when **correctMask** is switched on?

Best,  
Tingting

linear  
 ![linear](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/2/f21dd8eccbd8ee76e024fda3199790ce809f483e.png)  
Nearest Neighbor  
 ![nearestNei](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f1f09997ebf1894c770f60b7fcabdba01baaa8dc.png)  
Bspline  
 ![bspline](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/6/f6a98083ff72f0630f7beaba0537e7e0b3541e38.png)

---

<div class="post-metadata">

**Author:** ![JoostJM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joostjm/32/1091_2.png) [@JoostJM](https://discourse.slicer.org/u/JoostJM)\
**Post date:** [December 20, 2018, 7:18am UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/8 "2018-12-20T07:18:46Z")

</div>

Hi Tingting,

PyRadiomics uses nearestNeighbor to resample the mask. The interpolator that can be set in the configuration is only used for resampling the image if resampling is enabled.

Best,

Joost

---

<div class="post-metadata">

**Author:** ![TingtingYu](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TingtingYu](https://discourse.slicer.org/u/TingtingYu)\
**Post date:** [December 20, 2018, 7:57am UTC](https://discourse.slicer.org/t/slicerradiomics-contour-voxel-size/5069/9 "2018-12-20T07:57:48Z")

</div>

Hi Joost,

Thank you. Thank you for clearing my confusion.

Best wishes  
Tingting
