A configurable angle-resolving detector system for a STEM has been dev
eloped, which opens a universal and flexible way of masking the diffra
ction pattern. The diffraction pattern can be divided in up to 16 area
s of arbitrary shapes which may be defined analytically, or be constru
cted interactively under observation of the diffraction pattern. The s
ignals from such areas are separately accumulated and processed. A sim
ple demonstration is shown for two MgO crystals with different orienta
tion. The special case of differential phase contrast is demonstrated
for a hole in an amorphous carbon film.