def start(self): commit = self.params['commit'] description = self.params['description'] processdir = self.params['fulltomodir'] runname = self.params['runname'] offsetz = self.params['offsetz'] subbin = self.params['bin'] invert = self.params['invert'] fulltomodata = apTomo.getFullTomoData(self.params['fulltomoId']) #subvolume making if (self.params['selexonId'] is not None or self.params['stackId']) and fulltomodata is not None: sessiondata = fulltomodata['session'] seriesname = fulltomodata['name'].rstrip('_full') fullbin = fulltomodata['bin'] if not fullbin: apDisplay.printWarning("no binning in full tomogram, something is wrong, use alignment bin for now") fullbin = fulltomodata['aligner']['alignrun']['bin'] fulltomopath = os.path.join(fulltomodata['reconrun']['path']['path'], seriesname+"_full.rec") fulltomoheader = mrc.readHeaderFromFile(fulltomopath) fulltomoshape = fulltomoheader['shape'] if self.params['sizez'] > fulltomoshape[1]*fullbin : self.params['sizez'] = fulltomoshape[1]*fullbin subrunname = self.params['subrunname'] volumeindex = apTomo.getLastVolumeIndex(fulltomodata) + 1 dimension = {'x':int(self.params['sizex']),'y':int(self.params['sizey']),'z':int(self.params['sizez'])} zprojimagedata = fulltomodata['zprojection'] apDisplay.printMsg("getting pixelsize") pixelsize = apTomo.getTomoPixelSize(zprojimagedata) * fullbin * subbin gtransform = [1,0,0,1,0,0] if self.params['selexonId']: particles = apParticle.getParticles(zprojimagedata, self.params['selexonId']) if self.params['stackId']: particles,stackparticles = apStack.getImageParticles(zprojimagedata, self.params['stackId']) stackdata = apStack.getOnlyStackData(self.params['stackId']) for p, particle in enumerate(particles): print particle['xcoord'],particle['ycoord'],fullbin center = apTomo.transformParticleCenter(particle,fullbin,gtransform) size = (dimension['x']/fullbin,dimension['y']/fullbin,dimension['z']/fullbin) volumename = 'volume%d'% (volumeindex,) volumedir = os.path.join(processdir,subrunname+'/',volumename+'/') apParam.createDirectory(volumedir) apImod.trimVolume(processdir, subrunname,seriesname,volumename,center,offsetz,size,True) long_volumename = seriesname+'_'+volumename subvolumepath = os.path.join(processdir, runname+"/",volumename+"/",long_volumename+".rec") if subbin > 1 or invert: apTomo.modifyVolume(subvolumepath,subbin,invert) if commit: subtomorundata = apTomo.insertSubTomoRun(sessiondata, self.params['selexonId'],self.params['stackId'],subrunname,invert,subbin) subtomodata = apTomo.insertSubTomogram(fulltomodata,subtomorundata, particle,offsetz,dimension, volumedir,long_volumename,volumeindex,pixelsize, description) apTomo.makeMovie(subvolumepath) apTomo.makeProjection(subvolumepath) volumeindex += 1
def recon3D(self,particle,volumeindex): processdir = self.params['fulltomodir'] subrunname = self.params['subrunname'] subbin = self.params['bin'] invert = self.params['invert'] gtransform = [1,0,0,1,0,0] size = self.getSubTomogramSize() volumename = self.setSubVolumePath(volumeindex) center = apTomo.transformParticleCenter(particle,self.fullbin,gtransform) apImod.trimVolume(processdir, subrunname,self.seriesname,volumename,center,self.params['offsetz'],size,True) offsetz = self.getOffsetZ() if subbin > 1 or invert: apTomo.modifyVolume(self.subvolumepath,subbin,invert) return size, self.params['offsetz']
def recon3D(self, particle, volumeindex): processdir = self.params['fulltomodir'] subrunname = self.params['subrunname'] subbin = self.params['bin'] invert = self.params['invert'] gtransform = [1, 0, 0, 1, 0, 0] size = self.getSubTomogramSize() volumename = self.setSubVolumePath(volumeindex) center = apTomo.transformParticleCenter(particle, self.fullbin, gtransform) apImod.trimVolume(processdir, subrunname, self.seriesname, volumename, center, self.params['offsetz'], size, True) offsetz = self.getOffsetZ() if subbin > 1 or invert: apTomo.modifyVolume(self.subvolumepath, subbin, invert) return size, self.params['offsetz']