Requires PsychToolBox
Note that PsychToolBox is only superficially supported for Windows, only bug-tested for Windows 10, & is in general not recommended for high-precision tasks.
Code used in:
An increase in spontaneous activity mediates visual habituation. Jae-eun Kang Miller, Bradley R Miller, Darik A O'Neil, & Rafael Yuste. Cell Reports, April 2022.