From 469a91a606bc42cd548df77f338e96d25a5792b1 Mon Sep 17 00:00:00 2001 From: Julien Besle Date: Thu, 7 Nov 2019 03:52:58 +0200 Subject: [PATCH] (julien) added hrf model hrfCustom.m to add arbitrary HRF model using numerical values --- .../GLM_v2/newGlmAnalysis/glmAnalysisGUI.m | 2 +- .../Plugin/GLM_v2/newGlmAnalysis/hrfCustom.m | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/hrfCustom.m diff --git a/mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/glmAnalysisGUI.m b/mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/glmAnalysisGUI.m index c32413da9..972992c87 100644 --- a/mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/glmAnalysisGUI.m +++ b/mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/glmAnalysisGUI.m @@ -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)'; diff --git a/mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/hrfCustom.m b/mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/hrfCustom.m new file mode 100644 index 000000000..8f70a4c87 --- /dev/null +++ b/mrLoadRet/Plugin/GLM_v2/newGlmAnalysis/hrfCustom.m @@ -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 \ No newline at end of file