示例#1
0
 def load_data(self):
     self.data, self.fname, self.node_path = browse_data(ret_all=True)
     if self.data is not None:
         self.settings.child('xaxis', 'xoffset').setValue(
             (-self.data.shape[1] / 2))
         self.settings.child('yaxis', 'yoffset').setValue(
             (-self.data.shape[0] / 2))
         self.viewer2D.setImage(self.data)
         self.viewer2D.ui.Show_histogram.click()
         self.viewer2D.ui.roiBtn.click()
         self.viewer2D.ui.ROIs_widget.setVisible(False)
         QtWidgets.QApplication.processEvents()
 def load_calibration(self, fname):
     (root, ext) = os.path.splitext(fname)
     if 'h5' in ext:
         self.calibration = h5browser.browse_data(
             fname
         )  #phase values corresponding to grey levels (256 elements in array)
     elif 'txt' in ext or 'dat' in ext:
         self.calibration = np.loadtxt(
             fname)[:, 1]  # to update in order to select what data in file
     else:
         self.calibration = None
         self.emit_status(
             ThreadCommand('Update_Status',
                           ['No calibration has been loaded', 'log']))
示例#3
0
    def load_image(self):
        #image_filepath = str(utils.select_file(start_path=None, save=False, ext='h5'))
        data, fname, node_path = browse_data(ret_all=True)
        if data is not None and fname != '':
            self.h5file_image = tables.open_file(fname)
            node = self.h5file_image.get_node(node_path)
            pixmaps = utils.get_h5file_scans(self.h5file_image, node._v_parent)
            self.settings.child('settings', 'imagepath').setValue(fname)
            other_child = [
                child for child in self.settings.child(('scans')).children()
                if 'Scan' not in child.name()
            ]
            if len(other_child) >= 1:
                for child in other_child:
                    self.settings.child(('scans')).removeChild(child)
            params = []
            for pixmap in pixmaps:
                params.append({
                    'name':
                    pixmap['scan_name'],
                    'type':
                    'pixmap_check',
                    'value':
                    dict(data=pixmap['data'],
                         checked=False,
                         path=pixmap['path'])
                })
            self.settings.child(('scans')).addChildren(params)

            val = self.settings.child('scans', pixmaps[0]['scan_name']).value()
            val.update(dict(checked=True))
            self.settings.child('scans', pixmaps[0]['scan_name']).setValue(val)
            self.settings.child(
                'scans', pixmaps[0]['scan_name']).sigValueChanged.emit(
                    self.settings.child('scans', pixmaps[0]['scan_name']),
                    self.settings.child('scans',
                                        pixmaps[0]['scan_name']).value())
    def move_Abs(self, position):
        """
            Make the absolute move from the given position after thread command signal was received in DAQ_Move_main.

            =============== ========= =======================
            **Parameters**  **Type**   **Description**

            *position*       float     The absolute position
            =============== ========= =======================

            See Also
            --------
            DAQ_Move_base.set_position_with_scaling, DAQ_Move_base.poll_moving

        """
        try:
            position = self.check_bound(position)
            #position=self.set_position_with_scaling(position)
            #print(position)
            self.target_position = position
            if self.settings.child(('shaping_type')).value() == 'FullScreen':
                self.controller.showBlankscreen(grayValue=position)
            elif self.settings.child(
                ('shaping_type')).value() == 'SplitScreen':
                if self.settings.child('splitting', 'split_control').value(
                ) == 'Screen spliting':  #,'GreyA','GreyB']
                    screenDivider = position
                else:
                    screenDivider = self.settings.child(
                        'splitting', 'split_value').value()
                if self.settings.child('splitting',
                                       'split_control').value() == 'GreyA':
                    a_gray_value = int(position)
                else:
                    a_gray_value = self.settings.child('splitting',
                                                       'greyA_value').value()
                if self.settings.child('splitting',
                                       'split_control').value() == 'GreyB':
                    b_gray_value = int(position)
                else:
                    b_gray_value = self.settings.child('splitting',
                                                       'greyB_value').value()

                flipped = self.settings.child('splitting',
                                              'split_flip').value()

                if self.settings.child('splitting',
                                       'split_dir').value() == 'Vertical':
                    self.controller.showDividedScreenVertical(
                        a_gray_value, b_gray_value, screenDivider, flipped)
                else:
                    self.controller.showDividedScreenHorizontal(
                        a_gray_value, b_gray_value, screenDivider, flipped)
            elif self.settings.child(('shaping_type')).value() == 'File':
                fname = str(select_file(start_path=None, save=False, ext='h5'))
                data = h5browser.browse_data(fname)

                if self.settings.child('calibration', 'calib_apply').value(
                ) and self.calibration is not None:
                    data = np.reshape(
                        np.interp(data.reshape(np.prod(data.shape)),
                                  self.calibration,
                                  np.linspace(0, 255, 256)).astype('uint8'),
                        data.shape)

                dataWidth = self.controller.width_px
                dataHeight = self.controller.height_px
                # Calculate the data:
                for indy in range(dataHeight):
                    for indx in range(dataWidth):
                        self.data_uchar[indy, indx] = data[indy, indx]

                if data is None:
                    raise Exception('No data has been selected')
                else:
                    self.controller.showData(self.data_uchar)

            self.current_position = position  #+np.random.rand()-0.5
            self.poll_moving()
        except Exception as e:
            self.emit_status(
                ThreadCommand('Update_Status',
                              [getLineInfo() + str(e), 'log']))