def SetData(self, data): """ Set / replace the data associated with the image. This is primarily used in the acquisition program when we want a live view of constantly updating data. It is also used for the same purpose during deconvolution. Parameters ---------- data : numpy array or PYME.IO.DataSources datasource Returns ------- """ #the data does not need to be a numpy array - it could also be, eg., queue data #on a remote server - wrap so that is is indexable like an array self.data = dataWrap.Wrap(data)
def SetDataStack(self, datasource): self.ds = dataWrap.Wrap(datasource) #make sure data is wrapped nchans = self.ds.shape[self.ds.ndim - 1] self.nz = self.ds.shape[2] if (self.ds.ndim >= 5): self.nt = self.ds.shape[3] else: self.nt = 1 if not nchans == len(self.Chans): if nchans == 1: self.Chans = [0] self.Gains = [1] self.Offs = [0] self.cmaps = [cm.gray] try: if np.iscomplexobj(self.ds[0, 0, 0, 0, 0]): self.cmaps = [cm.jet] self.cmax_offset = -np.pi self.cmax_scale = 1. / (2 * np.pi) except IndexError: pass self.show = [True] else: self.Chans = [] self.Gains = [] self.Offs = [] self.cmaps = [] self.show = [] cms = [cm.r, cm.g, cm.b] for i in range(nchans): self.Chans.append(i) self.Gains.append(1.) self.Offs.append(0.) self.cmaps.append(cms[i % len(cms)]) self.show.append(True) self.names = ['Chan %d' % i for i in range(nchans)] self.OnChange()
def OnAlignChannels(self, event): #try: # names = self.image.mdh.getEntry('ChannelNames') #except: # names = ['%d' % d for d in range(self.image.data.shape[3])] from PYME.IO.DataSources import AlignDataSource from PYME.IO import dataWrap if isinstance(self.image.data, dataWrap.ListWrapper): nd = [ AlignDataSource.DataSource(ds) for ds in self.image.data.wrapList ] else: nd = [ AlignDataSource.DataSource( dataWrap.Wrap(self.image.data[:, :, :, i])) for i in range(self.image.data.shape[3]) ] mdh = MetaDataHandler.NestedClassMDHandler(self.image.mdh) res = View3D(nd, '%s - %s' % (self.image.filename, 'align'), mdh=mdh, parent=wx.GetTopLevelParent(self.dsviewer)) res.panAlign = ShiftPanel(res) pinfo1 = aui.AuiPaneInfo().Name("shiftPanel").Right( ).Caption('Alignment').DestroyOnClose( True ).CloseButton(False).MinimizeButton(True).MinimizeMode( aui.AUI_MINIMIZE_CAPT_SMART | aui.AUI_MINIMIZE_POS_RIGHT ) #.MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False) #pinfo2 = aui.AuiPaneInfo().Name("overlayPanel").Right().Caption('Overlays').CloseButton(False).MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False) res._mgr.AddPane(res.panAlign, pinfo1) res._mgr.Update()