Exemplo n.º 1
0
 def test_even_projections(self):
     """ Evenly distributed em2d image projections from a PDB file"""
     smodel = IMP.Model()
     ssel = IMP.atom.ATOMPDBSelector()
     prot = IMP.atom.read_pdb(self.get_input_file_name("1z5s.pdb"), smodel, ssel)
     IMP.atom.add_radii(prot)
     particles = IMP.core.get_leaves(prot)
     n_projections = 3
     rows = 80
     cols = 80
     resolution = 1
     apix = 1.5
     srw = em2d.SpiderImageReaderWriter()
     registration_values = em2d.get_evenly_distributed_registration_results(n_projections)
     options = em2d.ProjectingOptions(apix, resolution)
     projections = em2d.get_projections(particles, registration_values, rows, cols, options)
     # Read the stored projections
     stored_projection_names = em2d.create_filenames(n_projections, "1z5s-fast-projection", "spi")
     for n in xrange(0, n_projections):
         stored_projection_names[n] = self.get_input_file_name(stored_projection_names[n])
     stored_projections = em2d.read_images(stored_projection_names, srw)
     # check
     for n in xrange(0, n_projections):
         for i in xrange(0, rows):
             for j in xrange(0, cols):
                 self.assertAlmostEqual(
                     projections[n](i, j),
                     stored_projections[n](i, j),
                     delta=0.001,
                     msg="Projections generated and stored are different",
                 )
Exemplo n.º 2
0
 def test_even_projections(self):
     """ Evenly distributed em2d image projections from a PDB file"""
     smodel = IMP.Model()
     ssel = IMP.atom.ATOMPDBSelector()
     prot = IMP.atom.read_pdb(self.get_input_file_name("1z5s.pdb"),
                              smodel, ssel)
     IMP.atom.add_radii(prot)
     particles = IMP.core.get_leaves(prot)
     n_projections = 3
     rows = 80
     cols = 80
     resolution = 1
     apix = 1.5
     srw = em2d.SpiderImageReaderWriter()
     registration_values = em2d.get_evenly_distributed_registration_results(
         n_projections)
     options = em2d.ProjectingOptions(apix, resolution)
     projections = em2d.get_projections(particles,
                                        registration_values, rows, cols, options)
     # Read the stored projections
     stored_projection_names = em2d.create_filenames(
         n_projections, "1z5s-fast-projection", "spi")
     for n in range(0, n_projections):
         stored_projection_names[n] = self.get_input_file_name(
             stored_projection_names[n])
     stored_projections = em2d.read_images(stored_projection_names, srw)
     # check
     for n in range(0, n_projections):
         for i in range(0, rows):
             for j in range(0, cols):
                 self.assertAlmostEqual(projections[n](i, j),
                                        stored_projections[n](i, j), delta=0.001,
                                        msg="Projections generated and stored are different")
import IMP
import IMP.em2d as em2d
import os
"""
    Conversion of Electron Microscopy Images.

"""

# Read images
fn_selection=em2d.get_example_path("all-1z5s-projections.sel")

srw = em2d.SpiderImageReaderWriter()
trw = em2d.TIFFImageReaderWriter()
fn_images=em2d.read_selection_file(fn_selection)
fn_images = [em2d.get_example_path(x) for x in fn_images]
images = em2d.read_images(fn_images,srw)
# write
fn_saved=em2d.create_filenames(3,"1z5s-projection","tif")
em2d.save_images(images,fn_saved,trw)
Exemplo n.º 4
0
## \example em2d/em_images_conversion.py
# Conversion of Electron Microscopy Images.
#

import IMP
import IMP.em2d as em2d
import os
"""
    Conversion of Electron Microscopy Images.

"""

# Read images
fn_selection = em2d.get_example_path("all-1z5s-projections.sel")

srw = em2d.SpiderImageReaderWriter()
trw = em2d.TIFFImageReaderWriter()
fn_images = em2d.read_selection_file(fn_selection)
fn_images = [em2d.get_example_path(x) for x in fn_images]
images = em2d.read_images(fn_images, srw)
# write
fn_saved = em2d.create_filenames(3, "1z5s-projection", "tif")
em2d.save_images(images, fn_saved, trw)