def calculate_FOM(self): """Process the acquired images""" from numpy import zeros,sum from numimage import numimage from peak_integration import peak_integration_mask images = self.images FOM = zeros(self.scan_N) for self.Nanalyzed in range(0,self.scan_N): if self.Nanalyzed % 10 == 0: info("analysis %.f%%" % (float(self.Nanalyzed)/self.scan_N*100)) image = images[self.Nanalyzed] FOM[self.Nanalyzed] = sum(peak_integration_mask(image)*image) logfile = self.logfile logfile["FOM"] = FOM logfile.save()
def calculate_FOM_Fast(self): """Process the acquired images""" from numpy import zeros,sum,uint32 from peak_integration import peak_integration_mask images = self.images sum_image = sum(images.astype(uint32),axis=0) info("Peak mask of summed image...") mask = peak_integration_mask(sum_image) info("FOM...") FOM = zeros(self.scan_N) for self.Nanalyzed in range(0,self.scan_N): FOM[self.Nanalyzed] = sum(mask*images[self.Nanalyzed]) info("FOM done.") logfile = self.logfile logfile["FOM"] = FOM logfile.save()
def show_image(image_file): from time import time from pylab import figure,imshow,title,show,cm from numimage import numimage from peak_integration import spot_mask,peak_integration_mask from numpy import minimum from scipy.ndimage.measurements import label I0 = numimage(image_file) ROIX,ROIY,WIDTH = sample_frozen.ROIX,sample_frozen.ROIY,sample_frozen.WIDTH I = I0[ROIX:ROIX+WIDTH,ROIY:ROIY+WIDTH] # Time the 'peak_integration_mask' function. t0 = time() mask = spot_mask(I+20) info('spot_mask = %.3f [s]' %(time()-t0)) ##N_spots = mask.sum() labelled_mask,N_spots = label(mask) # Display the image. chart = figure(figsize=(8,8)) title("%s: %d spots" % (image_file,N_spots)) imshow(minimum(I,1000).T,cmap=cm.jet,origin='upper',interpolation='nearest') if N_spots != 0: # Spot integration t0 = time() SB_mask = peak_integration_mask(I) t1 = time() print "Time to find Spots and generate S_mask (s):",t1-t0 # Perform the spot integration. print "Integrated intensity: ",sum(I*SB_mask) # Display 'mask' chart = figure(figsize=(8,8)) title('SB_mask') imshow(SB_mask.T,cmap=cm.jet,origin='upper',interpolation='nearest') show()