I thought i propose some minor improvements to make it possibly portable to non-Windows, or at least Psychtoolbox bits should not prevent portability. This code is untested, but should be correct or trivially fixable in case i made a typo.
Using KbName() allows to get rid of the mystic key numbers.
Using KbName('UnifyKeyNames') makes this also work on Linux or macOS.
Moving the version checks to the top, because otherwise it would already be too late to verify.
Other possible minor performance improvement would be to use Screen('FillRect', obj.SLM, 0); instead of Screen(obj.SLM, 'PutImage',obj.blank_image); to simply clear the screen to black. In general, PutImage is the slowest way to get an image to the screen. A combination of MakeTexture to convert a matlab matrix into a texture handle before the actual realtime presentation sequence, and DrawTexture to draw it fast into the window, may be a speed advantage on low-end or slow machines.
Maybe using of the timestamping and timing features of Screen('Flip') would also be advantageous for stable presentation timing during the lithography presentation sequence, compared to use of tic, toc etc.
Thanks a lot for the suggestions! I have added the key name and blank image suggestions to v1.1.5 and will work on the image textures for a later release.
…provement.
Hi, Psychtoolbox developer here. Cool project! A user of us just asked me to support him in using your toolkit: See https://psychtoolbox.discourse.group/t/matlab-crashes-when-i-run-the-program/3707 for reference.
I thought i propose some minor improvements to make it possibly portable to non-Windows, or at least Psychtoolbox bits should not prevent portability. This code is untested, but should be correct or trivially fixable in case i made a typo.
Using KbName() allows to get rid of the mystic key numbers. Using KbName('UnifyKeyNames') makes this also work on Linux or macOS. Moving the version checks to the top, because otherwise it would already be too late to verify.
Other possible minor performance improvement would be to use
Screen('FillRect', obj.SLM, 0);
instead ofScreen(obj.SLM, 'PutImage',obj.blank_image);
to simply clear the screen to black. In general,PutImage
is the slowest way to get an image to the screen. A combination ofMakeTexture
to convert a matlab matrix into a texture handle before the actual realtime presentation sequence, andDrawTexture
to draw it fast into the window, may be a speed advantage on low-end or slow machines.Maybe using of the timestamping and timing features of
Screen('Flip')
would also be advantageous for stable presentation timing during the lithography presentation sequence, compared to use of tic, toc etc.Best, -mario