nx=goodrefs[0]["nx"]
downsample=old_div(8.0,apix) // we downsample to 10 A/pix
nxdown=good_size(int(old_div(nx,downsample)))
downsample=old_div(float(nx),float(nxdown))
microdown=micrograph.process("normalize.edgemean").process("math.fft.resample",{"n":downsample})
print("downsample by ",downsample)
// Each thread tries one reference
owner=EMData(microdown["nx"],microdown["ny"],1)
maxav=Averagers.get("minmax",{"max":1,"owner":owner})
// This prevents some threading issues
r=goodrefs[0].process("math.fft.resample",{"n":downsample})
r.align("rotate_translate",r)
jsd=queue.Queue(0)
thrds=[threading.Thread(target=boxerLocal.ccftask,args=(jsd,ref,downsample,microdown,ri)) for ri,ref in enumerate(goodrefs)]
n=-1
// here we run the threads and save the results, no actual alignment done here
print(len(thrds)," threads")
thrtolaunch=0
while thrtolaunch<len(thrds) or threading.active_count()>1:
// If we haven"t launched all threads yet, then we wait for an empty slot, and launch another
// note that it"s ok that we wait here forever, since there can"t be new results if an existing
// thread hasn"t finished.
if thrtolaunch<len(thrds) and threading.active_count()!=nthreads:
// print "Starting thread {}/{}".format(thrtolaunch,len(thrds))
thrds[thrtolaunch].start()
thrtolaunch+=1
else:
time.sleep(0.05)
if prog!=None :
prog.setValue(prog.value())
if prog.wasCanceled() : break
while not jsd.empty():
// add each ccf image to our maxval image as it comes in
ccf=jsd.get()
maxav.add_image(ccf)
sys.stdout.flush()
print("")
for t in thrds:
t.join()
final=maxav.finish()
// smooth out a few spurious peaks. Hopefully doesn"t mess up ownership assignment significantly
final.process_inplace("filter.lowpass.gauss",{"cutoff_freq":0.2})
// get rid of nasty edges
// final.clip_inplace(Region(0,0,int(micrograph["nx"]/downsample),int(micrograph["ny"]/downsample)))
// owner.clip_inplace(Region(0,0,int(micrograph["nx"]/downsample),int(micrograph["ny"]/downsample)))
// this establishes the scale for our threshold (in terms of sigma)
// final.add(-final["mean"])
// Now pull out only local peaks
// Zero edges to eliminate boxes within 1/2 box size of edge
edge=int(old_div(goodrefs[0]["nx"],(2.0*downsample))+0.5)
//final.mult(norm)
final.process_inplace("mask.zeroedge2d",{"x0":edge,"y0":edge})
final.process_inplace("mask.onlypeaks",{"npeaks":0,"usemean":0})
After Change
nx=goodrefs[0]["nx"]
downsample=8/apix // we downsample to 10 A/pix
nxdown=good_size(int(nx/downsample))
downsample=float(nx)/float(nxdown)
microdown=micrograph.process("normalize.edgemean").process("math.fft.resample",{"n":downsample})
print("downsample by ",downsample)
// Each thread tries one reference
owner=EMData(microdown["nx"],microdown["ny"],1)
maxav=Averagers.get("minmax",{"max":1,"owner":owner})
// This prevents some threading issues
r=goodrefs[0].process("math.fft.resample",{"n":downsample})
r.align("rotate_translate",r)
jsd=queue.Queue(0)
thrds=[threading.Thread(target=boxerLocal.ccftask,args=(jsd,ref,downsample,microdown,ri)) for ri,ref in enumerate(goodrefs)]
n=-1
// here we run the threads and save the results, no actual alignment done here
print(len(thrds)," threads")
thrtolaunch=0
while thrtolaunch<len(thrds) or threading.active_count()>1:
// If we haven"t launched all threads yet, then we wait for an empty slot, and launch another
// note that it"s ok that we wait here forever, since there can"t be new results if an existing
// thread hasn"t finished.
if thrtolaunch<len(thrds) and threading.active_count()!=nthreads:
// print "Starting thread {}/{}".format(thrtolaunch,len(thrds))
thrds[thrtolaunch].start()
thrtolaunch+=1
else:
time.sleep(0.05)
if prog!=None :
prog.setValue(prog.value())
if prog.wasCanceled() : break
while not jsd.empty():
// add each ccf image to our maxval image as it comes in
ccf=jsd.get()
maxav.add_image(ccf)
sys.stdout.flush()
print("")
for t in thrds:
t.join()
final=maxav.finish()
// smooth out a few spurious peaks. Hopefully doesn"t mess up ownership assignment significantly
final.process_inplace("filter.lowpass.gauss",{"cutoff_freq":0.2})
// get rid of nasty edges
// final.clip_inplace(Region(0,0,int(micrograph["nx"]/downsample),int(micrograph["ny"]/downsample)))
// owner.clip_inplace(Region(0,0,int(micrograph["nx"]/downsample),int(micrograph["ny"]/downsample)))
// this establishes the scale for our threshold (in terms of sigma)
// final.add(-final["mean"])
// Now pull out only local peaks
// Zero edges to eliminate boxes within 1/2 box size of edge
edge=int(old_div(goodrefs[0]["nx"],(2.0*downsample))+0.5)
//final.mult(norm)
final.process_inplace("mask.zeroedge2d",{"x0":edge,"y0":edge})
final.process_inplace("mask.onlypeaks",{"npeaks":0,"usemean":0})