def makevol(options, originalseriesfile, newseries, it, originalangles, originalsize, writevols=1, initialfsc=0): #print "Newseries received in makevol and its type are", type(newseries) #print newseries #sys.exit() mode = 'gauss_2' if options.reconstructor: if len(options.reconstructor) > 1: if 'mode' in options.reconstructor[-1]: try: if options.reconstructor[-1]['mode'] != 'gauss_2': mode = options.reconstructor[-1]['mode'] else: pass except: pass box = originalsize if options.pad3d: if options.pad2d: if options.pad3d > options.pad2d: box = int(box * options.pad3d) else: box = int(box * options.pad2d) else: box = int(box * options.pad3d) elif options.pad2d: box = int(box * options.pad2d) #if options.verbose > 5: #print "\nPPPPPPPPPPPPPPP\n\n(e2spt_isr.py)(makevol) Because there's options.pad=%f,then newsize=%d" % ( options.pad3d, newsize ) #if options.verbose > 9: #print "\n(e2spt_isr.py)(makevol) Mode for reconstructor is", mode #print "Setting up reconstructor; options.reconstructor is", options.reconstructor #print "For volume of size",box,box,box #rEven = Reconstructors.get(options.reconstructor[0],{'size':(box,box,box),'sym':'c1','verbose':True,'mode':mode}) r = Reconstructors.get(options.reconstructor[0], { 'size': (box, box, box), 'sym': 'c1', 'verbose': False, 'mode': mode }) r.setup() #print "in isr reconstructor is", options.reconstructor #print "r is", r #print "and box was", box axis = 'y' if options.tiltaxis: axis = options.tiltaxis angles = [] #print "\n++++++++++++++++++++++++++++++\n(makevol) file=%s, lowmostRAWangle=%f, upmostRAWangle=%f" % ( originalseriesfile, min(originalangles), max(originalangles) ) #print "However, adding projections, the total number of images and angles will be", len(newseries),len(originalangles) #print "\n++++++++++++++++++++++++++++++\n" apix = 1.0 imageslist = [] for tiltangle in originalangles: #print "Angle and type are", tiltangle, type(tiltangle) img = newseries[tiltangle] #try: # if img['spt_tiltangle']: # pass #except: img['xform.projection'] = Transform({ 'type': 'eman', 'az': 90, 'alt': float(tiltangle), 'phi': -90 }) img2send = img.copy() imageslist.append(img2send) #print "size of image appended to imageslist", img2send['nx'],img2send['ny'] apix = img['apix_x'] angle = None if options.verbose > 9: print( "\n(e2spt_isr.py)(makevol) processing image %d in stack %s and ITERATION %d" % (i, originalseriesfile, it)) print( "For image %d, mean=%f, min=%f, max=%f, std=%f" % (i, img['mean'], img['minimum'], img['maximum'], img['sigma'])) if options.pad2d and float(options.pad2d) > 1.0: box2d = img['nx'] * options.pad2d img = clip2D(img, box2d) #print "\nPadding prj to newsize", newsize try: angle = img['spt_tiltangle'] except: print( "\nWARNING: 'spt_tiltangle' parameter not found in the header of image %d in file %s" % (i, f)) #sys.exit() angle = tiltangle print("Using this tiltangle", tiltangle) try: axis = img['spt_tiltaxis'] except: if options.verbose > 9: print( """\n(e2spt_isr.py)(makevol) WARNING: No spt_tiltaxis or sptsim_tiltaxis found in header. Default used.""", options.tiltaxis, axis) if angle != None: #angles.append( angle ) t = Transform({'type': 'eman', 'az': 90, 'alt': angle, 'phi': -90}) if axis == 'x': t = Transform({'type': 'eman', 'alt': angle}) imgp = r.preprocess_slice(img, t) weight = 1.0 if options.verbose > 9: print("\n(makevol) ITER=%d, tiltangle=%f, weight=%f" % (it, angle, weight)) print("Inserted IMAGE with this tranform", t) #print "transform used for WHOLE 3D", t r.insert_slice(imgp, t, weight) rec = r.finish(True) rec['apix_x'] = apix rec['apix_y'] = apix rec['apix_z'] = apix rec['origin_x'] = 0 rec['origin_y'] = 0 rec['origin_z'] = 0 #angles.sort() #if options.verbose > 9: # print "\n(e2spt_fillwedge.py)(makevol) Sorted angles to write to header are", angles rec['spt_tiltangles'] = originalangles recxc = old_div(rec['nx'], 2) recyc = old_div(rec['ny'], 2) reczc = old_div(rec['nz'], 2) #R2 = Region( (2*recxc - originalsize)/2, (2*recyc - originalsize)/2, (2*reczc - originalsize)/2, originalsize , originalsize , originalsize) #rec.clip_inplace( R2 ) outx = outy = outz = originalsize if options.outxsize: outx = options.outxsize if options.outysize: outy = options.outysize if options.outzsize: outz = options.outzsize rec = clip3D(rec, outx, outy, outz) rec.process_inplace('normalize') if options.verbose > 9: print("\n(e2spt_isr.py)(makevol) Reconstructed volume for file", originalseriesfile) volfile = '' if options.savevols and writevols: volfile = os.path.basename(originalseriesfile).replace( '.hdf', '_ISR3D.hdf') if options.path not in volfile: volfile = options.path + '/' + volfile rec.write_image(volfile, 0) #print "size of images in imageslist to send is", imageslist[0]['nx'],imageslist[-1]['ny'] ret = genOddAndEvenVols(options, originalseriesfile, imageslist) volOdd = ret[1] volEven = ret[0] score3d = ret[2] #volOdd.write_image( options.path + '/' + originalseriesfile.replace('.hdf','_ISR3D_ODD.hdf') ) #volEven.write_image( options.path + '/' + originalseriesfile.replace('.hdf','_ISR3D_EVEN.hdf') ) filebasetoplotfsc = originalseriesfile if it == 0: print("There SHOULD be intialfsc", initialfsc) if initialfsc: print("There is intialfsc", initialfsc) filebasetoplotfsc = originalseriesfile.replace('.hdf', '_INITIAL.hdf') retfsc = fscOddVsEven(options, filebasetoplotfsc, volOdd, volEven) fsc = retfsc[0] fscarea = retfsc[1] aliscore = [] return [rec, volfile, fscarea, score3d]
def makevol(options, originalseriesfile, newseries, it, originalangles, originalsize, writevols=1, initialfsc=0): # print "Newseries received in makevol and its type are", type(newseries) # print newseries # sys.exit() mode = "gauss_2" if options.reconstructor: if len(options.reconstructor) > 1: if "mode" in options.reconstructor[-1]: try: if options.reconstructor[-1]["mode"] != "gauss_2": mode = options.reconstructor[-1]["mode"] else: pass except: pass box = originalsize if options.pad3d: if options.pad2d: if options.pad3d > options.pad2d: box = int(box * options.pad3d) else: box = int(box * options.pad2d) else: box = int(box * options.pad3d) elif options.pad2d: box = int(box * options.pad2d) # if options.verbose > 5: # print "\nPPPPPPPPPPPPPPP\n\n(e2spt_isr.py)(makevol) Because there's options.pad=%f,then newsize=%d" % ( options.pad3d, newsize ) # if options.verbose > 9: # print "\n(e2spt_isr.py)(makevol) Mode for reconstructor is", mode # print "Setting up reconstructor; options.reconstructor is", options.reconstructor # print "For volume of size",box,box,box # rEven = Reconstructors.get(options.reconstructor[0],{'size':(box,box,box),'sym':'c1','verbose':True,'mode':mode}) r = Reconstructors.get( options.reconstructor[0], {"size": (box, box, box), "sym": "c1", "verbose": False, "mode": mode} ) r.setup() # print "in isr reconstructor is", options.reconstructor # print "r is", r # print "and box was", box axis = "y" if options.tiltaxis: axis = options.tiltaxis angles = [] # print "\n++++++++++++++++++++++++++++++\n(makevol) file=%s, lowmostRAWangle=%f, upmostRAWangle=%f" % ( originalseriesfile, min(originalangles), max(originalangles) ) # print "However, adding projections, the total number of images and angles will be", len(newseries),len(originalangles) # print "\n++++++++++++++++++++++++++++++\n" apix = 1.0 imageslist = [] for tiltangle in originalangles: # print "Angle and type are", tiltangle, type(tiltangle) img = newseries[tiltangle] # try: # if img['spt_tiltangle']: # pass # except: img["xform.projection"] = Transform({"type": "eman", "az": 90, "alt": float(tiltangle), "phi": -90}) img2send = img.copy() imageslist.append(img2send) # print "size of image appended to imageslist", img2send['nx'],img2send['ny'] apix = img["apix_x"] angle = None if options.verbose > 9: print "\n(e2spt_isr.py)(makevol) processing image %d in stack %s and ITERATION %d" % ( i, originalseriesfile, it, ) print "For image %d, mean=%f, min=%f, max=%f, std=%f" % ( i, img["mean"], img["minimum"], img["maximum"], img["sigma"], ) if options.pad2d and float(options.pad2d) > 1.0: box2d = img["nx"] * options.pad2d img = clip2D(img, box2d) # print "\nPadding prj to newsize", newsize try: angle = img["spt_tiltangle"] except: print "\nWARNING: 'spt_tiltangle' parameter not found in the header of image %d in file %s" % (i, f) # sys.exit() angle = tiltangle print "Using this tiltangle", tiltangle try: axis = img["spt_tiltaxis"] except: if options.verbose > 9: print """\n(e2spt_isr.py)(makevol) WARNING: No spt_tiltaxis or sptsim_tiltaxis found in header. Default used.""", options.tiltaxis, axis if angle != None: # angles.append( angle ) t = Transform({"type": "eman", "az": 90, "alt": angle, "phi": -90}) if axis == "x": t = Transform({"type": "eman", "alt": angle}) imgp = r.preprocess_slice(img, t) weight = 1.0 if options.verbose > 9: print "\n(makevol) ITER=%d, tiltangle=%f, weight=%f" % (it, angle, weight) print "Inserted IMAGE with this tranform", t # print "transform used for WHOLE 3D", t r.insert_slice(imgp, t, weight) rec = r.finish(True) rec["apix_x"] = apix rec["apix_y"] = apix rec["apix_z"] = apix rec["origin_x"] = 0 rec["origin_y"] = 0 rec["origin_z"] = 0 # angles.sort() # if options.verbose > 9: # print "\n(e2spt_fillwedge.py)(makevol) Sorted angles to write to header are", angles rec["spt_tiltangles"] = originalangles recxc = rec["nx"] / 2 recyc = rec["ny"] / 2 reczc = rec["nz"] / 2 # R2 = Region( (2*recxc - originalsize)/2, (2*recyc - originalsize)/2, (2*reczc - originalsize)/2, originalsize , originalsize , originalsize) # rec.clip_inplace( R2 ) outx = outy = outz = originalsize if options.outxsize: outx = options.outxsize if options.outysize: outy = options.outysize if options.outzsize: outz = options.outzsize rec = clip3D(rec, outx, outy, outz) rec.process_inplace("normalize") if options.verbose > 9: print "\n(e2spt_isr.py)(makevol) Reconstructed volume for file", originalseriesfile volfile = "" if options.savevols and writevols: volfile = os.path.basename(originalseriesfile).replace(".hdf", "_ISR3D.hdf") if options.path not in volfile: volfile = options.path + "/" + volfile rec.write_image(volfile, 0) # print "size of images in imageslist to send is", imageslist[0]['nx'],imageslist[-1]['ny'] ret = genOddAndEvenVols(options, originalseriesfile, imageslist) volOdd = ret[1] volEven = ret[0] score3d = ret[2] # volOdd.write_image( options.path + '/' + originalseriesfile.replace('.hdf','_ISR3D_ODD.hdf') ) # volEven.write_image( options.path + '/' + originalseriesfile.replace('.hdf','_ISR3D_EVEN.hdf') ) filebasetoplotfsc = originalseriesfile if it == 0: print "There SHOULD be intialfsc", initialfsc if initialfsc: print "There is intialfsc", initialfsc filebasetoplotfsc = originalseriesfile.replace(".hdf", "_INITIAL.hdf") retfsc = fscOddVsEven(options, filebasetoplotfsc, volOdd, volEven) fsc = retfsc[0] fscarea = retfsc[1] aliscore = [] return [rec, volfile, fscarea, score3d]