Mgl is a suite of mex/m files for displaying visual psychophysics stimuli and writing experimental programs in Matlab. Runs on Mac OS X and is compatible with latest versions of the Mac OS (Catalina as of 3/2020). There is an alpha (proof of principle) version that is compatible with Metal. See here for a list of publications that have used mgl and how to cite use of mgl in your manuscript!
mgl is a set of matlab functions for displaying full screen visual stimuli from matlab. It is based on OpenGL functions, but abstracts these into more simple functions that can be used to code various kinds of visual stimuli. It can be used on Mac OS X systems (a Windows beta exists which can open/close screen and display but is not ready for serious use and an older but usable version (1.5) exists for Linux. Neither windows nor linux versions are recommended for anyone who is not comfortable programming in C and building out existing functionality into a fully compatible version).
% Open the screen, 0 specifies to draw in a window. % 1 would be full screen in the main display % 2 would be full screen in a secondary display, etc... mglOpen(0); % Select the coordinate frame for drawing % (e.g. for a monitor 57 cm away, which has width and height of 16 and 12 cm). mglVisualAngleCoordinates(57,[16 12]); % Draw the text in the center (i.e. at 0,0) mglTextDraw('Hello World!',[0 0]); % The above is drawn on the back-buffer of the double-buffered display % To make it show up you flush the display. % This function will wait till the end of the screen refresh mglFlush;
When finished, with displaying the stimuli, you simply close the screen:
A couple of things that distinguish MGL from other packages for doing psychophysics experiments using Matlab.
1) Simple standalone functions. We were aiming to make the code as simple as possible, so that we and others could extend functionality as easily as possible. So a major design goal was to keep each function as atomic and simple as possible - every function is one C/MEX file that has OS specific code clearly separated out, typically as a separate function. Something like the philosophy behind UNIX where kitchen sink type functions are frowned upon. This was so that it would be easy to hack in the future and for others. New functionality typically gets added as a separate function so we don't risk breaking existing code. Functions are simple so that they are easier to maintain against OS upgrades (the back end of MGL was rewritten a few years ago using objective-C so that we could be 64-bit compliant).
2) Task library. We have a low-level library for displaying stimuli and accessing hardware as well as a task library which sits on top of that. The task library simplifies writing experiments since it takes care of timing, trials, synching with digital pulses, interfacing with eye-trackers etc. Each new experiment simply implements callback functions that handle how to draw the screen, what to do when a subject responds etc. This makes it quick to write new experiments and makes sure that problems fixed for one experiment are solved for all experiments.
Apple is transitioning away from OpenGL and we are aware that the current version of MGL does not work on newer systems. We are working on a new version of MGL that will be based on Metal, but that is not yet prime-time.
As of this writing (9.23.2021), MGL can still work on Catalina on non-M1 Macs. I am not exactly sure what specs are required, but something like the following:
Mac: Probably needs to be pre-2019ish? Definitely works on MacBook Air Mid-2012, iMac 2015 OS: up to at least, macOS Catalina Version 10.15.7 Matlab: Matlab Version 2013a-2015b (may work on later versions of matlab, but is hard to compile because Mathworks changed the mexopts.sh compilation options file) Xcode (only necessary for recompiling): Version 11.7 (11E801a)
Here are some configurations that are working:
|Hardware||OS Version||Matlab version||Needs recompile|
|MacPro (2019)||Big Sur 11.4||Matlab2015a||No|