ImageJ 1.53c, Windows 10
I’m not sure whether I’m not doing the slice deletion properly or whether it is a small bug.
Run the following jython code:
from ij import IJ
IJ.run('MRI Stack') # has 27 slices
im = IJ.getImage()
# set stack to the last slice
im.setSlice(im.getNSlices())
# delete last slice
im.getImageStack().deleteLastSlice()
# update (I do not know which one I should be calling)
im.updateAndRepaintWindow()
im.updateImage()
im.updateAndDraw()
im.repaintWindow()
you should see
There are two issues:
- the slice displayed is the last one (27) that should have been deleted
- the slice number at the top (26/26) does not match the bottom slider
From there
- if you do a mousewheel scroll down
– the slice image is updated to the correct new last slice (slice 26)
– the last slice (27) correctly disappears
– the slider is still wrong. Only after wheel scrolling back and forth it gets back to normal - if you do a mousewheel scroll up, or click on either arrow of the stack slider
– the last slice (27) is still present while it should have been deleted
– the second last slice (26) has been deleted instead
If you comment out displaying the last slice
# im.setSlice(im.getNSlices()-1)
there is no issue (or it resolves upon scrolling when you go check the end of the stack).
If you set and then delete the second last slice:
from ij import IJ
a = IJ.run('MRI Stack')
im = IJ.getImage()
# set stack to the second last slice
im.setSlice(im.getNSlices()-1)
# delete second last slice
im.getImageStack().deleteSlice(im.getNSlices()-1)
# update (I do not know which one I should be calling)
im.updateAndRepaintWindow()
im.updateImage()
im.updateAndDraw()
im.repaintWindow()
you should see
Only one issue: the bottom slider is wrong. There are no issues with deletion of the wrong slice regardless of scrolling up/down or using the slider arrows.
Any idea what is happening?
Thanks