# How to create spherical mask for all voxels of an organ

**URL:** <https://discourse.itk.org/t/how-to-create-spherical-mask-for-all-voxels-of-an-organ/4584>\
**Category:** Algorithms\
**Tags:** simpleitk, python\
**Created:** [November 15, 2021, 9:04pm UTC](https://discourse.itk.org/t/how-to-create-spherical-mask-for-all-voxels-of-an-organ/4584 "2021-11-15T21:04:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jithendra\_Kumar\_V](https://discourse.itk.org/user_avatar/discourse.itk.org/jithendra_kumar_v/32/2378_2.png) [@Jithendra\_Kumar\_V](https://discourse.itk.org/u/Jithendra_Kumar_V)\
**Post date:** [November 15, 2021, 9:04pm UTC](https://discourse.itk.org/t/how-to-create-spherical-mask-for-all-voxels-of-an-organ/4584/1 "2021-11-15T21:04:55Z")

</div>

Hi,

I am trying to iterate all the voxels of an organ. For each voxel, need to create a 30 mm spherical mask and get the corresponding standard deviation. Finally pick the voxels with least standard deviation. Please guide me on the classes which can be used for this.

Thanks,  
Jit

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [November 15, 2021, 10:37pm UTC](https://discourse.itk.org/t/how-to-create-spherical-mask-for-all-voxels-of-an-organ/4584/2 "2021-11-15T22:37:49Z")

</div>

This sounds like a job for a [NeighborhoodIterator](https://itk.org/Doxygen/html/NeighborhoodIteratorsPage.html). You could use [ShapedNeighborhoodIterator](https://itk.org/ITKExamples/src/Core/Common/IterateOverARegionWithAShapedNeighborhoodIterator/Documentation.html), and provide sphere as your shape. I suspect that [BinaryBallStructuringElement](https://itk.org/Doxygen/html/classitk_1_1BinaryBallStructuringElement.html) can be used for that purpose.

For picking voxel with lowest deviation you can use [MinimumMaximumImageCalculator](https://itk.org/Doxygen/html/classitk_1_1MinimumMaximumImageCalculator.html) or [NMinimaMaximaImageCalculator](https://github.com/InsightSoftwareConsortium/ITKMontage/blob/master/include/itkNMinimaMaximaImageCalculator.h) from ITKMontage remote module.

Also possibly look at this older [mailing list discussion](https://itk.org/pipermail/community/2015-March/008636.html).
