# Numpy bridge with image vectors

**URL:** <https://discourse.itk.org/t/numpy-bridge-with-image-vectors/1422>\
**Category:** Uncategorized\
**Created:** [November 16, 2018, 2:44pm UTC](https://discourse.itk.org/t/numpy-bridge-with-image-vectors/1422 "2018-11-16T14:44:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [November 16, 2018, 2:44pm UTC](https://discourse.itk.org/t/numpy-bridge-with-image-vectors/1422/1 "2018-11-16T14:44:59Z")

</div>

Hi,  
It seems to me that the numpy bridge does not work for “itk::Image\<itk::Vector” types. For example, if I (manually) run the test [test\_NumPyBridge\_itkVectorPixelImage](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Bridge/NumPy/test/itkPyBufferTest.py#L147), the convertedvectorImage is not of the same type as the vectorImage: it’s a scalar image instead of an image of vectors. Is this intended? Maybe PixelType should be redefined in [itkPyBuffer.wrap](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Bridge/NumPy/wrapping/itkPyBuffer.wrap) for vector pixel types?  
Simon

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [November 16, 2018, 3:12pm UTC](https://discourse.itk.org/t/numpy-bridge-with-image-vectors/1422/2 "2018-11-16T15:12:00Z")

</div>

Hi Simon,

Good point. I will take a look.

Thanks,  
Matt

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [November 20, 2018, 10:42am UTC](https://discourse.itk.org/t/numpy-bridge-with-image-vectors/1422/3 "2018-11-20T10:42:20Z")

</div>

@matt.mccormick I have created a [PR](https://github.com/InsightSoftwareConsortium/ITK/pull/209) that attempts to address this issue. Let me know what you think… As a side note, this PR does not address another problem I have observed: error messages thrown in the code, e.g., in [\_GetImageViewFromArray](https://github.com/InsightSoftwareConsortium/ITK/blob/c95b99852a9109a8fc176a06f88b2aa6d442154b/Modules/Bridge/NumPy/include/itkPyBuffer.hxx#L73), are not properly caught by Python. I don’t know how to address this other issue.
