def setHeader(self, header: NonDBHeader, field: str, *args, **kwargs): self.header = header self.field = field imageEvent = next(header.events(fields=['image'])) self.rc2ind = imageEvent['rc_index'] self.wavenumbers = imageEvent['wavenumbers'] # make lazy array from document data = None try: data = header.meta_array(field) self.row = data.shape[1] self.col = data.shape[2] self.txt.setPos(self.col, 0) except IndexError: msg.logMessage( 'Header object contained no frames with field ' '{field}' '.', msg.ERROR) if data is not None: # kwargs['transform'] = QTransform(1, 0, 0, -1, 0, data.shape[-2]) self.setImage(img=data, *args, **kwargs) self._data = data self._image = self._data[0]
def preview_header(self, header: NonDBHeader): try: data = header.meta_array()[0] threads.invoke_in_main_thread(self.setImage, data) except IndexError: threads.invoke_in_main_thread(self.imageitem.clear) threads.invoke_in_main_thread(self.setText, "UNKNOWN DATA FORMAT")
def preview_header(self, header: NonDBHeader): try: data = header.meta_array()[0] self.setImage(data) except IndexError: self.imageitem.clear() self.setText('UNKNOWN DATA FORMAT')
def appendHeader(self, header: NonDBHeader, **kwargs): # init item item = QStandardItem( header.startdoc.get('sample_name', '????') + '_' + str(self.headermodel.rowCount())) item.header = header item.selectedPixels = None self.headermodel.appendRow(item) self.headermodel.dataChanged.emit(QModelIndex(), QModelIndex()) # read out image shape imageEvent = next(header.events(fields=['image'])) imgShape = imageEvent['imgShape'] # get current MapView widget currentMapView = self.imageview.currentWidget() # transmit imgshape to currentMapView currentMapView.getImgShape(imgShape) # get xy coordinates of ROI selected pixels currentMapView.sigRoiPixels.connect( partial(self.appendSelection, 'pixel')) currentMapView.sigRoiState.connect(partial(self.appendSelection, 'ROI')) currentMapView.sigAutoMaskState.connect( partial(self.appendSelection, 'autoMask')) currentMapView.sigSelectMaskState.connect( partial(self.appendSelection, 'select')) self.PCA_widget.setHeader(field='spectra') self.NMF_widget.setHeader(field='volume') for i in range(4): self.PCA_widget.roiList[i].sigRegionChangeFinished.connect( self.updateROI)
def setHeader(self, header: NonDBHeader, field: str, *args, **kwargs): self.header = header self.field = field # get wavenumbers spectraEvent = next(header.events(fields=['spectra'])) self.wavenumbers = spectraEvent['wavenumbers'] self.N_w = len(self.wavenumbers) self.rc2ind = spectraEvent['rc_index'] # make lazy array from document data = None try: data = header.meta_array(field) except IndexError: msg.logMessage('Header object contained no frames with field ''{field}''.', msg.ERROR) if data is not None: # kwargs['transform'] = QTransform(1, 0, 0, -1, 0, data.shape[-2]) self._data = data
def setHeader(self, header: NonDBHeader, field: str, *args, **kwargs): self.header = header self.field = field # make lazy array from document data = None try: data = header.meta_array(field) except IndexError: msg.logMessage('Header object contained no frames with field ''{field}''.', msg.ERROR) if data: data2 = self.tempGetData(self) #super(FourDImageView, self).setData(data2, *args, **kwargs) self.setData(data2)
def setHeader(self, header: NonDBHeader, field: str, *args, **kwargs): self.header = header # make lazy array from document data = None try: data = header.meta_array(field) except IndexError as ex: msg.logMessage( f'Header object contained no frames with field "{field}".', level=msg.ERROR) msg.logError(ex) if data: # kwargs['transform'] = QTransform(0, -1, 1, 0, 0, data.shape[-2]) super(RAWViewer, self).setImage(img=data, *args, **kwargs)
def setHeader(self, header: NonDBHeader, field: str, *args, **kwargs): self.header = header self.field = field # make lazy array from document data = None try: data = header.meta_array(field) except IndexError: msg.logMessage( f'Header object contained no frames with field "{field}".', msg.ERROR) if data: # kwargs['transform'] = QTransform(1, 0, 0, -1, 0, data.shape[-2]) self.setImage(img=data, *args, **kwargs)
def pull(self, deviceitem): # instrument = Detector(pvname, name=pvname, read_attrs=['image1']) # instrument.image1.shaped_image.kind = 'normal' docs = { 'start': [], 'descriptor': [], 'event': [], 'resource': [], 'datum': [], 'stop': [] } self.RE(count([deviceitem.device_obj]), lambda doctype, doc: docs[doctype].append(doc)) return NonDBHeader(docs['start'][0], docs['descriptor'], docs['event'], docs['stop'][0])
def setHeader(self, header: NonDBHeader, field: str, *args, **kwargs): self.header = header self.field = field # make lazy array from document data = None try: data = header.meta_array(field) except IndexError: msg.logMessage( f'Header object contained no frames with field {field}.', msg.ERROR) for ii in header: msg.logMessage('header types = '.format(type(ii))) if data: # data = np.squeeze(data) #test for 1D spectra if data.ndim > 1: # kwargs['transform'] = QTransform(0, -1, 1, 0, 0, data.shape[-2]) # NOTE PAE: for setImage: # use setImage(xVals=timeVals) to set the values on the slider for 3D data try: # Retrieve the metadata for pixel scale and units descriptorsTee = itertools.tee( header.descriptors, 1)[0] # tee the descriptors generator once _ = next(descriptorsTee) # start document headerTitle, md = next( descriptorsTee) # descriptor document with metadata scale0 = (md['PhysicalSizeX'], md['PhysicalSizeY']) units0 = (md['PhysicalSizeXUnit'], md['PhysicalSizeYUnit']) except: scale0 = (1, 1) units0 = ('', '') msg.logMessage( 'EFIviewer: No pixel size or units detected') super(EFIViewerPlugin, self).setImage(img=data, scale=scale0, *args, **kwargs) self.axesItem.setLabel('bottom', text='X', units=units0[0]) self.axesItem.setLabel('left', text='Y', units=units0[1])
def appendHeader(self, header: NonDBHeader, **kwargs): # get fileName and update status bar fileName = header.startdoc.get('sample_name', '????') msg.showMessage(f'Opening {fileName}.h5') # init item item = QStandardItem(fileName + '_' + str(self.headermodel.rowCount())) item.header = header item.selectedPixels = None self.headermodel.appendRow(item) self.headermodel.dataChanged.emit(QModelIndex(), QModelIndex()) # read out image shape imageEvent = next(header.events(fields=['image'])) imgShape = imageEvent['imgShape'] rc2ind = imageEvent['rc_index'] # get current MapView widget currentMapView = self.imageview.currentWidget() # transmit imgshape to currentMapView currentMapView.getImgShape(imgShape, rc2ind) # get xy coordinates of ROI selected pixels currentMapView.sigRoiPixels.connect( partial(self.appendSelection, 'pixel')) currentMapView.sigRoiState.connect(partial(self.appendSelection, 'ROI')) currentMapView.sigAutoMaskState.connect( partial(self.appendSelection, 'autoMask')) currentMapView.sigSelectMaskState.connect( partial(self.appendSelection, 'select')) self.preprocess.setHeader(field='spectra') self.FA_widget.setHeader(field='spectra') self.clusterwidget.setHeader(field='spectra') for i in range(4): self.FA_widget.roiList[i].sigRegionChangeFinished.connect( self.updateROI) self.clusterwidget.roi.sigRegionChangeFinished.connect(self.updateROI)
def appendcatalog(header: NonDBHeader): img = header.meta_array(list(header.fields())[0]) EZTest.instance.setImage(img)
def liveacquire(self): streaming_header = NonDBHeader() self.sigOpen.emit(self.PVname.text()) self.model.dataresource.stream_to()
def pull(self, planitem: PlanItem): header = NonDBHeader() planitem.run(lambda doctype, doc: header.append(doctype, doc)) return header