Hi,
I am having issues with using the imageview roi when imageAxisOrder is set 
to row-major. The values that get sampled are wrong. I made a test-file 
that I attached in which I compare the plots that I get from the roi in the 
original file, and a modified plot. (PS: you have to manually enlarge the 
plot in the red-custom plot window)
The axes values need to be different in order for the roi to display the 
correct image.
Moreover I get data values from where the rectangle would have been drawn 
if I did not have the row-major config settings.

So the question: 
Is this a bug or is there another way to do this ? 

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/897e9ef3-6524-43a3-8622-d06db264d68d%40googlegroups.com.
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph.graphicsItems.ROI as rois
import sys
from pyqtgraph.imageview.ImageView import *
import pyqtgraph as pg



def newROI_CHG_ROI(chROI: ROI, iv: ImageView):
    darray = iv.image.view(np.ndarray)
    print(iv.axes['x'], iv.axes['y'])
    ar = chROI.getArrayRegion(darray, iv.getImageItem(), axes=[1, 2])
    print(ar.shape)
    ar = ar.mean(axis=2)
    ar = ar.mean(axis=1)

    iv.roiCurves.clear()
    iv.getRoiPlot().plotItem.clear()
    iv.roiCurves.append(iv.ui.roiPlot.plot(pen=pg.mkPen(color='r')))
    iv.roiCurves[len(iv.roiCurves) - 1].setData(x=iv.tVals, y=ar)


if __name__ == '__main__':

    app = QtGui.QApplication()
    pg.setConfigOptions(imageAxisOrder='row-major')  # todo check if this is still needed
    iv = ImageView(name="Modified")
    unchangedIv = ImageView(name="Unchanged")

    # make data
    #each frame of the timeline is a rectangle filled with same values
    d1 = np.full((100, 200), 400)
    d2 = np.full((100, 200), 250)
    d3 = np.full((100, 200), 10)

    f1 = np.dstack((d1, d3))
    f1 = np.dstack((f1, d2))

    data = f1.T
    #
    iv.setImage(data)
    iv.roiClicked()

    chROI = rois.ROI([50, 50], pen=pg.mkPen(color='r'))
    chROI.addTranslateHandle([0, 0])
    iv.view.addItem(chROI)
    chROI.setZValue(20)
    iv.roi = chROI
    chROI.sigRegionChanged.connect(lambda r=chROI, i=iv: newROI_CHG_ROI(chROI, iv))
    # chROI.sigRegionChanged.connect(iv.roiChanged)
    unchangedIv.setImage(data)

    iv.show()
    unchangedIv.show()

    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()

Reply via email to