|
Table of Contents
Saving data into a stimfileStimfilesAfter you have run an experiment, all three variables (myscreen, task and your stimulus variable) will get saved into a file called yymmdd_stimnn.mat Where yymmdd is the current date, and nn is a sequential number starting at 01. This file will be stored in the current directory or in the directory ~/data if you have one. After these get saved, you can access all the variables for your experiment by using getTaskParameters(myscreen,task); This will return a strucutre that contains the starting volume of each trial, what each variable was set to, the response of the subject and reaction time, among other things. For most purposes this should contain all the information you need to reconstruct what was presented on what trial and what the subject's response was. Note that there is a variable called myscreen.saveData which tells the task structure whether to save the stim file or not. The default on your computer is probably set not to save the stim file. When you run on the computer in the scanner room, it will save the file automatically. For debugging purposes this is usually what you want so that you don't save unnecessary stim files every time you test your program. However if you want to save the stim file on your test computer to look at, you can add the following to your code where you call initScreen: myscreen.saveData = 1; myscreen = initScreen(myscreen); The variables stored in the stim file contain all the information you should need to recreate what happened in your experiment. In fact, it even contains a full listing of the file you used when running the experiment. This is useful since often you might make minor changes to the program and forget what version you were using when you ran an experiment. You can access a listing from the task variable: task{1}{1}.taskFileListing===== Directory to save stimfiles in =====
By default, mgl will save the data in ~/data if that directory exists, and in the current directory if ~/data doesn't exist. To save data to a specific directory instead of to these defaults, set myscreen.datadir = datadirname; where datadirname is the full path of the desired directory. Retrieving data from stimfilesgetTaskParameters
usage: e = getTaskParameters(myscreen,task);
getStimvol
usage: [stimvol stimNames var] = getStimvol(v,'varname',<taskNum=?>,<phaseNum=?>,<segmentNum=?>);
An example: v = newView; v = viewSet(v,'curGroup',3); v = viewSet(v,'curScan',1); [stimvol stimNames var] = getStimvol(v,'varname','taskNum=2','phaseNum=2'); getStimvolFromVarname
usage:[stimvol stimNames] = getStimvolFromVarname(varnameIn,myscreen,task,taskNum,phaseNum,segmentNum);
varnameIn can be the name of a parameter or randVar. e.g.: getStimvolFromVarname('dir',myscreen,task,2,2);
It can also be of the form varname(indexVar). For when you have used a parameterCode and an index variable. e.g.:
getStimvolFromVarname('localDir(dirIndex)',myscreen,task);
Or it can be _all_ which returns all trial numbers regardless of stimulus type: getStimvolFromVarname('_all_',myscreen,task);
If varnameIn is a cell array, then you can specify a set of matching conditions. For example, the following would return the stimvols for when var1 = 1 *and* var2 = either 2 or 3: {'var1=[1]','var2=[2 3]'}
If you want to return multiple sets of stimvols with matching conditions, you can make a cell array of cell arrays of the type form above. For example: {{'var1=[1]','var2=[2 3]'},{'var1=[2]','var2=[1]'}}
getTaskVarnames
usage:varnames = getTaskVarnames(task);
getParameterTrace
usage: trace = getParameterTrace(myscreen,task,'varname');
getVarFromParameters
usage: [varval taskNum phaseNum] = getVarFromParameters('varname',e);
makeTracesFor most people, using getTaskParameters is the easiest way to get what happened on each trial. But there is another mechanism that allows you to see the specific timing of events as traces. This is saved in the traces field of the myscreen variable. This field stores when each volume was collected and what stimulus was presented. Using this information you can reconstruct the volume when each stimulus occurred. It is set up so the first row contains an array which has a one every time a volume was acquired (i.e. whenever a backtick was received) and zeros elsewhere. The timebase for the array is in monitor refreshes, so every 60 elements shouls be one second. Take a look at what this trace has by doing: myscreen = makeTraces(myscreen); plot(myscreen.traces(1,:)); You can also plot in seconds, relative to the beginning of the experiment: plot(myscreen.time,myscreen.traces(1,:)); The other important trace is the one corresponding to myscreen.stimtrace: plot(myscreen.traces(myscreen.stimtrace,:)); This will contain the information about which trial was presented as long as you have set the writeTrace variable correctly (see next section). |