def _getRecalCommand(self, ctfModel, **kwargs): line = ctfModel.getObjComment().split() params = self.getRecalCtfParamsDict(ctfModel) # get the size and the image of psd imgPsd = ctfModel.getPsdFile() imgh = em.ImageHandler() size, _, _, _ = imgh.getDimensions(imgPsd) mic = ctfModel.getMicrograph() # Convert digital frequencies to spatial frequencies sampling = mic.getSamplingRate() params['step_focus'] = 1000.0 params['sampling'] = sampling params['lowRes'] = sampling / float(line[3]) params['highRes'] = sampling / float(line[4]) params['minDefocus'] = min([float(line[0]), float(line[1])]) params['maxDefocus'] = max([float(line[0]), float(line[1])]) params['astigmatism'] = self.astigmatism.get() params['windowSize'] = size params['pixelAvg'] = 1 # set to 1 since we have our own downsampling params['tiltAngle'] = self.tiltA.get() params['tiltR'] = self.tiltR.get() params.update(kwargs) return self._getCommandFromParams(params)
def getCommand(self, **kwargs): """ Return the program and arguments to be run. The input keywords argument should contain key-values for one micrograph or group of micrographs. """ params = dict(self._params) params.update(kwargs) return self._getProgram(), self._args % params
def _prepareRecalCommand(self, ctfModel): if self.recalculate: self._defineRecalValues(ctfModel) self._createFilenameTemplates() self._program = 'xmipp_ctf_estimate_from_psd_fast' self._args = "--psd %(psdFn)s " line = ctfModel.getObjComment().split() # get the size and the image of psd imgPsd = ctfModel.getPsdFile() psdFile = os.path.basename(imgPsd) imgh = ImageHandler() size, _, _, _ = imgh.getDimensions(imgPsd) mic = ctfModel.getMicrograph() micDir = self._getMicrographDir(mic) downFactor = self._calculateDownsampleList( mic.getSamplingRate())[0] params = dict(self.getCtfParamsDict()) params.update(self.getRecalCtfParamsDict()) # FIXME Where does this variable come from params.update({'psdFn': fnPsd, 'defocusU': float(line[0])}) # Mapping between base protocol parameters and the package specific # command options self.__params = { 'sampling_rate': params['samplingRate'], 'downSamplingPerformed': downFactor, 'kV': params['voltage'], 'Cs': params['sphericalAberration'], 'min_freq': line[3], 'max_freq': line[4], 'defocusU': params['defocusU'], 'Q0': params['ampContrast'], 'defocus_range': 5000, 'ctfmodelSize': size } if self.findPhaseShift: fnCTFparam = self._getFileName('ctfParam', micBase=self._getMicBase(mic)) mdCTFParam = md.MetaData(fnCTFparam) phase_shift = mdCTFParam.getValue(md.MDL_CTF_PHASE_SHIFT, mdCTFParam.firstObject()) self.__params['VPP_radius'] = 0.005 self.__params['phase_shift'] = phase_shift for par, val in self.__params.items(): self._args += " --%s %s" % (par, str(val))
def _getCommand(self, **kwargs): params = self.getCtfParamsDict() # Convert digital frequencies to spatial frequencies sampling = params['samplingRate'] params['lowRes'] = sampling / params['lowRes'] if params['lowRes'] > 50: params['lowRes'] = 50 params['highRes'] = sampling / params['highRes'] params['astigmatism'] = self.astigmatism.get() params['step_focus'] = 500.0 params['pixelAvg'] = 1 # set to 1 since we have our own downsampling params['tiltAngle'] = self.tiltA.get() params['tiltR'] = self.tiltR.get() params.update(kwargs) return self._getCommandFromParams(params)
def _writeRefinementScripts(self, protType): """ Write the needed scripts to run refinement and substitute some values. """ refPath = self._getExtraPath('Refinement') pwutils.makePath(refPath) def path(p): """ Escape path with '' and add ../ """ return "'%s'" % join('..', p) def script(name, paramsDict={}, protType=protType): if protType == DEF_GROUPS: dirName = 'defocus-groups' else: dirName = 'no-defocus-groups' outputScript = join(refPath, name) writeScript( Plugin.getScript('projmatch', 'Refinement', dirName, name), outputScript, paramsDict) nIter = self.numberOfIterations.get() def getListStr(valueStr): return "'%s'" % ','.join(pwutils.getListFromValues( valueStr, nIter)) diam = int(self.radius.get() * 2 * self.inputParticles.get().getSamplingRate()) params = { '[alignsh]': self.alignmentShift.get(), # shrange was renamed to alignsh in new versions '[shrange]': self.alignmentShift.get(), '[iter-end]': self.numberOfIterations.get(), '[diam]': diam, '[win-frac]': self.winFrac.get(), # '[converg]': self.convergence.get(), '[small-ang]': '1' if self.smallAngle else '0', '[ang-steps]': getListStr(self.angSteps.get()), '[ang-limits]': getListStr(self.angLimits.get()), '[ang-step-sm]': "'(%0.2f)'" % self.angStepSm.get(), '[theta-range]': "'(%0.2f)'" % self.thetaRange.get(), '[vol_orig]': path('ref_vol'), '[sel_group_orig]': path('sel_group'), '[sel_particles_orig]': path('group{***[grp]}_selfile'), '[group_align_orig]': path('group{***[grp]}_align'), '[unaligned_images_orig]': path('group{***[grp]}_stack'), '[out_align]': path('stack_alignment') } if self.protType == GOLD_STD: params.update({ 'sphdecon': self.sphDeconAngle.get(), 'bp-type': self.bpType.get() + 1 }) script('refine_settings.pam', params, protType=protType) if protType == DEF_GROUPS: scriptList = [ 'refine', 'prepare', 'grploop', 'mergegroups', 'enhance', 'endmerge', 'smangloop', 'endrefine' ] else: scriptList = [ 'refine', 'refine-setrefangles', 'refine-prjrefs', 'refine-loop', 'refine-smangloop', 'refine-bp', 'merge-fsc-filt', 'sphdecon', 'enhance', 'show-r2' ] for s in scriptList: script('%s.pam' % s)