def makeDenoisedParticleJPGFrames(self,partdatas,shiftdata,shortname):
         '''
         Denoise the boxed particles and then read in the resulting frame stack of the particle for saving as movie frames.
         '''
         if not partdatas:
                 return
         if not self.is_dd_stack:
                 apDisplay.printError('Denoising works only with ddstack for now')
         imgdata = partdatas[0]['image']
         ddstackdir,stackfile = self.getDDStackDirFile(imgdata)
         framestacks = []
         for p,partdata in enumerate(partdatas):
                 # denoise within the particle box
                 col_start,row_start = apBoxer.getBoxStartPosition(imgdata,self.half_box,partdata, shiftdata)
                 row_end = row_start + self.boxsize
                 col_end = col_start + self.boxsize
                 roi = ((row_start,row_end),(col_start,col_end))
                 paramstr = self.denoise.setupKSVDdenoise(self.frameavg,self.firstframe,self.nframe,roi)
                 apDisplay.printMsg('denoise param string: %s' % paramstr)
                 self.denoise.makeDenoisedStack(ddstackdir, stackfile)
                 outputstackfile = '%s_%s.mrc' % (stackfile[:-4], paramstr)
                 framestacks.append(outputstackfile)
         for i,start_frame in enumerate(range(self.firstframe,self.nframe-self.frameavg-self.firstframe+1,self.framestep)):
                 for p,partdata in enumerate(partdatas):
                         array = mrc.read(os.path.join(self.params['rundir'],'results/mrc',framestacks[p]),i)
                         # bin is not used for now
                         movieframe_number = start_frame
                         self.saveFrameFromArray(array,shortname,p,movieframe_number)
Esempio n. 2
0
 def makeParticleJPGFrames(self, partdatas, shiftdata, shortname):
     '''
             Make corrected frame images and then box off the particles.
             '''
     imgdata = partdatas[0]['image']
     for start_frame in range(
             self.firstframe,
             self.nframe - self.frameavg - self.firstframe + 1,
             self.framestep):
         if self.is_dd_frame:
             corrected = self.dd.correctFrameImage(start_frame,
                                                   self.frameavg)
         else:
             ddstackdir, stackfile = self.getDDStackDirFile(imgdata)
             corrected = self.dd.getDDStackFrameSumImage(
                 start_frame, self.frameavg)
         for p, partdata in enumerate(partdatas):
             col_start, row_start = apBoxer.getBoxStartPosition(
                 imgdata, self.half_box, partdata, shiftdata)
             row_end = row_start + self.boxsize
             col_end = col_start + self.boxsize
             array = corrected[row_start:row_end, col_start:col_end]
             # bin is not used for now
             movieframe_number = start_frame
             self.saveFrameFromArray(array, shortname, p, movieframe_number)
	def removeBoxOutOfImage(self,imgdata,partdatas,shiftdata):
		imgdims = imgdata['camera']['dimension']
		newpartdatas = []
		for partdata in partdatas:
			start_x,start_y = apBoxer.getBoxStartPosition(imgdata,self.half_box,partdata, shiftdata)
			if apBoxer.checkBoxInImage(imgdims,start_x,start_y,self.boxsize):
				newpartdatas.append(partdata)
		return newpartdatas
 def removeBoxOutOfImage(self, imgdata, partdatas, shiftdata):
     imgdims = imgdata['camera']['dimension']
     newpartdatas = []
     for partdata in partdatas:
         start_x, start_y = apBoxer.getBoxStartPosition(
             imgdata, self.half_box, partdata, shiftdata)
         if apBoxer.checkBoxInImage(imgdims, start_x, start_y,
                                    self.boxsize):
             newpartdatas.append(partdata)
     return newpartdatas
 def makeParticleJPGFrames(self,partdatas,shiftdata,shortname):
         '''
         Make corrected frame images and then box off the particles.
         '''
         imgdata = partdatas[0]['image']
         for start_frame in range(self.firstframe,self.nframe-self.frameavg-self.firstframe+1,self.framestep):
                 if self.is_dd_frame:
                         corrected = self.dd.correctFrameImage(start_frame,self.frameavg)
                 else:
                         ddstackdir,stackfile = self.getDDStackDirFile(imgdata)
                         corrected = self.dd.getDDStackFrameSumImage(start_frame,self.frameavg)
                 for p,partdata in enumerate(partdatas):
                         col_start,row_start = apBoxer.getBoxStartPosition(imgdata,self.half_box,partdata, shiftdata)
                         row_end = row_start + self.boxsize
                         col_end = col_start + self.boxsize
                         array = corrected[row_start:row_end,col_start:col_end]
                         # bin is not used for now
                         movieframe_number = start_frame
                         self.saveFrameFromArray(array,shortname,p,movieframe_number)
Esempio n. 6
0
 def makeDenoisedParticleJPGFrames(self, partdatas, shiftdata, shortname):
     '''
             Denoise the boxed particles and then read in the resulting frame stack of the particle for saving as movie frames.
             '''
     if not partdatas:
         return
     if not self.is_dd_stack:
         apDisplay.printError('Denoising works only with ddstack for now')
     imgdata = partdatas[0]['image']
     ddstackdir, stackfile = self.getDDStackDirFile(imgdata)
     framestacks = []
     for p, partdata in enumerate(partdatas):
         # denoise within the particle box
         col_start, row_start = apBoxer.getBoxStartPosition(
             imgdata, self.half_box, partdata, shiftdata)
         row_end = row_start + self.boxsize
         col_end = col_start + self.boxsize
         roi = ((row_start, row_end), (col_start, col_end))
         paramstr = self.denoise.setupKSVDdenoise(self.frameavg,
                                                  self.firstframe,
                                                  self.nframe, roi)
         apDisplay.printMsg('denoise param string: %s' % paramstr)
         self.denoise.makeDenoisedStack(ddstackdir, stackfile)
         outputstackfile = '%s_%s.mrc' % (stackfile[:-4], paramstr)
         framestacks.append(outputstackfile)
     for i, start_frame in enumerate(
             range(self.firstframe,
                   self.nframe - self.frameavg - self.firstframe + 1,
                   self.framestep)):
         for p, partdata in enumerate(partdatas):
             array = mrc.read(
                 os.path.join(self.params['rundir'], 'results/mrc',
                              framestacks[p]), i)
             # bin is not used for now
             movieframe_number = start_frame
             self.saveFrameFromArray(array, shortname, p, movieframe_number)