def __init__(self, parent, send_data_function): super().__init__(parent) self.plotThread = self.PlotThread(self) self.parent = parent self.send_data = send_data_function self.canvas = plugin_canvas.PluginCanvas(parent, send_data_function) self.canvas.set_name(name) self.ax = self.canvas.figure.add_subplot(111)
def __init__(self, parent, name): super().__init__(name) self.parameter_boxes = {} self._name = name self.canvas = plugin_canvas.PluginCanvas() self.canvas.set_name(name) self.layoutWidget = self.canvas.layoutWidget self.canvas.layout.removeWidget(self.canvas.active_checkbox) self.canvas.active_checkbox.setParent(None) self.set_active(True) self.layout = QHBoxLayout() number_label = QLabel("# of averages:") self.layout.addWidget(number_label) self.averages_spinbox = QSpinBox() self.averages_spinbox.setValue(5) self.averages_spinbox.setMinimum(1) self.averages_spinbox.setMaximum(999) self.layout.addWidget(self.averages_spinbox) self.layout.addStretch(1) self.start_button = QPushButton("Start") self.layout.addWidget(self.start_button) self.layout.addStretch(1) self.progress_bar = QProgressBar() self.progress_bar.setMaximum(5) self.progress_bar.setValue(0) self.layout.addWidget(self.progress_bar) self.layout.addStretch(1) self.stop_button = QPushButton("Abort") self.layout.addWidget(self.stop_button) self.layout.addStretch(1) self.save_button = QPushButton("Save") self.layout.addWidget(self.save_button) self.widget = QWidget() self.widget.setLayout(self.layout) self.canvas.layout.insertWidget(0, self.widget) magma = generatePgColormap('magma') self.main_plot = self.layoutWidget.addViewBox(invertY=True) self.main_plot.setAspectLocked() self.mainImage = pg.ImageItem(lut=magma.getLookupTable()) self.mainImage.setOpts(axisOrder="row-major") self.main_plot.addItem(self.mainImage) self.worker_thread = AveragingWorker() self.frameAvailable.connect(self.worker_thread.processFrame) self.worker_thread.averagedImageAvailable.connect(self.set_image) self.start_button.clicked.connect(self.start_recording) self.stop_button.clicked.connect(self.worker_thread.stopRecording) self.save_button.clicked.connect(self.save_image) self.worker_thread.imagesRecorded.connect(self.progress_bar.setValue) self.worker_thread.message.connect(self.message) self.name_generator = SaveNameGenerator()
def __init__(self, parent, name): super().__init__(name) self.parameter_boxes = {} self._name = name self.canvas = plugin_canvas.PluginCanvas() self.canvas.set_name(name) self.layoutWidget = self.canvas.layoutWidget self.canvas.active.connect(self.set_active) self.layout = QHBoxLayout() self.homogenizeCheckbox = QCheckBox("high-pass") self.layout.addWidget(self.homogenizeCheckbox) self.layout.addStretch(1) self.sigmaLabel = QLabel("sigma: ") self.layout.addWidget(self.sigmaLabel) self.sigmaBox = QDoubleSpinBox() self.sigmaBox.setSingleStep(0.2) self.sigmaBox.setValue(4) self.layout.addWidget(self.sigmaBox) self.layout.addStretch(1) self.blurLabel = QLabel("blur: ") self.layout.addWidget(self.blurLabel) self.blurBox = QDoubleSpinBox() self.blurBox.setValue(1) self.blurBox.setSingleStep(0.2) self.layout.addWidget(self.blurBox) self.widget = QWidget() self.widget.setLayout(self.layout) self.canvas.layout.insertWidget(1, self.widget) # some image plots: magma = generatePgColormap('magma') self.main_plot = self.layoutWidget.addPlot(invertY=True) self.main_plot.setAspectLocked() self.mainImage = pg.ImageItem(lut=magma.getLookupTable()) self.mainImage.setOpts(axisOrder="row-major") self.main_plot.addItem(self.mainImage) self.workerThread = Worker() self.frameAvailable.connect(self.workerThread.processFrame) self.workerThread.result.connect(self.setResult)
def __init__(self, parent, send_data_function): super().__init__(parent) self.parameter_boxes = {} self.parent = parent self.send_data = send_data_function self.canvas = plugin_canvas.PluginCanvas(parent, send_data_function) self.canvas.set_name(name) self.layoutWidget = self.canvas.layoutWidget # some image plots: magma = generatePgColormap('magma') self.leftPlot = self.layoutWidget.addPlot(title="left") self.leftPlot.setAspectLocked() self.leftPlot.showAxis('bottom', False) self.leftPlot.showAxis('left', False) self.leftImage = pg.ImageItem(lut=magma.getLookupTable()) self.leftPlot.addItem(self.leftImage) self.rightPlot = self.layoutWidget.addPlot(title="right") self.rightPlot.setAspectLocked() self.rightPlot.showAxis('bottom', False) self.rightPlot.showAxis('left', False) self.rightImage = pg.ImageItem(lut=magma.getLookupTable()) self.rightPlot.addItem(self.rightImage) self.differencePlot = self.layoutWidget.addPlot(title="difference") self.differencePlot.setAspectLocked() self.differencePlot.showAxis('bottom', False) self.differencePlot.showAxis('left', False) self.differenceImage = pg.ImageItem(lut=magma.getLookupTable()) self.differencePlot.addItem(self.differenceImage) self.workerThread = Worker() self.frameAvailable.connect(self.workerThread.processFrame) self.workerThread.leftImage.connect(self.setLeft) self.workerThread.rightImage.connect(self.setRight) self.workerThread.result.connect(self.setDifference)
def __init__(self, parent, name): super().__init__(name) self.filename = QDir.homePath() self._total_images = 0 self.canvas = plugin_canvas.PluginCanvas() self.canvas.set_name(name) self.canvas.layout.removeWidget(self.canvas.layoutWidget) self.canvas.layoutWidget.setParent(None) self.canvas.layout.removeWidget(self.canvas.active_checkbox) self.canvas.active_checkbox.setParent(None) self.set_active(True) main_layout = QVBoxLayout() self.folderLabel = QLabel() self.folderLabel.setMinimumWidth(300) self.folderButton = QPushButton("Choose...") self.folderButton.clicked.connect(self.chooseFolder) self.folderGroupBox = QGroupBox("File") folder_layout = QHBoxLayout() folder_layout.addWidget(self.folderLabel) folder_layout.addStretch(1) folder_layout.addWidget(self.folderButton) self.folderGroupBox.setLayout(folder_layout) main_layout.addWidget(self.folderGroupBox) self.rateSpinBox = QDoubleSpinBox() self.rateSpinBox.setValue(1) self.rateSpinBox.setMinimum(0.001) self.rateSpinBox.setSingleStep(0.05) self.rateSpinBox.valueChanged.connect(self.updateTotalTime) self.rateGroupBox = QGroupBox("Frames / s") rate_layout = QHBoxLayout() rate_layout.addWidget(self.rateSpinBox) rate_layout.addStretch(1) self.rateGroupBox.setLayout(rate_layout) main_layout.addWidget(self.rateGroupBox) self.numberImagesSpinBox = QSpinBox() self.numberImagesSpinBox.setValue(10) self.numberImagesSpinBox.setMinimum(1) self.numberImagesSpinBox.setMaximum(9999) self.numberImagesSpinBox.valueChanged.connect(self.updateTotalTime) self.numberImagesGroupBox = QGroupBox("Number of images") numberImages_layout = QHBoxLayout() numberImages_layout.addWidget(self.numberImagesSpinBox) numberImages_layout.addStretch(1) self.numberImagesGroupBox.setLayout(numberImages_layout) main_layout.addWidget(self.numberImagesGroupBox) self.averagesSpinBox = QSpinBox() self.averagesSpinBox.setValue(3) self.averagesSpinBox.setMinimum(1) self.averagesSpinBox.setMaximum(9999) self.averagesGroupBox = QGroupBox("Averages per images") averages_layout = QHBoxLayout() averages_layout.addWidget(self.averagesSpinBox) averages_layout.addStretch(1) self.averagesGroupBox.setLayout(averages_layout) main_layout.addWidget(self.averagesGroupBox) self.recorded_images_label = QLabel("Images recorded: 0") main_layout.addWidget(self.recorded_images_label) self.saved_images_label = QLabel("Image file written: Not yet") main_layout.addWidget(self.saved_images_label) self.time_label = QLabel("Elapsed time: ") main_layout.addWidget(self.time_label) self.total_time_label = QLabel("Total time: ") main_layout.addWidget(self.total_time_label) button_layout = QHBoxLayout() self.start_button = QPushButton("start") button_layout.addWidget(self.start_button) self.stop_button = QPushButton("stop") button_layout.addWidget(self.stop_button) main_layout.addLayout(button_layout) outer_layout = QHBoxLayout() outer_layout.addStretch(1) outer_layout.addLayout(main_layout) outer_layout.addStretch(1) self.canvas.layout.addStretch(1) self.canvas.layout.addLayout(outer_layout) self.canvas.layout.addStretch(1) self.updateTotalTime() self.recorder_worker = RecorderWorker() self.recorder_worker.imagesRecorded.connect(self.updateImagesRecorded) self.recorder_worker.imagesSaved.connect(self.updateImagesSaved) self.frameAvailable.connect(self.recorder_worker.processFrame) self.start_button.clicked.connect(self.startRecording) self.stop_button.clicked.connect(self.recorder_worker.stopRecording) self.recorder_worker.message.connect(self.message) self.updateFolderLabel() self.timer = QTimer() self.startTime = 0 self.timer.timeout.connect(self.updateTime) self.recorder_worker.finished.connect(self.timer.stop)
def __init__(self, parent, name): super().__init__(name) self.parameter_boxes = {} self.parent = parent self.canvas = plugin_canvas.PluginCanvas() self.canvas.set_name(name) # self.canvas.resize(900, 600) self.layoutWidget = self.canvas.layoutWidget self.canvas.active.connect(self.set_active) # make fields to enter parameters: self.canvas.param_layout = QHBoxLayout() self.parameter_boxes["auto"] = QCheckBox("auto") for param in ["min_sigma", "max_sigma", "overlap", "threshold"]: if param == "min_sigma" or param == "max_sigma": spin_box = QSpinBox() else: spin_box = QDoubleSpinBox() self.parameter_boxes[param] = spin_box group_box = QGroupBox(param) layout = QHBoxLayout() layout.addWidget(spin_box) if param == "threshold": layout.addWidget(self.parameter_boxes["auto"]) group_box.setLayout(layout) self.canvas.param_layout.addWidget(group_box) number_box = QComboBox() number_box.addItem("3") number_box.addItem("2") group_box = QGroupBox("Number of blobs") layout = QHBoxLayout() layout.addWidget(number_box) group_box.setLayout(layout) self.canvas.param_layout.addWidget(group_box) self.parameter_boxes["number"] = number_box method_box = QComboBox() method_box.addItem("dog") method_box.addItem("log") group_box = QGroupBox("method") layout = QHBoxLayout() layout.addWidget(method_box) group_box.setLayout(layout) self.canvas.param_layout.addWidget(group_box) self.parameter_boxes["method"] = method_box window_box = QGroupBox("FFT window") layout = QVBoxLayout() window_box.setLayout(layout) transformWindowCheckbox = QCheckBox("transform") self.parameter_boxes["window"] = transformWindowCheckbox layout.addWidget(transformWindowCheckbox) invTransfromWindowCheckbox = QCheckBox("inverse transform") self.parameter_boxes["invWindow"] = invTransfromWindowCheckbox layout.addWidget(invTransfromWindowCheckbox) self.canvas.param_layout.addWidget(window_box) # default parameters: self.parameter_boxes["min_sigma"].setValue(8) self.parameter_boxes["max_sigma"].setValue(17) self.parameter_boxes["overlap"].setValue(0) self.parameter_boxes["overlap"].setSingleStep(0.05) self.parameter_boxes["overlap"].setMaximum(1) self.parameter_boxes["threshold"].setValue(1) self.parameter_boxes["threshold"].setSingleStep(0.02) self.parameter_boxes["threshold"].setMaximum(5) self.parameter_boxes["threshold"].setDecimals(4) self.parameter_boxes["method"].setCurrentText('dog') self.parameter_boxes["auto"].setChecked(True) param_widget = QWidget() param_widget.setLayout(self.canvas.param_layout) self.canvas.layout.insertWidget(1, param_widget) self.blob_boxes = {} self.canvas.blob_layout = QHBoxLayout() blob_text = QLabel("Main blob position: ") self.canvas.blob_layout.addWidget(blob_text) self.blob_boxes["auto"] = QCheckBox("auto") self.blob_boxes["auto"].setChecked(True) self.canvas.blob_layout.addWidget((self.blob_boxes["auto"])) self.canvas.blob_layout.addStretch(1) for param in ["x", "y", "r"]: if param == "r": spin_box = QDoubleSpinBox() else: spin_box = QSpinBox() self.blob_boxes[param] = spin_box param_label = QLabel(param + ":") self.canvas.blob_layout.addWidget(param_label) self.canvas.blob_layout.addWidget(spin_box) self.canvas.blob_layout.addStretch(1) self.canvas.blob_layout.addStretch(1) homogenize_box = QCheckBox("high-pass") self.blob_boxes["homogenize"] = homogenize_box self.canvas.blob_layout.addWidget(homogenize_box) homogenize_value = QDoubleSpinBox() homogenize_value.setValue(4.0) self.blob_boxes["homogenize_value"] = homogenize_value self.canvas.blob_layout.addWidget(homogenize_value) self.blur_label = QLabel("blur") self.canvas.blob_layout.addStretch(1) self.canvas.blob_layout.addWidget(self.blur_label) blur_box = QSpinBox() self.blob_boxes["homogenize_blur"] = blur_box blur_box.setValue(0) self.canvas.blob_layout.addWidget(blur_box) blob_widget = QWidget() blob_widget.setLayout(self.canvas.blob_layout) self.canvas.layout.insertWidget(3, blob_widget) self.blob_boxes["x"].setMaximum(300) self.blob_boxes["y"].setMaximum(300) self.blob_boxes["r"].setSingleStep(0.5) self.blob_boxes["r"].setDecimals(1) self.blob_boxes["r"].setMaximum(60) label_layout = QHBoxLayout() self.blob_label = QLabel("Blobs found: #") self.blob_label.setMinimumWidth(150) label_layout.addWidget(self.blob_label) self.period_label = QLabel("Fringe period: # px") self.period_label.setMinimumWidth(150) label_layout.addWidget(self.period_label) label_layout.addStretch(1) self.canvas.layout.insertLayout(3, label_layout) # some image plots: viridis = generatePgColormap('viridis') inferno = generatePgColormap('inferno') magma = generatePgColormap('magma') self.origplot = self.layoutWidget.addPlot(title="Original") self.origplot.setAspectLocked() self.origplot.showAxis('bottom', False) self.origplot.showAxis('left', False) self.origimage = pg.ImageItem() self.origplot.addItem(self.origimage) self.fftplot = self.layoutWidget.addPlot(title="FFT") self.fftplot.setAspectLocked() self.fftplot.showAxis('bottom', False) self.fftplot.showAxis('left', False) self.fftimage = pg.ImageItem(lut=inferno.getLookupTable()) self.fftplot.addItem(self.fftimage) self.transformplot = self.layoutWidget.addPlot( title="Inverse transform") self.transformplot.setAspectLocked() self.transformplot.showAxis('bottom', False) self.transformplot.showAxis('left', False) self.transformimage = pg.ImageItem(lut=magma.getLookupTable()) self.transformplot.addItem(self.transformimage) self.phaseplot = self.layoutWidget.addPlot(title="Phase") self.phaseplot.setAspectLocked() self.phaseplot.showAxis('bottom', False) self.phaseplot.showAxis('left', False) self.phaseimage = pg.ImageItem(lut=viridis.getLookupTable()) self.phaseplot.addItem(self.phaseimage) self.circle_plots = [] self.workerThread = FFTWorker() self.frameAvailable.connect(self.workerThread.processFrame) self.workerThread.clearCircles.connect(self.clearCircles) self.workerThread.circle.connect(self.plotCircle) self.workerThread.orig.connect(self.setOrig) self.workerThread.fft.connect(self.setFft) self.workerThread.backtransform.connect(self.setBacktransform) self.workerThread.phase.connect(self.setPhase) self.workerThread.blobs.connect(self.setBlobsLabel) self.workerThread.blob_position.connect(self.setBlobCoords) self.workerThread.pixel_period.connect(self.setFringePeriod)