To setup mgl at home you will need the following:
You should make two directories in your home directory, one for code and one for data. You can do this from terminal:
cd ~ mkdir proj mkdir data
In the proj directory you will want to clone our git repositories.
cd ~/proj git clone https://github.com/justingardner/mgl.git mgl git clone https://github.com/justingardner/mrTools.git mrTools git clone https://github.com/justingardner/gru.git gru git clone https://github.com/justingardner/grustim.git grustim
If you are working in the lab, you can download a license for Matlab - note that you will want to use an older version of Matlab which is more stable. We typically use Matlab R2015a.
For running stimulus programs, I highly recommend running Matlab from a terminal rather than using the Matlab Desktop. While the Matlab Desktop is great for the debugging environment, it tends to be a bit of a problem for stimulus programs when they crash because if the environment crashes then you can't see the error messages. Running from the terminal is easier because if Matlab crashes out the terminal will still have the display of the error messages. To run it, you start Terminal and do:
/Applications/MATLAB_R2015a.app/bin/matlab -nodesktop
Note that if you are using a different version of MATLAB you will need to put that in the command above. You can see what matlab you have by doing:
ls -d /Applications/M*
Once you are running matlab, you will want to make sure to add the paths to our repositories
>> addpath(genpath('~/proj'))
Check the wiki pages for mgl to run the mglSystemCheck and test programs to make sure you have things working properly.
When working with two displays, you will need to tell mgl how you want to configure your displays. You do this with the command mglEditScreenParams. The point of this command is to keep all the settings that you need for your display. Actually you can keep multiple groups of settings, for example one group of settings for debug and one for actual experiments. Here we will setup one for running experiments. Start by running the command:
>> mglEditScreenParams
You should see a dialog like the following come up:
This allows you to select which configuration to edit. You select that by the number on top. For now, 1 is the one you will edit. If you want to start a new configuration, you would click “Add Display”. Instead, just click OK and you will see a dialog like the following.
>> mglResolution(1) ans = displayNumber: 1 numDisplays: 2 screenWidth: 1920 screenHeight: 1200 frameRate: 60 bitDepth: 32
. Now go back to mglEditScreenParams and set the screenNumber, screenWidth and screenHeight using the values you learned from mglResolution. Click “Test screen params” as above and check that the screen opens up correctly. You might notice that the screen may go blank for a second before coming up - this is MacOS trying to reset the resolution of the display.
mglSetSID('test');
You may wish to run initScreen with the following all in one line, which will open up the screen, change the background color, wait 10 secs and then close the screen (just in case something went wrong and it covers up your matlab workspace, this will auto close) Note that you will need to change 'external_monitor' to whatever you used for your displayName
initScreen('external_monitor'); mglClearScreen([0.3 0.7 0.4]); mglFlush; mglWaitSecs(10); endScreen;
If all went well, you should see in the command buffer something like the following
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ Begin initScreen =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ (initScreen) SID is: test (initScreen) Monitor parameters for: boodles displayName: external_monitor (initScreen) ignoreInitialVols = 0 (initScreen) 1.0: 1920x1200(pix) dist:57.0 (cm) size:51.7x32.0 (cm) 60Hz save:1 autoclose:1 flipHV:[0 1] (initScreen) Saving data into ~/data (mglPrivateVolume) Volume property does not exist (initScreen) Flipping coordinates vertically (initScreen) Correcting for monitor gamma of 1.80 (initScreen) imageWidth: 50.23 imageHeight: 31.74 (mglPrivateListener) Starting keyboard and mouse event tap. End with mglListener('quit'). =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ End initScreen =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ (endScreen) No myscreen variable passed in, just closing screen and shutting down listeners (mglPrivateListener) Ending keyboard and mouse event tap
I really, really encourage you to always glance at this display when it comes up. It tells you whether important settings have been set when you open the screen. In particular, the imageWidth/imageHeight (in degrees of visual angle), where data is being saved to, what the monitor calibration is that is being used.
mglSetSID('add');
The first time you run, you will see the following
(mglSetSID) Setting lock file on SID database (mglSetSID) Could not find SID Database file /Users/justin/.sidDatabase, create one from scratch? (y/n)?
since you do not yet have an SID database. Go ahead and say “y”. You should see a dialog like the follwing
Go ahead and put in your name, gender, date of birth and click OK. You will now see
(mglSetSID) Create SID database file: /Users/justin/.sidDatabase (y/n)? y (mglSetSID) Saving SID database, enter password enter des-ede3-cbc encryption password: Verifying - enter des-ede3-cbc encryption password: (mglSetSID) Releasing lock file on SID database
You can enter whatever password you want here - just make sure it is something you remember. To test whether it works or not, you can try to set your SID using your name
>> mglSetSID('justin') (mglSetSID) Loading SID database, enter password enter des-ede3-cbc decryption password: (mglSetSID) Found subject: Justin Gardner (s001) (mglSetSID) Setting SID: s001
You will need to use the password that you set on the sid database.