def update_roi(self): axes=(0,1) # self.line_data = self.line_roi.getArrayRegion(self.zdata, self.imageItem, axes=(0,1)) img = self.imageItem imgPts = [self.line_roi.mapToItem(img, h['item'].pos()) for h in self.line_roi.handles] d = Point(imgPts[1] - imgPts[0]) o = Point(imgPts[0]) z = fn.affineSlice(self.zdata, shape=(int(d.length()),), vectors=[Point(d.norm())], origin=o, axes=axes, order=1) x = fn.affineSlice(self.xdata, shape=(int(d.length()),), vectors=[Point(d.norm())], origin=o, axes=axes, order=1) y = fn.affineSlice(self.ydata, shape=(int(d.length()),), vectors=[Point(d.norm())], origin=o, axes=axes, order=1) self.line_data = (x,y,z)
def getArrayRegion(self, data, img, axes=(0, 1), order=1, returnMappedCoords=False, **kwds): """ Use the position of this ROI relative to an imageItem to pull a slice from an array. Since this pulls 1D data from a 2D coordinate system, the return value will have ndim = data.ndim-1 See ROI.getArrayRegion() for a description of the arguments. """ imgPts = [self.mapToItem(img, h) for h in self.endpoints] rgns = [] coords = [] d = Point(imgPts[1] - imgPts[0]) o = Point(imgPts[0]) rgn = affineSlice(data, shape=(int(d.length()), ), vectors=[Point(d.norm())], origin=o, axes=axes, order=order, returnCoords=returnMappedCoords, **kwds) return rgn
def getArrayIndexes(self, spacing=1, **kwds): imgPts = self.get_vertex() positions = [] for i in range(len(imgPts) - 1): d = Point(imgPts[i + 1] - imgPts[i]) o = Point(imgPts[i]) vect = Point(d.norm()) Npts = 0 while Npts * spacing < d.length(): positions.append(((o + Npts * spacing * vect).x(), (o + Npts * spacing * vect).y())) Npts += 1 return positions