From f40e71d46c1dd5a44ebd768aec1416579a20d910 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Fri, 28 Jul 2023 10:49:48 +0100 Subject: [PATCH] Use numpy2vtkImage in CILViewer2D to replace deprecated numpy2vtkImporter (#346) * use numpy2vtkImage closes #244 * Update CHANGELOG.md --------- Co-authored-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com> --- CHANGELOG.md | 3 +++ Wrappers/Python/ccpi/viewer/CILViewer2D.py | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50679ff4..5b3ced9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`: diff --git a/Wrappers/Python/ccpi/viewer/CILViewer2D.py b/Wrappers/Python/ccpi/viewer/CILViewer2D.py index e2cc5f4f..a9d0068f 100644 --- a/Wrappers/Python/ccpi/viewer/CILViewer2D.py +++ b/Wrappers/Python/ccpi/viewer/CILViewer2D.py @@ -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] @@ -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()