Skip to content

Commit

Permalink
(julien) added hrf model hrfCustom.m to add arbitrary HRF model using…
Browse files Browse the repository at this point in the history
… numerical values
  • Loading branch information
julienbesle committed Nov 7, 2019
1 parent 463f25f commit 469a91a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/glmAnalysisGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
askForParams = 1;
% put group name on top of list to make it the default
groupNames = putOnTopOfList(params.groupName,viewGet(thisView,'groupNames'));
hrfModelMenu = putOnTopOfList(params.hrfModel,{'hrfDoubleGamma','hrfFslFlobs','hrfDeconvolution','hrfBoxcar'});
hrfModelMenu = putOnTopOfList(params.hrfModel,{'hrfDoubleGamma','hrfFslFlobs','hrfDeconvolution','hrfBoxcar','hrfCustom'});
analysisVolumeMenu = {'Whole volume'};
if nRois
analysisVolumeMenu{end+1} = 'Loaded ROI(s)';
Expand Down
63 changes: 63 additions & 0 deletions mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/hrfCustom.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
% hrfDeconvolution.m
%
% $Id$
% usage: [params,hrf] = hrfCustom(params, sampleDuration, sampleDelay, defaultParams)
% by: julien besle
% date: 13/04/2010
% purpose: returns the HRF specified as values in the parameters. If a time vector is specified
% checks that times correspond to actual TR and acquistion time (sampleDuration and sampleDelay)
% otherwise, assumes that HRF sample times correspond to those TR and acquisition times
%
function [params,hrf] = hrfCustom(params, sampleDuration,sampleDelay, defaultParams)

if ~any(nargin == [1 2 3 4])% 5])
help hrfCustom
return
end

if ieNotDefined('defaultParams'),defaultParams = 0;end
if ieNotDefined('sampleDelay')
sampleDelay=sampleDuration/2;
end

if ieNotDefined('params')
params = struct;
end
if fieldIsNotDefined(params,'description')
params.description = 'Custom HRF';
end
if fieldIsNotDefined(params,'hrf')
[~, params.hrf] = hrfDoubleGamma([],sampleDuration,sampleDelay,1);
params.hrf = params.hrf';
end
if fieldIsNotDefined(params,'hrfTimes')
params.hrfTimes = sampleDelay+sampleDuration*(0:length(params.hrf)-1);
end

paramsInfo = {...
{'description', params.description, 'comment describing the hdr model'},...
{'hrf',params.hrf,'values of the the HRF'},...
{'hrfTimes',params.hrfTimes,'Times of the HRF samples'},...
};

if defaultParams
params = mrParamsDefault(paramsInfo);
else
params = mrParamsDialog(paramsInfo, 'Set Custom HRF parameters');
end

if nargout==1
return
end

%check that the times correspond to
if ~isequal(sampleDelay+sampleDuration*(0:length(params.hrf)-1), params.hrfTimes)
mrWarnDlg('(hrfCustom) HRF times are not compatible with TR and acquisition time');
keyoard
else
if size(params.hrf,1)==1
hrf = params.hrf';
else
hrf = params.hrf;
end
end

0 comments on commit 469a91a

Please sign in to comment.