Does anyone have a code for spherical correction of the stimuli for mice?

Does anyone have a code for spherical correction of full field gratings stimuli for mice?

attached is an example MATLAB code and explanation: