def binAndAddCTFlabel(self, image, ht, rpixelsize, binning=1, defocus=None):
         pow = imagefun.power(image)
         binned = imagefun.bin(pow, binning)
         # No ctf estimation until it works better so that this node does not
         # depend on coma beam-tilt calibration
         s = None
         ctfdata = None
         '''
         try:
                 ctfdata = fftfun.fitFirstCTFNode(pow,rpixelsize['x'], defocus, ht)
         except Exception, e:
                 self.logger.error("ctf fitting failed: %s" % e)
                 ctfdata = None
         if ctfdata:
                 self.logger.info('z0 %.3f um, zast %.3f um (%.0f ), angle= %.1f deg' % (ctfdata[0]*1e6,ctfdata[1]*1e6,ctfdata[2]*100, ctfdata[3]*180.0/math.pi))
                 s = '%d' % int(ctfdata[0]*1e9)
         #elif self.ace2exe:
         elif False:
                 ctfdata = self.estimateCTF(imagedata)
                 z0 = (ctfdata['defocus1'] + ctfdata['defocus2']) / 2
                 s = '%d' % (int(z0*1e9),)
         '''
         if s:
                 t = numpil.textArray(s)
                 t = ndimage.zoom(t, (min(binned.shape)-40.0)*0.08/(t.shape)[0])
                 minvalue = arraystats.min(binned)
                 maxvalue = arraystats.max(binned)
                 t = minvalue + t * (maxvalue-minvalue)
                 imagefun.pasteInto(t, binned, (20,20))
         return binned, ctfdata
def wxBitmapFromNumarray(n, min=None, max=None, color=False):
        if min is None or max is None:
                min = arraystats.min(n)
                max = arraystats.max(n)
        wximage = wx.EmptyImage(n.shape[1], n.shape[0])
        if color:
                wximage.SetData(numextension.rgbstring(n, float(min), float(max), colormap))
        else:
                wximage.SetData(numextension.rgbstring(n, float(min), float(max)))
        return wx.BitmapFromImage(wximage)
def wxBitmapFromNumarray(n, min=None, max=None, color=False):
    if min is None or max is None:
        min = arraystats.min(n)
        max = arraystats.max(n)
    wximage = wx.EmptyImage(n.shape[1], n.shape[0])
    if color:
        wximage.SetData(
            numextension.rgbstring(n, float(min), float(max), colormap))
    else:
        wximage.SetData(numextension.rgbstring(n, float(min), float(max)))
    return wx.BitmapFromImage(wximage)
    def setStatistics(self, array=None, statistics={}):
        try:
            mean = statistics['mean']
        except KeyError:
            if array is None:
                mean = None
            else:
                mean = arraystats.mean(array)
        try:
            min = statistics['min']
        except KeyError:
            if array is None:
                min = None
            else:
                min = arraystats.min(array)
        try:
            max = statistics['max']
        except KeyError:
            if array is None:
                max = None
            else:
                max = arraystats.max(array)
        try:
            sd = statistics['stdev']
        except KeyError:
            if array is None:
                sd = None
            else:
                sd = arraystats.std(array)

        if mean is None:
            meanstr = ''
        else:
            meanstr = '%g' % mean
        if min is None:
            minstr = ''
        else:
            minstr = '%g' % min
        if max is None:
            maxstr = ''
        else:
            maxstr = '%g' % max 
        if sd is None:
            sdstr = ''
        else:
            sdstr = '%g' % sd

        self.meanlabel.SetLabel(meanstr)
        self.minlabel.SetLabel(minstr)
        self.maxlabel.SetLabel(maxstr)
        self.sdlabel.SetLabel(sdstr)

        self.sizer.Layout()
    def setStatistics(self, array=None, statistics={}):
        try:
            mean = statistics['mean']
        except KeyError:
            if array is None:
                mean = None
            else:
                mean = arraystats.mean(array)
        try:
            min = statistics['min']
        except KeyError:
            if array is None:
                min = None
            else:
                min = arraystats.min(array)
        try:
            max = statistics['max']
        except KeyError:
            if array is None:
                max = None
            else:
                max = arraystats.max(array)
        try:
            sd = statistics['stdev']
        except KeyError:
            if array is None:
                sd = None
            else:
                sd = arraystats.std(array)

        if mean is None:
            meanstr = ''
        else:
            meanstr = '%g' % mean
        if min is None:
            minstr = ''
        else:
            minstr = '%g' % min
        if max is None:
            maxstr = ''
        else:
            maxstr = '%g' % max
        if sd is None:
            sdstr = ''
        else:
            sdstr = '%g' % sd

        self.meanlabel.SetLabel(meanstr)
        self.minlabel.SetLabel(minstr)
        self.maxlabel.SetLabel(maxstr)
        self.sdlabel.SetLabel(sdstr)

        self.sizer.Layout()
Exemplo n.º 6
0
    def binAndAddCTFlabel(self,
                          image,
                          ht,
                          cs,
                          rpixelsize,
                          binning=1,
                          defocus=None):
        pow = imagefun.power(image)
        binned = imagefun.bin(pow, binning)
        # No ctf estimation until it works better so that this node does not
        # depend on coma beam-tilt calibration
        s = None
        ctfdata = None
        '''
		try:
			ctfdata = fftfun.fitFirstCTFNode(pow,rpixelsize['x'], defocus, ht, cs)
		except Exception, e:
			self.logger.error("ctf fitting failed: %s" % e)
			ctfdata = None
		if ctfdata:
			self.logger.info('z0 %.3f um, zast %.3f um (%.0f ), angle= %.1f deg' % (ctfdata[0]*1e6,ctfdata[1]*1e6,ctfdata[2]*100, ctfdata[3]*180.0/math.pi))
			s = '%d' % int(ctfdata[0]*1e9)
		#elif self.ace2exe:
		elif False:
			ctfdata = self.estimateCTF(imagedata)
			z0 = (ctfdata['defocus1'] + ctfdata['defocus2']) / 2
			s = '%d' % (int(z0*1e9),)
		'''
        if s:
            t = numpil.textArray(s)
            t = ndimage.zoom(t,
                             (min(binned.shape) - 40.0) * 0.08 / (t.shape)[0])
            minvalue = arraystats.min(binned)
            maxvalue = arraystats.max(binned)
            t = minvalue + t * (maxvalue - minvalue)
            imagefun.pasteInto(t, binned, (20, 20))
        return binned, ctfdata
 def _process(self, input):
         min = arraystats.min(input.image)
         max = arraystats.max(input.image)
         cutoff = (max - min) / self.cutoff.get()
         return self.outputclass(input.image,
                                                                                                         imagefun.threshold(input.image, cutoff))
Exemplo n.º 8
0
		except Exception, e:
			self.logger.error("ctf fitting failed: %s" % e)
			ctfdata = None
		if ctfdata:
			self.logger.info('z0 %.3f um, zast %.3f um (%.0f ), angle= %.1f deg' % (ctfdata[0]*1e6,ctfdata[1]*1e6,ctfdata[2]*100, ctfdata[3]*180.0/math.pi))
			s = '%d' % int(ctfdata[0]*1e9)
		#elif self.ace2exe:
		elif False:
			ctfdata = self.estimateCTF(imagedata)
			z0 = (ctfdata['defocus1'] + ctfdata['defocus2']) / 2
			s = '%d' % (int(z0*1e9),)
		if s:
			t = numpil.textArray(s)
			t = ndimage.zoom(t, (min(binned.shape)-40.0)*0.08/(t.shape)[0])
			minvalue = arraystats.min(binned)
			maxvalue = arraystats.max(binned)
			t = minvalue + t * (maxvalue-minvalue)
			imagefun.pasteInto(t, binned, (20,20))
		return binned, ctfdata

	def estimateCTF(self, imagedata):
		mag = imagedata['scope']['magnification']
		tem = imagedata['scope']['tem']
		cam = imagedata['camera']['ccdcamera']
		pixelsize = self.btcalclient.getPixelSize(mag, tem, cam)
		inputparams = {
			'input': os.path.join(imagedata['session']['image path'],imagedata['filename']+".mrc"),
			'cs': 2.0,
			'kv': imagedata['scope']['high tension']/1000.0,
			'apix': pixelsize*1e10,
			'binby': 1,
Exemplo n.º 9
0
 def _process(self, input):
     min = arraystats.min(input.image)
     max = arraystats.max(input.image)
     cutoff = (max - min) / self.cutoff.get()
     return self.outputclass(input.image,
                             imagefun.threshold(input.image, cutoff))