The most important picture in vision science
What do you think is the most important picture in vision science? Not a masterpiece, not a photograph. One good answer is a plain stripe pattern whose brightness rises and falls smoothly. That may sound disappointingly dull. But such a grating has a wonderful property: it is described completely by just a few numbers, namely its contrast, its tilt, its speed and its fineness, known as spatial frequency.
What matters in an experiment is that someone else can reproduce exactly what you showed. "Something stripy" will never let you compare an experiment in Tokyo with one in London. This simulation is a tool for describing gratings, Gabor patches, circles and rectangles entirely with numbers and formulas and putting them on the screen. Change a formula and the stimulus starts to move. As you build stimuli yourself, you will get a feel for how experiments on seeing are designed.
Drawing a picture as a function of time
Inside the editor every stimulus is a bundle of parameters: position x and y, rotation angle, opacity, plus size and stripe settings depending on the type. In each parameter field you can type a formula instead of a number. If the x field says 300 + 100 * sin(90 * t), the stimulus swings left and right around x = 300, completing one swing every 4 seconds, because t is the elapsed real time in seconds.
The screen is redrawn dozens of times per second. Each time, every formula is evaluated with the current t and the stimuli are drawn again. So what you are writing is a picture as a function of time. Instead of drawing film frames one by one, you write the rule for how things look at every moment. The editor itself, which reads and evaluates your formulas, is a small example of parsing in programming.
To draw many copies with one rule, raise the number of copies. The variable i then takes the values 0, 1, 2, …, so y = 300 + 80 * sin(90 * t + 36 * i) produces dots that bob up and down with a small delay from one to the next: a wave. Each dot only moves up and down, yet the wave travels sideways. The physics of "the medium oscillates while the wave travels" shows up here too.
Writing formulas in this editor is practice with mathematical functions. Make both x and y formulas in t and a point moves along a parametric curve. With x = 300 + 100 * cos(90 * t) and y = 300 + 100 * sin(90 * t) it traces a circle; double one of the frequencies and you get a Lissajous figure. The graphs from your math textbook appear here as motion.
Why plain stripes?
Why should plain stripes matter so much? Just as any sound can be written as a sum of sine waves of different pitches, any image can be written as a sum of sine-wave gratings of different fineness, orientation and position. This is Fourier analysis. So knowing how we respond to the basic building block, the sine grating, gives a foothold for understanding how we see any picture. The brightness of a sine grating, with the position across the stripes and the time, can be written
where is the spatial frequency in cycles per pixel, the temporal frequency in hertz and the phase. In this editor the two colors , and the contrast set
These come from one requirement: with , the darkest stripes should be exactly and the brightest exactly . The sine swings between −1 and 1, so the brightness swings between and . Add and subtract and , and you get the two formulas above; the contrast simply scales the amplitude down.
A common measure of brightness difference is the Michelson contrast. With and ,
so it means the amplitude as a fraction of the mean brightness.
Measuring sensation with numbers
Once stimuli can be built from numbers like this, sensation itself can be measured with numbers. For example, the smallest brightness difference you can just notice, , is roughly proportional to the starting brightness , a rule known as Weber's law. Going from one candle to two makes a room noticeably brighter; adding one candle to a hundred, you would hardly notice. What counts is the ratio, not the difference:
The science of measuring sensation with numbers is called psychophysics, and it began with a physicist's painful ordeal. Gustav Fechner, professor of physics at the University of Leipzig, injured his eyes around 1839–1840 while studying afterimages by gazing at the Sun through colored glasses, and after long suffering he resigned his post. Never try looking at the Sun, with any kind of glass or filter. While recovering he turned to the relation between mind and body, and on the morning of October 22, 1850, lying in bed, he is said to have hit on a way of linking sensations to physical stimuli with numbers. He set it out in his 1860 book Elements of Psychophysics. To this day the International Society for Psychophysics calls its annual meeting Fechner Day in honor of that insight. Its very first meeting, in 1985, was held on October 21 and 22.
The heart of Fechner's method was to make stimuli precisely, change them step by step, and check over and over where "noticeable" turns into "not noticeable". Writing stimuli as numbers and formulas in this editor is part of that tradition.
Gustav Fechner treated each just-noticeable difference as one step on the scale of sensation. Raising the stimulus from to raises the sensation by one step, and that step corresponds to a fixed , so for small changes . Adding up the steps from the threshold intensity , where , to gives
using the calculus fact that the integral of is a logarithm. Sensation grows with the logarithm of the stimulus: making a stimulus ten times stronger does not make it feel ten times stronger, it adds a fixed amount. This is not a law that always holds, though. Weber's law breaks down in very dim and very bright conditions, and S. S. Stevens, who had been developing the idea since the 1950s, argued in a 1961 paper that when people are asked to put numbers on how strong a sensation is, a power law fits better than a logarithm. Which formula works depends on what you measure and how.
Measuring the eye with stripes
By the middle of the twentieth century, sine gratings had become the stars of vision research. In 1968 Fergus Campbell and John Robson measured the faintest visible contrast of gratings of different fineness. Human eyes turned out to be most sensitive to medium-fine stripes, a few cycles per degree of visual angle, and less sensitive to both very coarse and very fine ones. The peak is often quoted as about 4 cycles per degree and shifts with conditions such as brightness. This "contrast sensitivity function" became a basic curve describing how well we see. Because Fourier analysis lets any image be built from gratings, knowing how we respond to gratings helps us think about how we see any picture.
Eye clinics test not only how small a letter you can read but also how faint a letter you can read, using charts with low-contrast letters. The quality of vision cannot be captured by fineness alone.
The grating idea also links to physics and information technology. Just as a sound can be split into sine waves of different frequencies, an image can be split into gratings. Digital photo compression uses this to discard fine-stripe information that our eyes hardly notice.
Drifting stripes and windowed stripes
How fast do the stripes travel? Like a surfer riding the same crest, follow a point of constant phase, where stays fixed. Solving for gives : the same crest moves toward negative at speed . Since is the number of crests passing per second and is the spacing between crests, the speed is just "crests per second times crest spacing". With , which is 3 cycles per 100 px, and 1 Hz, the speed is about 33 px/s.
A Gabor patch is a grating multiplied by a Gaussian window,
where is the standard deviation of the window: at a distance from the center the window has dropped to . Because receptive fields of cells in the visual cortex are well approximated by this shape, Gabor patches are a favorite in vision experiments.
The Gabor function is named after Dennis Gabor, the physicist known for inventing holography, who introduced it in a theory of communication. That it also fits the receptive fields of cells in the visual cortex is explored in the "Receptive Fields and Orientation Selectivity" simulation.
A radial grating varies with angle as , where is the number of cycles around the circle.
Art has its own stripe story. In the late 1930s, in 1937 or 1938 depending on the source, Victor Vasarely painted zebras out of nothing but curving black-and-white stripes. In 1965 the Museum of Modern Art in New York held an exhibition called The Responsive Eye, and works of op art by Bridget Riley and others, made of black-and-white stripes and rings that seem to shimmer and move, drew huge crowds. It is delightful that the stimuli vision scientists use in the lab and works hanging in galleries are connected by the same stripes.
Can anyone rebuild the same stimulus?
Now some honesty. This editor adds colors as screen values from 0 to 255. Screen values are not proportional to the light that comes out, because displays have a "gamma" curve, so "contrast 0.5" here is not the contrast you would measure in light. Researchers measure their screens with a photometer and correct for this. Also, a 60 Hz screen only updates every 16.7 ms or so, so "show it for 0.034 s" actually means two frames. And note that the trigonometric functions in formulas take angles in degrees: sin(90) = 1.
Once stimuli moved onto computer screens, researchers began writing their own software to generate them, and to share it. PsychoPy, for example, begun in 2002, is free, open-source software written in the Python programming language, and it can now build experiments that run in a web browser. The stimuli Fechner made by hand can now be rebuilt by anyone from the same formulas.
Psychology experiments run in web browsers over the internet have become common. They gather data from many people easily, but screen brightness, refresh rate and viewing distance differ from person to person. Saying clearly what was controlled and what was not matters more than ever.
Research also places growing weight on replication, other people repeating an experiment to check it. One wake-up call was a large project published in 2015: many researchers shared out and redid 100 studies from three leading psychology journals, and of the 97 originally reporting a clear effect, only 36% showed it again. If the stimuli are saved as files and shared, replication becomes much easier. That is why this editor saves a whole set of stimuli as JSON.
Build stimuli and test them
- When the page opens, a wave of dots is shown stopped, so that you can read the light-stimulus warning before anything moves. After reading it, press ▶ Play and the dots start to ripple like a wave. Select "Dot" under "Stimuli" and change 36 * i in the y expression to 0. How does the motion change? What about 72 * i? Predict before you try.
- Press Load "Flash-drag" and start it at the top of the panel. Two bars flash once per second beside a rotating disk. Do they look aligned? Change the y of "Left bar" a little at a time from 300 and find where they look aligned.
- The global variable a sets the disk's rotation speed in degrees per second. What happens to the bars when a is 0?
- Under "Presets", load "Drifting Gabor", change its "Spatial frequency" and "Temporal frequency", and predict the drift speed with .
- Set "Color 1" and "Color 2" of a grating to the same color. With "Contrast" at 0.5, what range of brightness do you get?
- Save your own stimulus set with "Save JSON", pass the file to a classmate and check that "Load JSON" reproduces the same stimuli.
Numbers on the screen, and what you see
Visual stimuli can be written down with numbers and formulas. A grating is fixed by its mean brightness, amplitude, spatial frequency, temporal frequency, phase and tilt, and its drift speed is . Written as numbers, stimuli can be saved, shared and reproduced by anyone. Some conditions lie outside the formulas, such as the display's gamma and its frame timing, and stating them honestly is part of what makes an experiment good.
A physicist who hurt his eyes staring at the Sun came up with the idea of measuring sensation with numbers. That idea led to grating stimuli and the contrast sensitivity function, and it continues today in free software and in a research culture of sharing stimuli so that others can check the results.
So how much of what you "see" is fixed by the numbers on the screen, and how much by your eyes and brain? Build some stimuli and go looking for the boundary.
Sources and further reading
Main sources for the facts mentioned above.
- F. W. Campbell & J. G. Robson, Application of Fourier analysis to the visibility of gratings, Journal of Physiology, 1968 (the contrast sensitivity function)
- S. S. Stevens, To honor Fechner and repeal his law, Science, 1961 (the power law)
- D. Gabor, Theory of communication. Part 1: The analysis of information, Journal of the IEE, 1946
- Open Science Collaboration, Estimating the reproducibility of psychological science, Science, 2015 (the 100-study replication project)
- PsychoPy, official site (free experiment software)
- F. C. Beiser, Gustav Theodor Fechner, Stanford Encyclopedia of Philosophy, 2020 (his chair in physics, the eye injury from looking at the Sun through colored glasses, the 1860 book)
- International Society for Psychophysics, About the society (Fechner Day and October 22, 1850)
- International Society for Psychophysics, History (the first meeting in 1985)
Further reading (encyclopedia):