Question: I am photographing a scene with white and black elements in it. Starting at the f/22 stop, I widen the aperture one stop and decrease the exposure time by a factor of 2, take a picture, and keep doing this for all the f-stops on the lens. My expectation is that raw counts should stay the same inside a white region or a black region since **halving the exposure time compensates for widening the aperture**. But when I select a white region and average its pixel raw counts for each image, there is **variability between the images** (the standard deviation of the raw counts is ~5% of the mean). Same thing if I select and average a black region. I am not knowingly changing anything else (illumination, camera position), and the camera is a scientific CMOS. What could be causing this variation: noise, or something more systematic?

Answer: 
This is normal behavior, caused by:

1. Imperfections of aperture. Usually there are variations from
technology process which cause not to have exact size of the hole.
On 50mm lens f4 you should have 12.5mm opening, but it can be 12.4mm
or 12.6mm
2. Imperfections in shutter speed. The shutter is also mechanical unit
and based on some factors as temperature, how precise are the blades
and other elements inside, speed will be not 1/100s but can be
1/110s or 1/90s.
3. The same is true about the sensor itself (from electronic point of
view)

At the end even two consecutive photos can have different (slightly) exposure.

And add fluctuation of your illumination source...
With regard to systematic problems: you are taking into account that with opening up the aperture depth of focus decreases and thus the borders of out-of-focus scene parts blur? Also with small apertures you might get some blurring due to diffraction.

If you have a mechanical shutter, you actually can get diffraction with *large* apertures from the resulting short shutter times when a significant amount of the exposure time is spent near at least one of the shutter curtains moving across.