1 """
2 Patterns based on patches of Sine Gratings as used in experiments.
3
4 $Id: teststimuli.py 8001 2008-02-18 15:15:10Z ceball $
5 """
6 __version__='$Revision: 8001 $'
7
8
9
10
11
12
13 import numpy
14
15 from topo.patterns.basic import SineGrating, Disk, Ring
16 from math import pi, sin, cos, sqrt
17 from numpy.oldnumeric import around,bitwise_and,sin,add,Float,bitwise_or
18 from numpy import alltrue
19
20 from topo.base.parameterizedobject import ParamOverrides
21 from topo.base.parameterclasses import Integer, Number, Parameter, Enumeration
22 from topo.base.parameterclasses import ListParameter
23 from topo.base.patterngenerator import PatternGenerator
24
25
26 from topo.base.patterngenerator import Constant
27
28 from topo.misc.patternfns import gaussian,gabor,line,disk,ring
29 from topo.misc.numbergenerators import UniformRandom
30 from topo.base.parameterclasses import BooleanParameter
31
32
33
35 """A sine grating masked by a circular disk so that only a round patch is visible."""
36
37 aspect_ratio = Number(default=1.0,bounds=(0.0,None),softbounds=(0.0,2.0),
38 precedence=0.31,doc=
39 "Ratio of width to height; size*aspect_ratio gives the width of the disk.")
40
41 size = Number(default=0.5,doc="Top to bottom height of the disk")
42
43 smoothing = Number(default=0.0,bounds=(0.0,None),softbounds=(0.0,0.5),
44 precedence=0.61,doc="Width of the Gaussian fall-off")
45
46 phase = Number(default=1.0, doc="phase of the sine grating")
47
48 frequency = Number(default=2.4,doc="frequency of the sine grating")
49
50
51 - def __call__(self,**params_to_override):
52 params = ParamOverrides(self,params_to_override)
53 bounds = params['bounds']
54 xdensity=params['xdensity']
55 ydensity=params['ydensity']
56 x=params['x']
57 y=params['y']
58 scale=params['scale']
59 offset=params['offset']
60 orientation=params['orientation']
61 size=params['size']
62 phase=params['phase']
63 frequency=params['frequency']
64 aspect_ratio=params['aspect_ratio']
65 smoothing=params['smoothing']
66
67 input_1=SineGrating(phase=phase, frequency=frequency, orientation=orientation, scale=scale, offset=offset)
68 input_2=Disk(aspect_ratio=aspect_ratio,smoothing=smoothing,x=x, y=y,size=size,scale=scale, offset=offset)
69
70 patterns = [input_1(xdensity=xdensity,ydensity=ydensity,bounds=bounds),
71 input_2(xdensity=xdensity,ydensity=ydensity,bounds=bounds)]
72
73 image_array = numpy.minimum.reduce(patterns)
74 return image_array
75
76
77
79 """A sine grating masked by a ring so that only the ring is visible."""
80
81 aspect_ratio = Number(default=1.0,bounds=(0.0,None),softbounds=(0.0,2.0),
82 precedence=0.31,doc=
83 "Ratio of width to height; size*aspect_ratio gives the overall width.")
84
85 thickness = Number(default=0.015,bounds=(0.0,None),softbounds=(0.0,0.5),
86 precedence=0.60,doc="Thickness (line width) of the ring.")
87
88 size = Number(default=0.5,doc="Top to bottom height of the disk")
89
90 smoothing = Number(default=0.0,bounds=(0.0,None),softbounds=(0.0,0.5),
91 precedence=0.61,doc="Width of the Gaussian fall-off")
92
93 phase = Number(default=1.0, doc="phase of the sine grating")
94
95 frequency = Number(default=2.4,doc="frequency of the sine grating")
96
97
98 - def __call__(self,**params_to_override):
99
100 params = ParamOverrides(self,params_to_override)
101
102 bounds = params['bounds']
103 xdensity=params['xdensity']
104 ydensity=params['ydensity']
105 x=params['x']
106 y=params['y']
107 scale=params['scale']
108 offset=params['offset']
109 orientation=params['orientation']
110 size=params['size']
111 phase=params['phase']
112 frequency=params['frequency']
113 aspect_ratio=params['aspect_ratio']
114 smoothing=params['smoothing']
115 thickness=params['thickness']
116
117 input_1=SineGrating(phase=phase, frequency=frequency, orientation=orientation, scale=scale, offset=offset)
118 input_2=Ring(thickness=thickness,aspect_ratio=aspect_ratio,smoothing=smoothing,x=x, y=y,size=size,scale=scale, offset=offset)
119
120 patterns = [input_1(xdensity=xdensity,ydensity=ydensity,bounds=bounds),
121 input_2(xdensity=xdensity,ydensity=ydensity,bounds=bounds)]
122
123 image_array = numpy.minimum.reduce(patterns)
124 return image_array
125
126
127
128
130 """A sine grating ring and a disk with parameters (orientation and size) which can be changed independantly"""
131
132 orientationcentre= Number(default=1.0,bounds=(0.0,None),softbounds=(0.0,10.0),
133 precedence=0.50, doc="Frequency of the sine grating.")
134
135 orientationsurround= Number(default=1.0,bounds=(0.0,None),softbounds=(0.0,10.0),
136 precedence=0.50, doc="Frequency of the sine grating.")
137
138 size_centre= Number(default=1.0,bounds=(0.0,None),softbounds=(0.0,10.0),
139 precedence=0.50, doc="Frequency of the sine grating.")
140
141 size_surround= Number(default=1.0,bounds=(0.0,None),softbounds=(0.0,10.0),