def postProcessingRecon(self):
     # Full tomogram created with imod is left-handed XZY
     voltransform = 'flipx'
     origtomopath = os.path.join(self.params['rundir'],
                                 self.seriesname + "_full.rec")
     currenttomopath = apImod.transformVolume(origtomopath, voltransform)
     shutil.move(currenttomopath, origtomopath)
 def start(self):
     cleanlist = []
     # imod needs the recon files named as .rec  It may need some fix later
     if self.params["name"] is None:
         self.setNewFileName()
     apDisplay.printColor("Naming tomogram as: " + self.params["name"], "cyan")
     newtomopath = os.path.join(self.params["rundir"], self.params["name"] + ".rec")
     origtomopath = self.params["file"]
     origxfpath = self.params["oldxffile"]
     apParam.createDirectory(self.params["aligndir"])
     newxfpath = os.path.join(self.params["aligndir"], self.params["newxffile"])
     order = self.params["order"]
     voltransform = self.params["transform"]
     bin = self.params["bin"]
     self.getImageShapeFromTiltSeries()
     self.getOriginalVolumeShape()
     if os.path.isfile(newtomopath):
         uploaded_before = self.checkExistingFile()
         if uploaded_before:
             return
     else:
         currenttomopath = origtomopath
         if self.params["full"]:
             ### full tomogram upload, may need to pad to the image size
             if self.params["order"] == "XZY" and not voltransform:
                 apDisplay.printMsg("Default full tomogram orientation with original handness")
             else:
                 if voltransform:
                     apDisplay.printMsg("Transforming original tomogram....")
                     currenttomopath = apImod.transformVolume(origtomopath, voltransform)
                     cleanlist.append(currenttomopath)
             ### padding the XZY tomogram to the image size
             currentheader = mrc.readHeaderFromFile(currenttomopath)
             currentshape = currentheader["shape"]
             currentxyshape = currentshape[0], currentshape[2]
             imageshape = self.imageshape
             if currentxyshape[0] < imageshape[0] / bin or currentxyshape[1] < imageshape[1] / bin:
                 currenttomopath = apImod.pad(currenttomopath, currentxyshape, imageshape, bin, "XZY")
                 cleanlist.append(currenttomopath)
         else:
             ### subtomogram simple upload, just copy file to Tomo folder
             if self.params["order"] == "XYZ" and not voltransform:
                 apDisplay.printMsg("Default sub tomogram orientation")
             else:
                 if voltransform:
                     apDisplay.printMsg("Transforming original tomogram....")
                     currenttomopath = apImod.transformVolume(origtomopath, voltransform)
                     cleanlist.append(currenttomopath)
         ### simple upload, just copy file to Tomo folder
         apDisplay.printMsg("Copying original tomogram to a new location: " + newtomopath)
         shutil.copyfile(currenttomopath, newtomopath)
         if origxfpath and os.path.isfile(origxfpath):
             apDisplay.printMsg("Copying original alignment to a new location: " + newxfpath)
             shutil.copyfile(origxfpath, newxfpath)
         if self.params["image"]:
             shutil.copyfile(self.params["image"], self.params["rundir"] + "/snapshot.png")
     ### inserting tomogram
     tomoheader = mrc.readHeaderFromFile(newtomopath)
     self.params["shape"] = tomoheader["shape"]
     if self.params["full"]:
         seriesname = "%s_%03d" % (self.params["sessionname"], self.params["tiltseriesnumber"])
         self.params["zprojfile"] = apImod.projectFullZ(
             self.params["rundir"], self.params["runname"], seriesname, bin, True, False
         )
     else:
         apTomo.makeMovie(newtomopath)
         apTomo.makeProjection(newtomopath)
     apTomo.uploadTomo(self.params)
     ### clean up
     for tmpfilepath in cleanlist:
         apFile.removeFile(tmpfilepath)
Пример #3
0
 def start(self):
     cleanlist = []
     # imod needs the recon files named as .rec  It may need some fix later
     if self.params['name'] is None:
         self.setNewFileName()
     apDisplay.printColor("Naming tomogram as: " + self.params['name'],
                          "cyan")
     newtomopath = os.path.join(self.params['rundir'],
                                self.params['name'] + ".rec")
     origtomopath = self.params['file']
     origxfpath = self.params['oldxffile']
     apParam.createDirectory(self.params['aligndir'])
     newxfpath = os.path.join(self.params['aligndir'],
                              self.params['newxffile'])
     order = self.params['order']
     voltransform = self.params['transform']
     bin = self.params['bin']
     self.getImageShapeFromTiltSeries()
     self.getOriginalVolumeShape()
     if os.path.isfile(newtomopath):
         uploaded_before = self.checkExistingFile()
         if uploaded_before:
             return
     else:
         currenttomopath = origtomopath
         if self.params['full']:
             ### full tomogram upload, may need to pad to the image size
             if self.params['order'] == 'XZY' and not voltransform:
                 apDisplay.printMsg(
                     "Default full tomogram orientation with original handness"
                 )
             else:
                 if voltransform:
                     apDisplay.printMsg(
                         "Transforming original tomogram....")
                     currenttomopath = apImod.transformVolume(
                         origtomopath, voltransform)
                     cleanlist.append(currenttomopath)
             ### padding the XZY tomogram to the image size
             currentheader = mrc.readHeaderFromFile(currenttomopath)
             currentshape = currentheader['shape']
             currentxyshape = currentshape[0], currentshape[2]
             imageshape = self.imageshape
             if currentxyshape[0] < imageshape[0] / bin or currentxyshape[
                     1] < imageshape[1] / bin:
                 currenttomopath = apImod.pad(currenttomopath,
                                              currentxyshape, imageshape,
                                              bin, 'XZY')
                 cleanlist.append(currenttomopath)
         else:
             ### subtomogram simple upload, just copy file to Tomo folder
             if self.params['order'] == 'XYZ' and not voltransform:
                 apDisplay.printMsg("Default sub tomogram orientation")
             else:
                 if voltransform:
                     apDisplay.printMsg(
                         "Transforming original tomogram....")
                     currenttomopath = apImod.transformVolume(
                         origtomopath, voltransform)
                     cleanlist.append(currenttomopath)
         ### simple upload, just copy file to Tomo folder
         apDisplay.printMsg(
             "Copying original tomogram to a new location: " + newtomopath)
         shutil.copyfile(currenttomopath, newtomopath)
         if origxfpath and os.path.isfile(origxfpath):
             apDisplay.printMsg(
                 "Copying original alignment to a new location: " +
                 newxfpath)
             shutil.copyfile(origxfpath, newxfpath)
         if self.params['image']:
             shutil.copyfile(self.params['image'],
                             self.params['rundir'] + '/snapshot.png')
     ### inserting tomogram
     tomoheader = mrc.readHeaderFromFile(newtomopath)
     self.params['shape'] = tomoheader['shape']
     if self.params['full']:
         seriesname = "%s_%03d" % (self.params['sessionname'],
                                   self.params['tiltseriesnumber'])
         self.params['zprojfile'] = apImod.projectFullZ(
             self.params['rundir'], self.params['runname'], seriesname, bin,
             True, False)
     else:
         apTomo.makeMovie(newtomopath)
         apTomo.makeProjection(newtomopath)
     apTomo.uploadTomo(self.params)
     ### clean up
     for tmpfilepath in cleanlist:
         apFile.removeFile(tmpfilepath)
 def postProcessingRecon(self):
     # Full tomogram created with imod is left-handed XZY
     voltransform = "flipx"
     origtomopath = os.path.join(self.params["rundir"], self.seriesname + "_full.rec")
     currenttomopath = apImod.transformVolume(origtomopath, voltransform)
     shutil.move(currenttomopath, origtomopath)