def imshow(data, title=None, hold=False): dlg = ImageDialog(wintitle=title) dlg.get_plot().add_item(make.image(data)) if hold: dlg.show() else: dlg.exec_()
def test(): win = ImageDialog(edit=True, toolbar=True, wintitle="Sample multi-polygon item") plot = win.get_plot() plot.set_aspect_ratio(lock=True) plot.set_antialiasing(False) plot.set_axis_direction('left', False) plot.set_axis_title("bottom", "Lon") plot.set_axis_title("left", "Lat") points = [] offsets = zeros( (NCIRC, 2), int32) colors = zeros( (NCIRC, 2), uint32) npts = 0 for k in range(NCIRC): pts = create_circle() offsets[k, 0] = k offsets[k, 1] = npts npts += pts.shape[0] points.append(pts) colors[k, 0] = COLORS[k%len(COLORS)][0] colors[k, 1] = COLORS[(3*k)%len(COLORS)][1] points = concatenate(points) print(NCIRC, "Polygons") print(points.shape[0], "Points") crv = PolygonMapItem() crv.set_data(points, offsets, colors) plot.add_item(crv, z=0) win.show() win.exec_()
def imshow(items, title=""): gridparam = make.gridparam(background="black", minor_enabled=(False, False), major_style=(".", "gray", 1)) win = ImageDialog(edit=False, toolbar=True, wintitle=title, options=dict(gridparam=gridparam)) nc = int(np.sqrt(len(items))+1.0) maxy = 0 y = 0 x = 0 w = None plot = win.get_plot() print("-"*80) for i, item in enumerate(items): h = item.boundingRect().height() if i%nc==0: x = 0 y += maxy maxy = h else: x += w maxy = max(maxy, h) w = item.boundingRect().width() item.set_transform(x, y, 0.0) print("Adding item #%d..." % i, end=' ') plot.add_item(item) print("Done") win.show() win.exec_()
def imshow(items, title=""): gridparam = make.gridparam(background="black", minor_enabled=(False, False), major_style=(".", "gray", 1)) win = ImageDialog(edit=False, toolbar=True, wintitle=title, options=dict(gridparam=gridparam)) nc = int(np.sqrt(len(items)) + 1.0) maxy = 0 y = 0 x = 0 w = None plot = win.get_plot() print("-" * 80) for i, item in enumerate(items): h = item.boundingRect().height() if i % nc == 0: x = 0 y += maxy maxy = h else: x += w maxy = max(maxy, h) w = item.boundingRect().width() item.set_transform(x, y, 0.0) print("Adding item #%d..." % i, end=' ') plot.add_item(item) print("Done") win.show() win.exec_()
def test(): win = ImageDialog(edit=True, toolbar=True, wintitle="Sample multi-polygon item") plot = win.get_plot() plot.set_aspect_ratio(lock=True) plot.set_antialiasing(False) plot.set_axis_direction("left", False) plot.set_axis_title("bottom", "Lon") plot.set_axis_title("left", "Lat") points = [] offsets = zeros((NCIRC, 2), int32) colors = zeros((NCIRC, 2), uint32) npts = 0 for k in range(NCIRC): pts = create_circle() offsets[k, 0] = k offsets[k, 1] = npts npts += pts.shape[0] points.append(pts) colors[k, 0] = COLORS[k % len(COLORS)][0] colors[k, 1] = COLORS[(3 * k) % len(COLORS)][1] points = concatenate(points) print(NCIRC, "Polygons") print(points.shape[0], "Points") crv = PolygonMapItem() crv.set_data(points, offsets, colors) plot.add_item(crv, z=0) win.show() win.exec_()
def roi_setup(self): """Show a dialog to setup the region of interest.""" dialog = ImageDialog("ROI Setup", edit=True, toolbar=False, parent=self) default = dialog.add_tool(SelectTool) dialog.set_default_tool(default) roi_tool = dialog.add_tool(RectangleTool, switch_to_default_tool=True) roi = self.cam.roi old_roi = roi roi_tool.activate() # Get image and display plot = dialog.get_plot() img = make.image(self.cam_thread.img_data) plot.add_item(img) plot.set_active_item(img) # Wait for user input dialog.show() if dialog.exec_(): try: roi = get_rect(roi_tool) self.cam.set_roi(roi) except: e = sys.exc_info() print(e) self.cam.set_roi(old_roi)
def imshow(filename): win = ImageDialog(edit=False, toolbar=True, wintitle="RGB image item test") item = make.rgbimage(filename=filename, xdata=[-1, 1], ydata=[-1, 1]) plot = win.get_plot() plot.add_item(item) win.show() win.exec_()
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- filename = osp.join(osp.dirname(__file__), "brain.png") image = make.image(filename=filename, title="Original", colormap="gray") win = ImageDialog( edit=False, toolbar=True, wintitle="Contrast test", options=dict(show_contrast=True), ) plot = win.get_plot() plot.add_item(image) win.resize(600, 600) win.show() try: plot.save_widget("contrast.png") except IOError: # Skipping this part of the test # because user has no write permission on current directory pass win.exec_()
def imshow( items ): win = ImageDialog(edit=False, toolbar=True, options={"yreverse": False}, wintitle="Pcolor test") plot = win.get_plot() for item in items: plot.add_item(item) win.show() win.exec_()
def imshow( data ): win = ImageDialog(edit=False, toolbar=True, wintitle="ImageDialog test", options=dict(xlabel='Concentration', xunit='ppm')) item = make.image(data) plot = win.get_plot() plot.add_item(item) win.show() win.exec_()
def imshow( x, y, data ): win = ImageDialog(edit=False, toolbar=True, wintitle="Image with custom X/Y axes scales", options=dict(xlabel="x (a.u.)", ylabel="y (a.u.)", yreverse=False)) item = make.xyimage(x, y, data) plot = win.get_plot() plot.add_item(item) win.show() win.exec_()
def mandel(): win = ImageDialog(edit=True, toolbar=True, wintitle="Mandelbrot", options=dict(yreverse=False)) mandel = MandelItem(-1.5, .5, -1., 1.) win.add_tool(FullScale, mandel) plot = win.get_plot() plot.set_aspect_ratio(lock=False) plot.add_item(mandel) plot.set_full_scale(mandel) win.show() win.exec_()
def hist2d_func(X, Y, Z): win = ImageDialog(edit=True, toolbar=True, wintitle="2-D Histogram X0=(0,1), X1=(-1,-1)") hist2d = make.histogram2D(X, Y, 200, 200, Z=Z, computation=2) curve = make.curve(X[::50], Y[::50], linestyle="", marker="+", title=_("Markers")) plot = win.get_plot() plot.set_aspect_ratio(lock=False) plot.set_antialiasing(False) plot.add_item(hist2d) plot.add_item(curve) plot.set_item_visible(curve, False) win.show() win.exec_()
def hist2d_func(X, Y, Z): win = ImageDialog(edit=True, toolbar=True, wintitle="2-D Histogram X0=(0,1), X1=(-1,-1)") hist2d = make.histogram2D(X, Y, 200, 200, Z=Z, computation=2) curve = make.curve(X[::50], Y[::50], linestyle='', marker='+', title=_("Markers")) plot = win.get_plot() plot.set_aspect_ratio(lock=False) plot.set_antialiasing(False) plot.add_item(hist2d) plot.add_item(curve) plot.set_item_visible(curve, False) win.show() win.exec_()
def imshow(x, y, data, filter_area, yreverse=True): win = ImageDialog(edit=False, toolbar=True, wintitle="Image filter demo", options=dict(xlabel="x (cm)", ylabel="y (cm)", yreverse=yreverse)) image = make.xyimage(x, y, data) plot = win.get_plot() plot.add_item(image) xmin, xmax, ymin, ymax = filter_area flt = make.imagefilter(xmin, xmax, ymin, ymax, image, filter=lambda x, y, data: gaussian_filter(data, 5)) plot.add_item(flt, z=1) plot.replot() win.show() win.exec_()
def get_segment(item): """Show image and return selected segment coordinates""" win = ImageDialog(_("Select a segment then press OK to accept"), edit=True) default = win.add_tool(SelectTool) win.set_default_tool(default) segtool = win.add_tool(AnnotatedSegmentTool, title="Test", switch_to_default_tool=True) segtool.activate() plot = win.get_plot() plot.add_item(item) plot.set_active_item(item) win.show() if win.exec_(): shape = segtool.get_last_final_shape() return shape.get_rect()
def plotImage(x,y,z,wintitle="Contour Plot",options={"lock_aspect_ratio":False,"yreverse":False}): options.update(dict(show_xsection=True, show_ysection=True)) """Test""" # -- Create QApplication _app = guidata.qapplication() # -- win = ImageDialog(edit=True, toolbar=True, wintitle=wintitle, options=options) win.resize(1500, 1000) item = make.xyimage(x, y, z,interpolation="linear") plot = win.get_plot() plot.add_item(item) win.plot_widget.xcsw_splitter.setSizes([400,600]) win.show() return win
def data_view(data, ofa, data_title): win = ImageDialog(edit=True, toolbar=True, wintitle="DW viewer", options=dict(show_contrast=False, xlabel='Channel', xunit='#', ylabel='time', show_xsection=True, show_ysection=True)) # win.add_tool(AnnotatedRectangleTool) # win.add_tool(ReverseYAxisTool) # win.add_tool(AnnotatedRectangleTool, title="Flag", # switch_to_default_tool=False, # handle_final_shape_cb=customize_shape) # win.add_tool(VCursorTool) # sst=win.add_tool(SignalStatsTool) # SignalStatsTool.activate(sst) xcs = win.panels['x_cross_section'] xcs.cs_plot.curveparam.curvestyle = 'Steps' xcs.cs_plot.perimage_mode = False ycs = win.panels['y_cross_section'] ycs.cs_plot.curveparam.curvestyle = 'Steps' ycs.cs_plot.perimage_mode = False item_data = make.image(data, title=data_title) item_data.interpolate = (0, ) item_ofa = make.image(ofa, title='Overflow') item_ofa.interpolate = (0, ) item_ofa.imageparam.alpha_mask = True plot = win.get_plot() plot.add_item(item_data) plot.add_item(item_ofa) # plot.add_item(itemFlag) win.show() if win.exec_(): # return plot.items return win
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- filename = osp.join(osp.dirname(__file__), "brain.png") image = make.image(filename=filename, title="Original", colormap='gray') win = ImageDialog(edit=False, toolbar=True, wintitle="Contrast test", options=dict(show_contrast=True)) plot = win.get_plot() plot.add_item(image) win.resize(600, 600) win.show() try: plot.save_widget('contrast.png') except IOError: # Skipping this part of the test # because user has no write permission on current directory pass win.exec_()
def plotImage(x, y, z, wintitle="Contour Plot", options={ "lock_aspect_ratio": False, "yreverse": False }): options.update(dict(show_xsection=True, show_ysection=True)) """Test""" # -- Create QApplication _app = guidata.qapplication() # -- win = ImageDialog(edit=True, toolbar=True, wintitle=wintitle, options=options) win.resize(1500, 1000) item = make.xyimage(x, y, z, interpolation="linear") plot = win.get_plot() plot.add_item(item) win.plot_widget.xcsw_splitter.setSizes([400, 600]) win.show() return win
SHOW = True # Show test in GUI-based test launcher FNAME = "image_masked.pickle" if __name__ == "__main__": import guidata _app = guidata.qapplication() win = ImageDialog(toolbar=True, wintitle="Masked image item test") win.add_tool(ImageMaskTool) if os.access(FNAME, os.R_OK): print("Restoring mask...", end=" ") iofile = open(FNAME, "rb") image = pickle.load(iofile) iofile.close() print("OK") else: fname = osp.join(osp.abspath(osp.dirname(__file__)), "brain.png") image = make.maskedimage( filename=fname, colormap="gray", show_mask=True, xdata=[0, 20], ydata=[0, 25], ) win.get_plot().add_item(image) win.show() win.exec_() iofile = open(FNAME, "wb") pickle.dump(image, iofile)
class MTEAcqu(QWidget): def __init__(self, parent): super(QWidget, self).__init__(parent) self.parent = parent self.base_path = os.path.realpath(os.path.curdir) self.threadAcq = ThreadAcq(self) self.configMTE = QSettings('configMTE.ini', QSettings.IniFormat) self.setup() self.win = ImageDialog(edit=False, toolbar=True, wintitle="Visu Data", options=dict(show_xsection=True, show_ysection=True, show_contrast=True, show_itemlist=False)) self.win.resize(800, 1000) data = np.ones((1300, 1340)) self.item_data = make.image(data, colormap='hot') self.plot = self.win.get_plot() self.plot.add_item(self.item_data) def setup(self): self.setWindowTitle('MTE acquisition') self.name_file = QLineEdit('filename.tif') self.showParam = QPushButton('Show Param') self.showParam.clicked.connect(self.show_all_param) self.com_conf = QComboBox() self.com_conf.insertItems(0, self.configMTE.childGroups()) self.but_load_conf = QPushButton('load conf') self.but_load_conf.clicked.connect(self.load_conf) hlayout3 = QHBoxLayout() hlayout3.addWidget(self.but_load_conf) self.check_bck = QCheckBox('Substract BCK') self.but_tool = QToolButton() self.but_tool.setText('...') self.but_tool.clicked.connect(self.load_BCK) self.name_bck = QLineEdit('filename_BCK.tif') self.name_bck.setDisabled(True) hlayout = QHBoxLayout() hlayout.addWidget(self.check_bck) hlayout.addWidget(self.but_tool) self.lin_base_path = QLineEdit('default path') self.lin_base_path.setText(self.base_path) self.lin_base_path.setDisabled(True) self.but_base_path = QToolButton() self.but_base_path.setText('...') self.but_base_path.clicked.connect(self.ch_base_path) hlayout2 = QHBoxLayout() hlayout2.addWidget(self.lin_base_path) hlayout2.addWidget(self.but_base_path) self.startAcq = QPushButton('Start Acq') self.startAcq.clicked.connect(self.start_acq) self.but_show = QPushButton('Show data') self.but_show.clicked.connect(self.show_data) vlayout = QVBoxLayout(self) vlayout.addWidget(self.showParam) vlayout.addSpacing(25) vlayout.addWidget(self.com_conf) vlayout.addLayout(hlayout3) vlayout.addSpacing(25) vlayout.addLayout(hlayout) vlayout.addWidget(self.name_bck) vlayout.addSpacing(25) vlayout.addLayout(hlayout2) vlayout.addWidget(self.name_file) vlayout.addWidget(self.startAcq) vlayout.addSpacing(25) vlayout.addWidget(self.but_show) vlayout.addStretch() self.setLayout(vlayout) def ch_base_path(self): self.base_path = QFileDialog.getExistingDirectory(self) self.lin_base_path.setText(self.base_path) print('Base path is set to : %s' % self.base_path) def load_BCK(self): path_bck = QFileDialog.getOpenFileName(self) self.name_bck.setText(path_bck) print('Background file is set to : %s' % path_bck) import PIL img_pil = PIL.Image.open(path_bck) self.array_bck = np.array(img_pil) def start_acq(self): self.mte = self.parent.widCON.mte self.threadAcq.start() def show_all_param(self): self.mte.printAvailableParameters() param = ['ExposureTime', 'ShutterTimingMode'] print('#### MTE parameters ####') for p in param: print(p, self.mte.getParameter(p)) def show_data(self): self.win.show() def load_conf(self): conf = self.com_conf.currentText() self.configMTE = QSettings('configMTE.ini', QSettings.IniFormat) print('Loading configuration: %s' % conf) x0 = int(self.configMTE.value(conf + '/x0')) w = int(self.configMTE.value(conf + '/w')) y0 = int(self.configMTE.value(conf + '/y0')) h = int(self.configMTE.value(conf + '/h')) CleanCycleCount = int(self.configMTE.value(conf + '/CleanCycleCount')) ExposureTime = int(self.configMTE.value(conf + '/ExposureTime')) TriggerResponse = int(self.configMTE.value(conf + '/TriggerResponse')) self.mte = self.parent.widCON.mte self.mte.setParameter("CleanCycleCount", CleanCycleCount) self.mte.setParameter("ExposureTime", ExposureTime) self.mte.setParameter("TriggerResponse", TriggerResponse) self.mte.setROI(x0, w, 1, y0, h, 1) self.mte.sendConfiguration()
class Gui(object): def __init__(self, xlabel=None, ylabel=None, winTitle=None): """ Boilerplate code for guiqwt image window. Includes qt application, x-,y-crosssection, itemlistpanel, contrast adjustment. Returns -------- win : guiqwt.plot.ImageDialog _app : PyQt4.QtGui.QApplication """ self._app = qapplication() self.win = ImageDialog(edit=False, toolbar=True, wintitle=winTitle, options=dict(xlabel=xlabel, ylabel=ylabel, yreverse=False, lock_aspect_ratio=False)) self.itemlist_panel = self.win.get_itemlist_panel() self.itemlist_panel.show() action = QAction(get_icon('busy.png'), "Reload", self.itemlist_panel) action.triggered.connect(self.reload_measurement) self.itemlist_panel.children()[-2].addAction(action) self.win.plot_widget.plot.SIG_ITEM_REMOVED.connect( self.remove_measurement) action = QAction(get_icon('save_all.png'), "Save all", self.itemlist_panel) action.triggered.connect(self.save_measurements) self.itemlist_panel.children()[-3].addAction(action) def fun(shape): shape.symbol.pen().setWidth(2) shape.symbol.setColor(QColor(255, 0, 0)) self.win.add_tool(PointTool, handle_final_shape_cb=fun) self.win.get_xcs_panel().show() self.win.get_ycs_panel().show() self.win.get_contrast_panel().show() action = QAction(get_icon('fileopen.png'), "Open measurement", self.itemlist_panel) action.triggered.connect(self.load_measurement) self.win.get_toolbar().addAction(action) self.win.get_toolbar().addAction("Load VNA measurement", self.load_VNAMeasurement) self.win.get_toolbar().addAction( "Load VNA measurement ...", self.load_VNAMeasurement_select_channels) self.win.get_toolbar().addAction( "Load VNA fields measurement ", self.load_VNASeparateFieldsMeasurement) self.win.get_toolbar().addAction("Get points", self.get_points) if peakit: self.win.get_toolbar().addAction("Fitting tool ...", self.launchFittingTool) self.fitting_controller = MeasurementController() else: self.fitting_controller = None self.operations_widget = OperationsWidget() bbfmr_operations = list( filter(None, [("bbFMR.processing.%s" % s) if "__" not in s else None for s in dir(bp)])) self.operations_widget.populate_available_operations(bbfmr_operations) self.itemlist_panel.layout().addWidget(self.operations_widget) self.itemlist_panel.listwidget.selectionModel( ).selectionChanged.connect(self.refresh_operations) self.operations_widget.operations_changed.connect( self.replot_measurement) self.plot_items = self.win.plot_widget.plot.items self.measurements = [] def _get_current_plot_item(self): selection = self.itemlist_panel.listwidget.selectedIndexes() if len(selection) > 0: list_idx = selection[0].row() plot_item_idx = len(self.plot_items) - 1 - list_idx return self.plot_items[plot_item_idx], plot_item_idx else: return None, None def get_points(self): points = [] for item in self.itemlist_panel.listwidget.items: if isinstance(item, PointShape): print(item.get_pos()) points.append(item.get_pos()) fileName = QFileDialog.getSaveFileName(caption='Save file', filter="dat (*.dat *.)") if fileName: print(fileName) np.savetxt(fileName, points, delimiter='\t') return points def refresh_operations(self): plot_item, _ = self._get_current_plot_item() if plot_item is not None: self.operations_widget.set_operations( plot_item.measurement.operations) def add_measurement(self, m, **kwargs): self.measurements.append(m) if "title" not in m.metadata or not m.metadata["title"]: m.metadata["title"] = m.metadata["fname"] _, image = self.imshow(m.X[:, 0], m.Y[0, :], m.Z.T, title=m.metadata["title"], **kwargs) image.measurement = m def remove_measurement(self, item): self.measurements.remove(item.measurement) def reload_measurement(self): """ Trigger reloading of the currently selected measurement """ plot_item, plot_item_idx = self._get_current_plot_item() if plot_item is None: return False plot_item.measurement.reload() self.replot_measurement() def replot_measurement(self): """ Recreate theimage for the currently selected image. Taking into account any changed operations. Called when operations_widget.operations_changed is emitted """ plot_item, plot_item_idx = self._get_current_plot_item() if plot_item is None: return False m = plot_item.measurement m.operations = self.operations_widget.get_operations() m.process() # recreate the image (this handles sorting of data and other bla) from guiqwt.builder import make image = make.xyimage(m.X[:, 0], m.Y[0, :], m.Z.T, interpolation="nearest", title=m.metadata["title"]) # update image to the new data values plot_item.set_data(image.data) plot_item.set_xy(image.x, image.y) plot_item.plot().replot() #self.win.get_plot().replot() def imshow(self, x, y, data, title=None, cmap="RdYlGn"): """ Create 2D xyimage for guiqwt image dialog Returns -------- plot : guiqwt.image.ImagePlot Plot widget in guiqwt ImageDialog image : guiqwt.image.XYImageItem Newly created image object """ from guiqwt.builder import make image = make.xyimage( x, y, data, interpolation="nearest", title=title, ) plot = self.win.get_plot() plot.add_item(image) plot.do_autoscale() plot.replot() image.set_color_map(cmap) image.measurement = None return plot, image def pcolorshow(self, aX, aY, aData, title=None): """ Create 2D xyimage for guiqwt image dialog Returns -------- plot : ? Plot widget in guiqwt ImageDialog image : ? new image object """ from guiqwt.builder import make image = make.pcolor( aX, aY, aData, interpolation="nearest", title=title, ) plot = self.win.get_plot() plot.add_item(image) plot.do_autoscale() plot.replot() return plot, image def save_measurements(self): """ Save measurements object descriptions to .measurement.json file(s) """ folder = QFileDialog.getExistingDirectory(caption="Save measurements") for m in self.measurements: fname = os.path.basename(m.metadata["fname"]) + ".measurement.json" m.save(os.path.join(folder, fname)) def load_measurement(self): """ Load measurements according to .measurement.json file(s) """ fnames = QFileDialog.getOpenFileNames( caption="Open Tdms file(s)", filter= u"Measurements Object Descriptions (*.measurement.json);;All files (*.*)" ) for fname in fnames: with open(fname, "r") as f: m = jsonpickle.loads(f.read()) self.add_measurement(m, cmap="RdYlGn") return fnames def load_VNAMeasurement(self): """ Load a VNA measurement from a TDMS file. Apply certain standard operations and plot data. """ fnames = QFileDialog.getOpenFileNames( caption="Open Tdms file(s)", filter=u"TDMS (*.tdms);;All files (*.*)") for fname in fnames: m = VNAMeasurement(fname) m.add_operation(bp.derivative_divide, modulation_amp=4) m.add_operation(bp.mag) self.add_measurement(m, cmap="RdYlGn") return fnames def load_VNAMeasurement_select_channels(self): """ Load a VNA measurement from a TDMS file. Apply certain standard operations and plot data. Allow to select used channels. """ fnames = QFileDialog.getOpenFileNames( caption="Open Tdms file(s)", filter=u"TDMS (*.tdms);;All files (*.*)") for fname in fnames: tdms_file = TdmsFile(fname) channel_labels = [ "Field channel", "Frequency channel", "Re(signal) channel", "Im(signal) channel" ] paths, accepted = TdmsChannelSelectDialog.get_group_channels( tdms_file=tdms_file, channel_labels=channel_labels) m = VNAMeasurement(fname=fname, tdms_file=tdms_file, group=paths[2][0], field_channel=paths[0][1], freq_channel=paths[1][1], signal_channel=paths[2][1], imag_channel=paths[3][1]) m.add_operation(bp.derivative_divide, modulation_amp=4) m.add_operation(bp.mag) self.add_measurement(m, cmap="RdYlGn") return fnames def launchFittingTool(self): """ ... """ plot_item, _ = self._get_current_plot_item() if plot_item is not None: measurement = plot_item.measurement else: measurement = None self.fitting_controller.measurement = measurement self.fitting_controller.show_view() def load_VNASeparateFieldsMeasurement(self): """ Load a VNA measurement from a TDMS file with two magnetic field channels (field_before, field_after). Apply certain standard operations and plot data. Allow to select used channels. """ fnames = QFileDialog.getOpenFileNames( caption="Open Tdms file(s)", filter=u"TDMS (*.tdms);;All files (*.*)") for fname in fnames: tdms_file = TdmsFile(fname) channel_labels = [ "Field_before", "Field_after", "Frequency", "Re(signal)", "Im(signal)" ] paths, accepted = TdmsChannelSelectDialog.get_group_channels( tdms_file=tdms_file, channel_labels=channel_labels) m = VNASeparateFieldsMeasurement(fname=fname, tdms_file=tdms_file, path_field_before=paths[0], path_field_after=paths[1], path_frequency=paths[2], path_real_signal=paths[3], path_imag_signal=paths[4]) m.add_operation(bp.derivative_divide, modulation_amp=4) m.add_operation(bp.mag) self.add_measurement(m, cmap="RdYlGn") return fnames def run(self): self.win.show() self.win.exec()
import os, os.path as osp, pickle from guiqwt.plot import ImageDialog from guiqwt.tools import ImageMaskTool from guiqwt.builder import make SHOW = True # Show test in GUI-based test launcher FNAME = "image_masked.pickle" if __name__ == "__main__": import guidata _app = guidata.qapplication() win = ImageDialog(toolbar=True, wintitle="Masked image item test") win.add_tool(ImageMaskTool) if os.access(FNAME, os.R_OK): print("Restoring mask...", end=" ") iofile = open(FNAME, "rb") image = pickle.load(iofile) iofile.close() print("OK") else: fname = osp.join(osp.abspath(osp.dirname(__file__)), "brain.png") image = make.maskedimage(filename=fname, colormap="gray", show_mask=True, xdata=[0, 20], ydata=[0, 25]) win.get_plot().add_item(image) win.show() win.exec_() iofile = open(FNAME, "wb") pickle.dump(image, iofile)