Skip to content

Commit

Permalink
Merge branch 'master' into hide-slider-dim1
Browse files Browse the repository at this point in the history
  • Loading branch information
DanicaSTFC authored Aug 27, 2024
2 parents add2bd5 + 1bcf7a3 commit 2a17775
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
## v24.0.2

Enhancements:
- Update corner annotation with axis label #433
- Add title to ViewerCoordsDockWidget #422
- Adds methods to CILviewer and CILviewer2D #425

Bugfix:
- Hides the slider when one image dimension is 1 #432
- Differentiate 3D and 2D images in the converter `numpy2vtkImage` #437
- Edit slider min value #420
- Fix extent error when user clicks in the viewer to create a box by clicking outside of the image #425
- Fix extent error when user enlarges the box outside the image #425
Expand Down
3 changes: 2 additions & 1 deletion Wrappers/Python/ccpi/viewer/CILViewer2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,8 @@ def createAnnotationText(self, display_type, data):
slice_coord = self.style.image2world(slice_coord)[self.getSliceOrientation()]
axis_length = self.style.image2world(axis_length)[self.getSliceOrientation()] - 1
data = (round(slice_coord), round(axis_length))
text = "Slice %d/%d" % data
axis_label = self.axisLabelsText[self.getSliceOrientation()]
text = "%s %d/%d" % (axis_label, data[0], data[1])

else:
# In all other cases, we have coordinates, and then we have an extra value
Expand Down
12 changes: 8 additions & 4 deletions Wrappers/Python/ccpi/viewer/utils/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,17 @@ class Converter(object):

@staticmethod
def numpy2vtkImage(nparray, spacing=(1., 1., 1.), origin=(0, 0, 0), deep=0, output=None):

"""The method converts a numpy array to a vtk image.
The vtk extent is set and needs to differentiate between 3D and 2D images."""
shape = numpy.shape(nparray)
if (nparray.flags["FNC"]):

order = "F"
i = 0
k = 2
k = len(shape) - 1
else:
order = "C"
i = 2
i = len(shape) - 1
k = 0

nparray = nparray.ravel(order)
Expand All @@ -117,7 +118,10 @@ def numpy2vtkImage(nparray, spacing=(1., 1., 1.), origin=(0, 0, 0), deep=0, outp
img_data = output

img_data.GetPointData().AddArray(vtkarray)
img_data.SetExtent(0, shape[i] - 1, 0, shape[1] - 1, 0, shape[k] - 1)
if len(shape) == 3:
img_data.SetExtent(0, shape[i] - 1, 0, shape[1] - 1, 0, shape[k] - 1)
elif len(shape) == 2:
img_data.SetExtent(0, shape[i] - 1, 0, shape[k] - 1, 0, 0)
img_data.GetPointData().SetActiveScalars('vtkarray')
img_data.SetOrigin(origin)
img_data.SetSpacing(spacing)
Expand Down

0 comments on commit 2a17775

Please sign in to comment.