# How to actually to convert 3d numpy array of DICOM images into vtkImageData and vtkAlgorithmOutput?

**URL:** https://discourse.vtk.org/t/how-to-actually-to-convert-3d-numpy-array-of-dicom-images-into-vtkimagedata-and-vtkalgorithmoutput/9529
**Category:** Support
**Tags:** python
**Created:** [October 5, 2022, 8:40am UTC](https://discourse.vtk.org/t/how-to-actually-to-convert-3d-numpy-array-of-dicom-images-into-vtkimagedata-and-vtkalgorithmoutput/9529 "2022-10-05T08:40:20Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 5, 2022, 1:35pm UTC](https://discourse.vtk.org/t/how-to-actually-to-convert-3d-numpy-array-of-dicom-images-into-vtkimagedata-and-vtkalgorithmoutput/9529/2 "2022-10-05T13:35:27Z")

</div>

Before getting to your question, note that `vtk.util.numpy_support` has been superseded by the `vtk.numpy_interface` that was developed for Paraview:

```python
from vtk.numpy_interface import dataset_adapter

vtk_array = dataset_adapter.numpyTovtkDataArray(linear_array, "PixelData")

```

This interface requires you to provide a name for the VTK array, and `'PixelData'` is a natural name for DICOM data. The older `vtk.util.numpy_support` is not scheduled for removal from VTK, but it is unlikely to receive any improvements or even basic maintenance in the future.

* * *

For the `SetInputConnection()` issue, you can use `vtkTrivialProducer` to bridge the gap:

```python
self.image_producer = vtkTrivialProducer()
self.image_producer.SetOutput(self.image)

```

then

```python
some_algorithm.SetInputConnection(self.image_producer.GetOutputPort())

```

---

_[View the full topic](https://discourse.vtk.org/t/how-to-actually-to-convert-3d-numpy-array-of-dicom-images-into-vtkimagedata-and-vtkalgorithmoutput/9529)._
