コード例 #1
0
    def test_Sequence(self):
        optics = Fluorescence(
            NA=0.6,
            magnification=10,
            resolution=1e-6,
            wavelength=633e-9,
            output_region=(0, 0, 32, 32),
        )
        ellipse = Ellipse(
            position_unit="pixel",
            position=(16, 16),
            intensity=1,
            radius=(1.5e-6, 1e-6),
            rotation=0,  # This will be the value at time 0.
            upsample=2,
        )

        def get_rotation(sequence_length, previous_value):
            return previous_value + 2 * np.pi / sequence_length

        rotating_ellipse = sequences.Sequential(ellipse, rotation=get_rotation)
        imaged_rotating_ellipse = optics(rotating_ellipse)
        imaged_rotating_ellipse_sequence = sequences.Sequence(
            imaged_rotating_ellipse, sequence_length=50)
        self.assertIsInstance(imaged_rotating_ellipse_sequence,
                              sequences.Sequence)
コード例 #2
0
    def test_Generator(self):
        optics = Fluorescence(
            NA=0.7,
            wavelength=680e-9,
            resolution=1e-6,
            magnification=10,
            output_region=(0, 0, 128, 128),
        )
        scatterer = PointParticle(
            intensity=100,
            position_unit="pixel",
            position=lambda: np.random.rand(2) * 128,
        )
        imaged_scatterer = optics(scatterer)

        def get_particle_position(result):
            for property in result.properties:
                if "position" in property:
                    return property["position"]

        generator = generators.Generator()
        particle_generator = generator.generate(imaged_scatterer,
                                                get_particle_position,
                                                batch_size=4)
        particles, positions = next(particle_generator)
        for particle, position in zip(particles, positions):
            self.assertEqual(particle.shape, (128, 128, 1))
            self.assertTrue(np.all(position >= 0))
            self.assertTrue(np.all(position <= 128))
コード例 #3
0
 def testDefocus(self):
     aberrated_optics = Fluorescence(
         NA=0.3,
         resolution=1e-6,
         magnification=10,
         wavelength=530e-9,
         output_region=(0, 0, 64, 64),
         padding=(64, 64, 64, 64),
         aberration=aberrations.Defocus(coefficient=1))
     aberrated_particle = aberrated_optics(self.particle)
     for z in (-100, 0, 100):
         im = aberrated_particle.resolve(z=z)
         self.assertIsInstance(im, Image)
         self.assertEqual(im.shape, (64, 64, 1))
コード例 #4
0
 def test_Sphere(self):
     optics = Fluorescence(NA=0.7,
                           wavelength=680e-9,
                           resolution=1e-6,
                           magnification=10,
                           output_region=(0, 0, 64, 64))
     scatterer = scatterers.Sphere(intensity=100,
                                   position_unit="pixel",
                                   position=(32, 32),
                                   radius=1e-6,
                                   upsample=4)
     imaged_scatterer = optics(scatterer)
     output_image = imaged_scatterer.resolve()
     self.assertIsInstance(output_image, Image)
     self.assertEqual(output_image.shape, (64, 64, 1))
コード例 #5
0
 def test_Ellipsoid(self):
     optics = Fluorescence(
         NA=0.7,
         wavelength=680e-9,
         resolution=1e-6,
         magnification=10,
         output_region=(0, 0, 64, 64),
     )
     scatterer = scatterers.Ellipsoid(
         intensity=100,
         position_unit="pixel",
         position=(32, 32),
         radius=(1e-6, 0.5e-6, 0.25e-6),
         rotation=(np.pi / 4, 0, 0),
         upsample=4,
     )
     imaged_scatterer = optics(scatterer)
     output_image = imaged_scatterer.resolve()
     self.assertIsInstance(output_image, Image)
     self.assertEqual(output_image.shape, (64, 64, 1))