spm_hrf.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function [hrf,p] = spm_hrf(RT,P,T)
  2. % Haemodynamic response function
  3. % FORMAT [hrf,p] = spm_hrf(RT,p,T)
  4. % RT - scan repeat time
  5. % p - parameters of the response function (two Gamma functions)
  6. %
  7. % defaults
  8. % {seconds}
  9. % p(1) - delay of response (relative to onset) 6
  10. % p(2) - delay of undershoot (relative to onset) 16
  11. % p(3) - dispersion of response 1
  12. % p(4) - dispersion of undershoot 1
  13. % p(5) - ratio of response to undershoot 6
  14. % p(6) - onset {seconds} 0
  15. % p(7) - length of kernel {seconds} 32
  16. %
  17. % T - microtime resolution [Default: 16]
  18. %
  19. % hrf - haemodynamic response function
  20. % p - parameters of the response function
  21. %__________________________________________________________________________
  22. % Copyright (C) 1996-2015 Wellcome Trust Centre for Neuroimaging
  23. % Karl Friston
  24. % $Id: spm_hrf.m 6594 2015-11-06 18:47:05Z guillaume $
  25. %-Parameters of the response function
  26. %--------------------------------------------------------------------------
  27. try
  28. p = spm_get_defaults('stats.fmri.hrf');
  29. catch
  30. p = [6 16 1 1 6 0 32];
  31. end
  32. if nargin > 1
  33. p(1:length(P)) = P;
  34. end
  35. %-Microtime resolution
  36. %--------------------------------------------------------------------------
  37. if nargin > 2
  38. fMRI_T = T;
  39. else
  40. fMRI_T = spm_get_defaults('stats.fmri.t');
  41. end
  42. %-Modelled haemodynamic response function - {mixture of Gammas}
  43. %--------------------------------------------------------------------------
  44. dt = RT/fMRI_T;
  45. u = [0:ceil(p(7)/dt)] - p(6)/dt;
  46. hrf = spm_Gpdf(u,p(1)/p(3),dt/p(3)) - spm_Gpdf(u,p(2)/p(4),dt/p(4))/p(5);
  47. hrf = hrf([0:floor(p(7)/RT)]*fMRI_T + 1);
  48. hrf = hrf'/sum(hrf);