Example #1
0
 def frames(self):
     self.current_phase = 0
     while True:
         center = imagen.SineGrating(
             mask_shape=imagen.pattern.Disk(smoothing=0.0,
                                            size=self.center_radius * 2),
             orientation=self.center_orientation,
             frequency=self.spatial_frequency,
             phase=self.current_phase,
             bounds=BoundingBox(radius=self.size_x / 2),
             offset=self.background_luminance * (100.0 - self.contrast) /
             100.0,
             scale=2 * self.background_luminance * self.contrast / 100.0,
             xdensity=self.density,
             ydensity=self.density)()
         r = (self.center_radius + self.surround_radius + self.gap) / 2
         t = (self.surround_radius - self.surround_radius - self.gap) / 2
         surround = imagen.SineGrating(
             mask_shape=imagen.pattern.Ring(thickness=t,
                                            smoothing=0,
                                            size=r * 2),
             orientation=self.surround_orientation,
             frequency=self.spatial_frequency,
             phase=self.current_phase,
             bounds=BoundingBox(radius=self.size_x / 2),
             offset=self.background_luminance * (100.0 - self.contrast) /
             100.0,
             scale=2 * self.background_luminance * self.contrast / 100.0,
             xdensity=self.density,
             ydensity=self.density)()
         yield (numpy.add.reduce([center, surround]), [self.current_phase])
         self.current_phase += 2 * pi * (self.frame_duration /
                                         1000.0) * self.temporal_frequency
def SineG(x, y, BlackBackground, phase_shift, Bound,frames):

    orientations = [i * np.pi /8 for i in range(8)]
    frequencies = [1.0 ,2.0, 4.0, 8.0, 12.0, 16.0]
    phase = np.pi/2
    paras = [[[ori, fre, phase]] for ori in orientations for fre in frequencies]

    if phase_shift:
        paras = pert.modulation_of_phase(paras,'SG',frames)
    else:
        frames = 1

    # generates images and saved into a numpy array
    SG = np.empty([len(paras), frames], dtype=np.object)
    idx_proto = 0
    for pars in paras:
        idx_shift = 0
        for p in pars:
            SG[idx_proto][idx_shift] = ig.SineGrating(bounds=Bound, phase=p[2], orientation=p[0],
                                      frequency=p[1], xdensity=x, ydensity=y)()

            if BlackBackground:
                assert SG[idx_proto][idx_shift].max() <= 1.0 and SG[idx_proto][idx_shift].min() >= 0
                SG[idx_proto][idx_shift] = 1 - SG[idx_proto][idx_shift]
            idx_shift += 1
        idx_proto += 1
    return SG
Example #3
0
    def frames(self):
        self.current_phase = 0
        while True:
            a = imagen.SineGrating(orientation=self.orientation,
                                   frequency=self.spatial_frequency,
                                   phase=self.current_phase,
                                   bounds=BoundingBox(radius=self.size_x / 2),
                                   offset=self.background_luminance *
                                   (100.0 - self.contrast) / 100.0,
                                   scale=2 * self.background_luminance *
                                   self.contrast / 100.0,
                                   xdensity=self.density,
                                   ydensity=self.density)()

            b = imagen.Null(scale=self.background_luminance,
                            bounds=BoundingBox(radius=self.size_x / 2),
                            xdensity=self.density,
                            ydensity=self.density)()
            c = imagen.Disk(smoothing=0.0,
                            size=self.radius * 2,
                            scale=1.0,
                            bounds=BoundingBox(radius=self.size_x / 2),
                            xdensity=self.density,
                            ydensity=self.density)()
            d1 = numpy.multiply(a, c)
            d2 = numpy.multiply(b, -(c - 1.0))
            d = numpy.add.reduce([d1, d2])
            yield (d, [self.current_phase])
            self.current_phase += 2 * pi * (self.frame_duration /
                                            1000.0) * self.temporal_frequency
Example #4
0
    def frames(self):

        f = open(self.eye_path_location, 'r')
        self.eye_path = pickle.load(f)
        self.time = 0
        self.current_phase = 0
        while True:
            location = self.eye_path[int(
                numpy.floor(self.frame_duration * self.time /
                            self.eye_movement_period))]

            image = imagen.SineGrating(
                orientation=self.orientation,
                x=location[0],
                y=location[1],
                frequency=self.spatial_frequency,
                phase=self.current_phase,
                bounds=BoundingBox(points=((-self.size_x / 2,
                                            -self.size_y / 2),
                                           (self.size_x / 2,
                                            self.size_y / 2))),
                offset=self.background_luminance * (100.0 - self.contrast) /
                100.0,
                scale=2 * self.background_luminance * self.contrast / 100.0,
                xdensity=self.density,
                ydensity=self.density)()
            self.current_phase += 2 * pi * (self.frame_duration /
                                            1000.0) * self.temporal_frequency
            yield (image, [self.time])
            self.time = self.time + 1
Example #5
0
    def frames(self):
        self.current_phase = 0
        i = 0
        t = 0
        while True:
            i += 1
            st = imagen.SineGrating(orientation=self.orientation,
                                    frequency=self.spatial_frequency,
                                    phase=self.current_phase,
                                    bounds=BoundingBox(radius=self.size_x / 2),
                                    offset=self.background_luminance *
                                    (100.0 - self.contrast) / 100.0,
                                    scale=2 * self.background_luminance *
                                    self.contrast / 100.0,
                                    xdensity=self.density,
                                    ydensity=self.density)()
            if t > self.offset_time:
                st = st * 0 + self.background_luminance
            if t < self.onset_time:
                st = st * 0 + self.background_luminance

            yield (st, [self.current_phase])
            self.current_phase += 2 * pi * (self.frame_duration /
                                            1000.0) * self.temporal_frequency
            t = t + self.frame_duration
def SineG(x, y, BlackBackground, jetter, Bound):
    # creates parameter list
    orientations = [i * np.pi / 12 for i in range(12)]
    frequencies = [3, 6, 12]
    of = list(itertools.product(orientations, frequencies))
    if jetter:
        of = pert.modulation_of_jetter(of, 'SG')

    # generates images and saved into a numpy array
    SG = np.empty(len(of), dtype=np.object)
    idx = 0
    for ith_of in of:
        SG[idx] = ig.SineGrating(bounds=Bound,
                                 phase=np.pi / 2,
                                 orientation=ith_of[0],
                                 frequency=ith_of[1],
                                 xdensity=x,
                                 ydensity=y)()
        # SG[idx] = ig.SineGrating(bounds=Bound, phase=0, orientation=ith_of[0],
        #                           frequency=ith_of[1], xdensity=x, ydensity=y)()

        if BlackBackground:
            assert SG[idx].max() <= 1.0 and SG[idx].min() >= 0
            SG[idx] = 1 - SG[idx]
        idx += 1
    return SG
Example #7
0
    def frames(self):
        self.current_phase = 0
        while True:
            r = (self.inner_appareture_radius +
                 self.outer_appareture_radius) / 2.0
            t = (self.outer_appareture_radius -
                 self.inner_appareture_radius) / 2.0
            ring = imagen.SineGrating(
                mask_shape=imagen.Ring(thickness=t * 2.0,
                                       smoothing=0.0,
                                       size=r * 2.0),
                orientation=self.orientation,
                frequency=self.spatial_frequency,
                phase=self.current_phase,
                bounds=BoundingBox(radius=self.size_x / 2.0),
                offset=0,
                scale=2 * self.background_luminance * self.contrast / 100.0,
                xdensity=self.density,
                ydensity=self.density)()

            bg = imagen.Constant(bounds=BoundingBox(radius=self.size_x / 2.0),
                                 scale=self.background_luminance,
                                 xdensity=self.density,
                                 ydensity=self.density)()

            correction = imagen.Ring(smoothing=0.0,
                                     thickness=t * 2.0,
                                     size=r * 2.0,
                                     scale=-self.background_luminance,
                                     bounds=BoundingBox(radius=self.size_x /
                                                        2.0),
                                     xdensity=self.density,
                                     ydensity=self.density)()

            yield (numpy.add.reduce([ring, bg,
                                     correction]), [self.current_phase])
            self.current_phase += 2 * pi * (self.frame_duration /
                                            1000.0) * self.temporal_frequency