def test_ctf2(self): """ This test requires: Download a file with one parametric CTF in EMX exchange format. Download a file with two test images in CCP4 format (these images are zero valued except in a single pixel). Their sampling rate is 2A/px Convert them to your package format. Apply the CTF to the corresponding image. Create a 2D CCP4 stack file with the two images resulting from applying the CTF to the test image The sampling of the resulting stack should be the same 2 Angstrom/pixel Upload the stack file. Three galleries of images will be displayed: the gold standard, the one just uploaded and the differences between them. The test has been successful if the gold standard and the images updated are identical. As extra check, the Web Site will make a pixel by pixel comparison between images belonging to both galleries. A green tick will appear if both images are identical and a red cross if any pair of pixels differ more than 10-2. Note: both CTFs as well as the test image have different sampling rate . The sampling rate of the output image should be 2 A/px. """ #download data self.url = "CTF/Test2/" deltaPArticle = self.downloadFile("data.mrc") emxFn = self.downloadFile("ctf2.emx") deltaParticleCTF = self.downloadFile("ctf.mrcs") #import ctf protEmxImport = self.newProtocol( ProtImportParticles, objLabel='from emx (ctfTest2)', importFrom=ProtImportParticles.IMPORT_FROM_EMX, emxFile=emxFn, alignType=3, #none? voltage=100, magnification=10000, samplingRate=2.) self.launchProtocol(protEmxImport) outputMics = getattr(protEmxImport, 'outputMicrographs', None) outputCTFs = getattr(protEmxImport, 'outputCTF', None) outputParts = getattr(protEmxImport, 'outputParticles', None) self.assertIsNotNone(outputMics) self.assertIsNotNone(outputCTFs) self.assertIsNotNone(outputParts) #split input particles protSplit = self.newProtocol( ProtSplitSet, numberOfSets=2, ) protSplit.inputSet.set(outputParts) protSplit.randomize.set(False) self.proj.launchProtocol(protSplit, wait=True) outputParts01 = getattr(protSplit, 'outputParticles01', None) outputParts02 = getattr(protSplit, 'outputParticles02', None) #filter with CTF1 protFilter1 = self.newProtocol(XmippProtFilterParticles) protFilter1.inputParticles.set(outputParts01) #protFilter1.inputCTF.set(outputCTFs) #protFilter1.inputCTF.setExtended(1) protFilter1.filterSpace.set(0) #fourier space protFilter1.filterModeFourier.set(3) #ctf self.launchProtocol(protFilter1) #filter with CTF2 protFilter2 = self.newProtocol(XmippProtFilterParticles) protFilter2.inputParticles.set(outputParts02) #protFilter2.inputCTF.set(outputCTFs) #ssprotFilter2.inputCTF.setExtended(2) protFilter2.filterSpace.set(0) #fourier space protFilter2.filterModeFourier.set(3) #ctf self.launchProtocol(protFilter2) #create a single set of particles protUnion = self.newProtocol(ProtUnionSet) protUnion.inputSets.append(protFilter1.outputParticles) protUnion.inputSets.append(protFilter2.outputParticles) self.launchProtocol(protUnion) #export as emx protEmxExport = self.newProtocol(ProtEmxExport) protEmxExport.inputSet.set(protUnion.outputSet) self.launchProtocol(protEmxExport) #TODO: upload result to emx web site. Now it is down stackFn = os.path.join(protEmxExport._getPath('emxData'), "data.mrc") self.assertTrue(ImageHandler().compareData(deltaParticleCTF, stackFn, tolerance=0.01))
def runVolumeConvertStep(self, reconstructedFilteredVolume, maskedFileName): from pyworkflow.em.convert import ImageHandler img = ImageHandler() img.convert(reconstructedFilteredVolume, maskedFileName)