From c349c3665bdd0aecd8bfc02a6b55e31dc6e54d4f Mon Sep 17 00:00:00 2001 From: Megan Kratz Date: Tue, 19 May 2020 15:11:11 -0600 Subject: [PATCH 1/4] fix for roi getting wrong data when imageAxisOrder='row-major' --- pyqtgraph/imageview/ImageView.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py index daa9b06d..c3878afd 100644 --- a/pyqtgraph/imageview/ImageView.py +++ b/pyqtgraph/imageview/ImageView.py @@ -586,7 +586,8 @@ class ImageView(QtGui.QWidget): # Extract image data from ROI axes = (self.axes['x'], self.axes['y']) - data, coords = self.roi.getArrayRegion(image.view(np.ndarray), self.imageItem, axes, returnMappedCoords=True) + #data, coords = self.roi.getArrayRegion(image.view(np.ndarray), self.imageItem, axes, returnMappedCoords=True) + data, coords = self.roi.getArrayRegion(image.view(np.ndarray), self.imageItem, returnMappedCoords=True) if data is None: return From 360bcad47b2c25ae2c7cffb8958bb97953b016db Mon Sep 17 00:00:00 2001 From: Megan Kratz Date: Tue, 19 May 2020 15:12:09 -0600 Subject: [PATCH 2/4] fix for mismatched axis exception when imageAxisOrder='row-major' --- pyqtgraph/imageview/ImageView.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py index c3878afd..8809def9 100644 --- a/pyqtgraph/imageview/ImageView.py +++ b/pyqtgraph/imageview/ImageView.py @@ -595,7 +595,13 @@ class ImageView(QtGui.QWidget): if self.axes['t'] is None: # Average across y-axis of ROI data = data.mean(axis=axes[1]) - coords = coords[:,:,0] - coords[:,0:1,0] + + if axes == (0,1): ## there's probably a better way to do this slicing dynamically, but I'm not sure what it is. + coords = coords[:,:,0] - coords[:,0:1,0] + elif axes == (1,0): ## we're in row-major order mode + coords = coords[:,0,:] - coords[:,0,0:1] + else: + raise Exception("Need to implement a better way to handle these axes: %s" %str(self.axes)) xvals = (coords**2).sum(axis=0) ** 0.5 else: # Average data within entire ROI for each frame From ca2e5849c21bf99f29c32606fb5ed7866a1b0861 Mon Sep 17 00:00:00 2001 From: Megan Kratz Date: Tue, 19 May 2020 15:25:15 -0600 Subject: [PATCH 3/4] better conditional handling so as not to break something that was working before --- pyqtgraph/imageview/ImageView.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py index 8809def9..f93c1fea 100644 --- a/pyqtgraph/imageview/ImageView.py +++ b/pyqtgraph/imageview/ImageView.py @@ -595,13 +595,10 @@ class ImageView(QtGui.QWidget): if self.axes['t'] is None: # Average across y-axis of ROI data = data.mean(axis=axes[1]) - - if axes == (0,1): ## there's probably a better way to do this slicing dynamically, but I'm not sure what it is. - coords = coords[:,:,0] - coords[:,0:1,0] - elif axes == (1,0): ## we're in row-major order mode + if axes == (1,0): ## we're in row-major order mode -- there's probably a better way to do this slicing dynamically, but I've not figured it out yet. coords = coords[:,0,:] - coords[:,0,0:1] - else: - raise Exception("Need to implement a better way to handle these axes: %s" %str(self.axes)) + else: #default to old way + coords = coords[:,:,0] - coords[:,0:1,0] xvals = (coords**2).sum(axis=0) ** 0.5 else: # Average data within entire ROI for each frame From c0b9bfa040575ea6bd0580a87aa3e3efdbd99d7f Mon Sep 17 00:00:00 2001 From: Ogi Date: Fri, 5 Jun 2020 21:00:18 -0700 Subject: [PATCH 4/4] Remove commented out line --- pyqtgraph/imageview/ImageView.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py index f93c1fea..8324cbbc 100644 --- a/pyqtgraph/imageview/ImageView.py +++ b/pyqtgraph/imageview/ImageView.py @@ -586,7 +586,6 @@ class ImageView(QtGui.QWidget): # Extract image data from ROI axes = (self.axes['x'], self.axes['y']) - #data, coords = self.roi.getArrayRegion(image.view(np.ndarray), self.imageItem, axes, returnMappedCoords=True) data, coords = self.roi.getArrayRegion(image.view(np.ndarray), self.imageItem, returnMappedCoords=True) if data is None: return