Skip to content
witthoft edited this page Oct 17, 2016 · 2 revisions
<title>t_glmRun</title><style type="text/css"> html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}

html { min-height:100%; margin-bottom:1px; } html body { height:100%; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000; line-height:140%; background:#fff none; overflow-y:scroll; } html body td { vertical-align:top; text-align:left; }

h1 { padding:0px; margin:0px 0px 25px; font-family:Arial, Helvetica, sans-serif; font-size:1.5em; color:#d55000; line-height:100%; font-weight:normal; } h2 { padding:0px; margin:0px 0px 8px; font-family:Arial, Helvetica, sans-serif; font-size:1.2em; color:#000; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; } h3 { padding:0px; margin:0px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:1.1em; color:#000; font-weight:bold; line-height:140%; }

a { color:#005fce; text-decoration:none; } a:hover { color:#005fce; text-decoration:underline; } a:visited { color:#004aa0; text-decoration:none; }

p { padding:0px; margin:0px 0px 20px; } img { padding:0px; margin:0px 0px 20px; border:none; } p img, pre img, tt img, li img { margin-bottom:0px; }

ul { padding:0px; margin:0px 0px 20px 23px; list-style:square; } ul li { padding:0px; margin:0px 0px 7px 0px; } ul li ul { padding:5px 0px 0px; margin:0px 0px 7px 23px; } ul li ol li { list-style:decimal; } ol { padding:0px; margin:0px 0px 20px 0px; list-style:decimal; } ol li { padding:0px; margin:0px 0px 7px 23px; list-style-type:decimal; } ol li ol { padding:5px 0px 0px; margin:0px 0px 7px 0px; } ol li ol li { list-style-type:lower-alpha; } ol li ul { padding-top:7px; } ol li ul li { list-style:square; }

.content { font-size:1.2em; line-height:140%; padding: 20px; }

pre, tt, code { font-size:12px; } pre { margin:0px 0px 20px; } pre.error { color:red; } pre.codeinput { padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; } pre.codeoutput { padding:10px 11px; margin:0px 0px 20px; color:#4c4c4c; }

@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } }

span.keyword { color:#0000FF } span.comment { color:#228B22 } span.string { color:#A020F0 } span.untermstring { color:#B20000 } span.syscmd { color:#B28C00 }

.footer { width:auto; padding:10px 0px; margin:25px 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; } .footer p { margin:0px; } .footer a { color:#878787; } .footer a:hover { color:#878787; text-decoration:underline; } .footer a:visited { color:#878787; }

table th { padding:7px 5px; text-align:left; vertical-align:middle; border: 1px solid #d6d4d4; font-weight:bold; } table td { padding:7px 5px; text-align:left; vertical-align:top; border:1px solid #d6d4d4; }

</style>

t_glmRun

Illustrates how to run a GLM on a functional data set.

Tested 01/04/2011 - MATLAB r2008a, Fedora 12, Current Repos

Stanford VISTA

Contents

Initialize the key variables and data path:

Data directory (where the mrSession file is located)

dataDir = fullfile(mrvDataRootPath,'functional','vwfaLoc');
parfDir = fullfile(dataDir, 'Stimuli', 'parfiles');

% You must analyze with the matlab directory in the data directory. curDir = pwd; % We will put you back where you started at the end chdir(dataDir);

% There can be several data types - we're using motion compensated dated dataType = 'MotionComp';

Get data structure:

vw = initHiddenInplane(); % Foregoes interface - loads data silently

Prepare scans for GLM

numScans = viewGet(vw, 'numScans');
whichScans = 1:numScans;

% If you're processing your own experiment, you'll need to produce parfiles % More info @ % http://white.stanford.edu/newIm/index.php/GLM#Create_.par_files_for_each_scan whichParfs = {'VWFALocalizer1.par' ... 'VWFALocalizer2.par' ... 'VWFALocalizer3.par'};

vw = er_assignParfilesToScans(vw, whichScans, whichParfs); % Assign parfiles to scans vw = er_groupScans(vw, whichScans, [], dataType); % Group scans together

Set GLM Parameters:

The GLM parameters are stored in a Matlab structure. We call the structure params. The parameters, such as params.timeWindow inform the GLM processing routine about the experiment.

A description of the parameters can be found on the wiki at:

http://white.stanford.edu/newlm/index.php/MrVista_1_conventions#eventAnalysisParams

params.timeWindow               = -8:24;  %
params.bslPeriod                = -8:0;   %
params.peakPeriod               = 4:14;   %
params.framePeriod              = 2;      % TR
params.normBsl                  = 1;
params.onsetDelta               = 0;
params.snrConds                 = 1;
params.glmHRF                   = 2;
params.eventsPerBlock           = 6;
params.ampType                  = 'betas';
params.detrend                  = 1;
params.detrendFrames            = 20;
params.inhomoCorrect            = 1;
params.temporalNormalization    = 0;
params.glmWhiten                = 0;

saveToDataType = 'GLMs'; % Data type the results will be saved to

Run GLM:

Returns view structure and saved-to scan number in new data type

[vw, newScan] = applyGlm(vw, dataType, whichScans, params, saveToDataType);

% newScan indicates the scan # in which results are saved % vw is a mrVista view structure. If you just type vw, you will see a lot % of the fields. In this case, many of them are empty. To understand what % the fields can represent, see the vistalab wiki re: GLMs.

To delete the new GLM run:

removeScan(vw, newScan, saveToDataType, 1);

END


Published with MATLAB® R2013b

<!--
SOURCE BEGIN

%% t_glmRun % % Illustrates how to run a GLM on a functional data set. % % Tested 01/04/2011 - MATLAB r2008a, Fedora 12, Current Repos % % Stanford VISTA %

%% Initialize the key variables and data path: % Data directory (where the mrSession file is located) dataDir = fullfile(mrvDataRootPath,'functional','vwfaLoc'); parfDir = fullfile(dataDir, 'Stimuli', 'parfiles');

% You must analyze with the matlab directory in the data directory. curDir = pwd; % We will put you back where you started at the end chdir(dataDir);

% There can be several data types - we're using motion compensated dated dataType = 'MotionComp';

%% Get data structure: vw = initHiddenInplane(); % Foregoes interface - loads data silently

%% Prepare scans for GLM

numScans = viewGet(vw, 'numScans'); whichScans = 1:numScans;

% If you're processing your own experiment, you'll need to produce parfiles % More info @ % http://white.stanford.edu/newIm/index.php/GLM#Create_.par_files_for_each_scan whichParfs = {'VWFALocalizer1.par' ... 'VWFALocalizer2.par' ... 'VWFALocalizer3.par'};

vw = er_assignParfilesToScans(vw, whichScans, whichParfs); % Assign parfiles to scans vw = er_groupScans(vw, whichScans, [], dataType); % Group scans together

%% Set GLM Parameters: % The GLM parameters are stored in a Matlab structure. % We call the structure params. % The parameters, such as params.timeWindow inform the GLM processing % routine about the experiment. % % A description of the parameters can be found on the wiki at: % % http://white.stanford.edu/newlm/index.php/MrVista_1_conventions#eventAnalysisParams params.timeWindow = -8:24; % params.bslPeriod = -8:0; % params.peakPeriod = 4:14; % params.framePeriod = 2; % TR params.normBsl = 1; params.onsetDelta = 0; params.snrConds = 1; params.glmHRF = 2; params.eventsPerBlock = 6; params.ampType = 'betas'; params.detrend = 1; params.detrendFrames = 20; params.inhomoCorrect = 1; params.temporalNormalization = 0; params.glmWhiten = 0;

saveToDataType = 'GLMs'; % Data type the results will be saved to

%% Run GLM: % Returns view structure and saved-to scan number in new data type [vw, newScan] = applyGlm(vw, dataType, whichScans, params, saveToDataType);

% newScan indicates the scan # in which results are saved % vw is a mrVista view structure. If you just type vw, you will see a lot % of the fields. In this case, many of them are empty. To understand what % the fields can represent, see the vistalab wiki re: GLMs.

%% To delete the new GLM run: removeScan(vw, newScan, saveToDataType, 1);

%% END

SOURCE END
Clone this wiki locally