# ITK ERROR: MattesMutualInformationImageToImageMetricv4(000001F33CCCA180): VirtualSampledPointSet must have 1 or more points.

**URL:** <https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611>\
**Category:** Engineering\
**Tags:** registration\
**Created:** [January 5, 2023, 3:16am UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611 "2023-01-05T03:16:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [January 5, 2023, 3:16am UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/1 "2023-01-05T03:16:45Z")

</div>

I want to complete a mask registration and add a mask to the dicom sequence to speed up the registration. I added a mask, but an error occurred in the title. I have checked my mask. There is data both internally and externally. How can I solve this problem

 ![image](https://discourse.itk.org/uploads/default/original/2X/e/eaaa1e515ab07708fe12c2922a7a5c1dd0ab1b8d.png)

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [January 5, 2023, 3:41am UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/2 "2023-01-05T03:41:58Z")

</div>

help me

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [January 5, 2023, 5:53am UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/3 "2023-01-05T05:53:20Z")

</div>

I have no problem using 2d test, but these problems occur once I switch to 3d. Doesn’t itk support 3d mask?

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [January 5, 2023, 8:19am UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/4 "2023-01-05T08:19:59Z")

</div>

when create the mask is consinderate the image spacing?

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [January 5, 2023, 1:49pm UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/5 "2023-01-05T13:49:43Z")

</div>

Hello @ma1282029525,

Not sure if this is the case, but the combination of small\_mask + large\_image + random\_sampling can lead to this situation, see [this long discussion and possible work-arounds](https://discourse.itk.org/t/fixed-mask-not-working-as-expected/1238). It is not about 2D vs. 3D, simply in 3D the chances of this happening are higher.

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [January 6, 2023, 1:33am UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/6 "2023-01-06T01:33:00Z")

</div>

I did use the strategy as you said, my purpose is actually to generate the mask exactly the same as the original image, but I did not find the sample code, so this problem occurs, could you please remind me how to generate the mask of the same size as the original image, and how the mask is aligned with the original image, by real physical coordinates, Or is it aligned by image coordinates?

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [January 6, 2023, 1:42pm UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/7 "2023-01-06T13:42:11Z")

</div>

Hello @ma1282029525,

The mask only needs to be aligned with the original image in physical space. The sampled points are checked for being inside the physical mask, see code [here](https://github.com/InsightSoftwareConsortium/ITK/blob/490b5c6069a790c2bbc50ece3a578fe1c5cdd50b/Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.hxx#L1010) and [here](https://github.com/InsightSoftwareConsortium/ITK/blob/490b5c6069a790c2bbc50ece3a578fe1c5cdd50b/Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.hxx#L1046).

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [January 7, 2023, 2:30am UTC](https://discourse.itk.org/t/itk-error-mattesmutualinformationimagetoimagemetricv4-000001f33ccca180-virtualsampledpointset-must-have-1-or-more-points/5611/8 "2023-01-07T02:30:59Z")

</div>

I got it，thanks very much.it help me a lot.
