def display_rois(self, n=''): """Add the ROIs from the roi_handler to the viewbox if they're not already displayed.""" if n: self.rh.create_rois(int(n)) viewbox = self.im_canvas.getViewBox() for item in viewbox.allChildren(): # remove unused ROIs if ((type(item) == pg.graphicsItems.ROI.ROI or type(item) == pg.graphicsItems.TextItem.TextItem) and item not in [r.roi for r in self.rh.ROIs] + [r.label for r in self.rh.ROIs]): viewbox.removeItem(item) layout = self.centre_widget.layout() k = np.sqrt(len(self.plots)) for i, r in enumerate(self.rh.ROIs): if r.roi not in viewbox.allChildren(): reset_slot(r.roi.sigRegionChangeFinished, self.user_roi, True) reset_slot(r.threshedit.textEdited, self.update_plots, True) r.roi.setZValue( 10) # make sure the ROI is drawn above the image viewbox.addItem(r.roi) viewbox.addItem(r.label) try: self.plots[i]['plot'].setTitle('ROI ' + str(r.id)) for j, label in enumerate( list(r.edits.values()) + [r.threshedit, r.autothresh]): layout.addWidget(label, (i // k) * 3, 7 + (i % k) * 6 + j, 1, 1) except IndexError as e: pass # warning('Atom Checker has more plots than ROIs')
def display_rois(self, n=''): """Add the ROIs from the roi_handler to the viewbox if they're not already displayed.""" ROIs = self.rh['Cs'].ROIs + self.rh['Rb'].ROIs viewbox = self.im_canvas.getViewBox() for item in viewbox.allChildren(): # remove unused ROIs if ((type(item) == pg.graphicsItems.ROI.ROI or type(item) == pg.graphicsItems.TextItem.TextItem) and item not in [r.roi for r in ROIs] + [r.label for r in ROIs]): viewbox.removeItem(item) for atom in ['Cs', 'Rb']: for i, r in enumerate(self.rh[atom].ROIs): if r.roi not in viewbox.allChildren(): reset_slot(r.roi.sigRegionChangeFinished, self.user_roi, True) reset_slot(r.threshedit.textEdited, self.update_plots, True) r.roi.setZValue( 10) # make sure the ROI is drawn above the image viewbox.addItem(r.roi) viewbox.addItem(r.label)
def display_fit(self, toggle=True, fit_method='quick'): """Plot the best fit calculated by histo_handler.process and display the histogram statistics in the stat_labels""" reset_slot(self.event_im, self.update_plot) # in case it gets disconnected by maingui sendertext = '' if hasattr(self.sender(), 'text'): # could be called by a different sender sendertext = self.sender().text() if fit_method == 'check action' or sendertext == 'Get best fit': try: fit_method = self.fit_options.checkedAction().text() except AttributeError: fit_method = 'quick' elif sendertext == 'Update statistics': fit_method = 'quick' for ih, hh, canv, labels in zip( [self.ih1, self.ih2, self.image_handler], [self.hh1, self.hh2, self.histo_handler], [self.hist1, self.hist2, self.hist_canvas], [self.hist1_stats, self.hist2_stats, self.stat_labels]): if hh == self.histo_handler: _ = self.get_histogram() success = hh.process(ih, labels['User variable'].text(), fix_thresh=self.thresh_toggle.isChecked(), method=fit_method) if success: for key in hh.stats.keys(): # update the text labels labels[key].setText(str(hh.temp_vals[key])) self.plot_current_hist(ih.histogram, canv) if hh.bf and hh.bf.bffunc and type(hh.bf.ps) != type( None): # plot the curve on the histogram xs = np.linspace(min(hh.bf.x), max(hh.bf.x), 200) canv.plot(xs, hh.bf.bffunc(xs, *hh.bf.ps), pen='b') return success
def set_im_show(self, toggle): """If the toggle is True, always update the display with the last image.""" reset_slot(self.event_im, self.update_im, toggle)
def set_hist_update(self, toggle=True): """Whether the histograms auto update for each new image.""" reset_slot(self.event_im, self.update_plots, toggle)