Skip to content

Commit

Permalink
Use numpy2vtkImage in CILViewer2D to replace deprecated numpy2vtkImpo…
Browse files Browse the repository at this point in the history
…rter (#346)

* use numpy2vtkImage

closes #244

* Update CHANGELOG.md

---------

Co-authored-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
  • Loading branch information
paskino and lauramurgatroyd authored Jul 28, 2023
1 parent b6b0eb4 commit f40e71d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## vx.x.x
- Fix bug with setInputAsNumpy() using deprecated `numpy2vtkImporter` in `CILViewer2D` - now uses `numpy2vtkImage`

## v23.1.0
- Raise error if try to add multiple widgets with the same name to CILViewer or CILViewer2D.
- Adds the following base classes to `ui.main_windows.py`:
Expand Down
9 changes: 4 additions & 5 deletions Wrappers/Python/ccpi/viewer/CILViewer2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,13 +1171,12 @@ def setInputAsNumpy(self,
dtype=vtk.VTK_UNSIGNED_SHORT):
self.rescale[0] = rescale

importer = Converter.numpy2vtkImporter(numpyarray, spacing, origin)
importer.Update()
img = Converter.numpy2vtkImage(numpyarray, spacing, origin)

if rescale:
# rescale to appropriate VTK_UNSIGNED_SHORT
stats = vtk.vtkImageAccumulate()
stats.SetInputData(importer.GetOutput())
stats.SetInputData(img)
stats.Update()
iMin = stats.GetMin()[0]
iMax = stats.GetMax()[0]
Expand All @@ -1191,14 +1190,14 @@ def setInputAsNumpy(self,

self.rescale[1] = (scale, -iMin)
shiftScaler = vtk.vtkImageShiftScale()
shiftScaler.SetInputData(importer.GetOutput())
shiftScaler.SetInputData(img)
shiftScaler.SetScale(scale)
shiftScaler.SetShift(-iMin)
shiftScaler.SetOutputScalarType(dtype)
shiftScaler.Update()
self.img3D = shiftScaler.GetOutput()
else:
self.img3D = importer.GetOutput()
self.img3D = img

self.installPipeline()

Expand Down

0 comments on commit f40e71d

Please sign in to comment.