def createCtfPlot(ctfSet, ctfId): from pyworkflow.utils.path import removeExt ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = removeExt(psdFn) + "_avrot.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'pixels^-1', 'CTF', yformat=False) legendName = [] for i in range(1, 5): _plotCurve(a, i, fn) if i == 1: legendName.append('rotational avg. No Astg') elif i == 2: legendName.append('rotational avg.') elif i == 3: legendName.append('CTF Fit') elif i == 4: legendName.append('Cross Correlation') elif i == 5: legendName.append('2sigma cross correlation of noise') xplotter.showLegend(legendName) a.grid(True) xplotter.show()
def importTomogramsStep(self, pattern, samplingRate): """ Copy images matching the filename pattern Register other parameters. """ self.info("Using pattern: '%s'" % pattern) # Create a Volume template object tomo = Tomogram() tomo.setSamplingRate(samplingRate) imgh = ImageHandler() tomoSet = self._createSetOfTomograms() tomoSet.setSamplingRate(samplingRate) self._parseAcquisitionData() for fileName, fileId in self.iterFiles(): x, y, z, n = imgh.getDimensions(fileName) if fileName.endswith('.mrc') or fileName.endswith('.map'): fileName += ':mrc' if z == 1 and n != 1: zDim = n n = 1 else: zDim = z else: zDim = z origin = Transform() if self.setOrigCoord.get(): origin.setShiftsTuple(self._getOrigCoord()) else: origin.setShifts(x / -2. * samplingRate, y / -2. * samplingRate, zDim / -2. * samplingRate) tomo.setOrigin(origin) # read origin from form newFileName = _getUniqueFileName(self.getPattern(), fileName.split(':')[0]) tsId = removeExt(newFileName) tomo.setTsId(tsId) if fileName.endswith(':mrc'): fileName = fileName[:-4] createAbsLink(fileName, abspath(self._getExtraPath(newFileName))) tomo.setAcquisition(self._extractAcquisitionParameters(fileName)) if n == 1: # One volume per file tomo.cleanObjId() tomo.setFileName(self._getExtraPath(newFileName)) tomoSet.append(tomo) else: # A stack of volumes per file (not common) for index in range(1, n + 1): tomo.cleanObjId() tomo.setLocation(index, self._getExtraPath(newFileName)) tomoSet.append(tomo) self._defineOutputs(outputTomograms=tomoSet)
def importCTF(self, mic, fileName): defocusU, defocusV, defocusAngle = parseCtffindOutput(fileName) ctf = CTFModel() ctf.copyObjId(mic) ctf.setStandardDefocus(defocusU, defocusV, defocusAngle) ctf.setMicrograph(mic) ctf.setPsdFile(removeExt(fileName) + "_psd.mrc") return ctf
def _getMovieRoot(self, movie): # Try to use the 'original' fileName in case it is present # the original could be different from the current filename if # we are dealing with compressed movies (e.g., movie.mrc.bz2) fn = movie.getAttributeValue('_originalFileName', movie.getFileName()) # Remove the first extension fnRoot = pwutils.removeBaseExt(fn) # Check if there is a second extension # (Assuming is is only a dot and 3 or 4 characters after it if fnRoot[-4] == '.' or fnRoot[-5] == '.': fnRoot = pwutils.removeExt(fnRoot) return fnRoot
def getUniqueFileName(fn, extension): """ Get an unique file for either link or convert files. It is possible that the base name overlap if they come from different runs. (like partices.mrcs after relion preprocess) """ newFn = join(outputDir, replaceBaseExt(fn, extension)) newRoot = removeExt(newFn) values = filesDict.values() counter = 1 while newFn in values: counter += 1 newFn = '%s_%05d.%s' % (newRoot, counter, extension) return newFn
def run_custom_mask_spider(request): imagePath = removeExt(request.GET.get('image', None)) radius1 = request.GET.get('radius1', None) sdFactor = request.GET.get('sdFactor', None) radius2 = request.GET.get('radius2', None) maskThreshold = request.GET.get('maskThreshold', None) runCustomMaskScript(radius1, sdFactor, radius2, maskThreshold, ".", inputImage=imagePath) # print "imagePath:",imagePath # print "os.getcwd: ", os.getcwd() return HttpResponse(mimetype='application/javascript')
def runJob(self, log, programName, params, numberOfMpi=1, numberOfThreads=1, env=None, cwd=None): threadId = threading.current_thread().thId submitDict = dict(self.hostConfig.getQueuesDefault()) submitDict.update(self.submitDict) submitDict['JOB_COMMAND'] = process.buildRunCommand( programName, params, numberOfMpi, self.hostConfig, env, gpuList=self.getGpuList()) self.threadCommands[threadId] += 1 subthreadId = '-%s-%s' % (threadId, self.threadCommands[threadId]) submitDict['JOB_NAME'] = submitDict['JOB_NAME'] + subthreadId submitDict['JOB_SCRIPT'] = os.path.abspath( removeExt(submitDict['JOB_SCRIPT']) + subthreadId + ".job") submitDict['JOB_LOGS'] = os.path.join( getParentFolder(submitDict['JOB_SCRIPT']), submitDict['JOB_NAME']) jobid = _submit(self.hostConfig, submitDict, cwd, env) if (jobid is None) or (jobid == UNKNOWN_JOBID): print("jobId is none therefore we set it to fail") raise Exception("Failed to submit to queue.") status = cts.STATUS_RUNNING wait = 3 # Check status while job running # REVIEW this to minimize the overhead in time put by this delay check while self._checkJobStatus(self.hostConfig, jobid) == cts.STATUS_RUNNING: time.sleep(wait) if wait < 300: wait += 3 return status
def createCtfPlot(ctfSet, ctfId): ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = removeExt(psdFn) + "_avrot.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'pixels^-1', 'CTF', yformat=False) legendName = ['rotational avg. No Astg', 'rotational avg.', 'CTF Fit', 'Cross Correlation', '2sigma cross correlation of noise'] for i in range(1, 6): _plotCurve(a, i, fn) xplotter.showLegend(legendName) a.grid(True) xplotter.show()
def createCtfPlot(ctfSet, ctfId): ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = removeExt(psdFn) + "_avrot.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'pixels^-1', 'CTF', yformat=False) legendName = [ 'rotational avg. No Astg', 'rotational avg.', 'CTF Fit', 'Cross Correlation', '2sigma cross correlation of noise' ] for i in range(1, 6): _plotCurve(a, i, fn) xplotter.showLegend(legendName) a.grid(True) xplotter.show()