1
+ function varargout = spm_prf_fcn_template(P ,M ,U ,varargin )
2
+ % Template pRF response function. This example models neuronal
3
+ % activity as a scaled version of the inputs:
4
+ %
5
+ % z(t) = alpha * u(t)
6
+ %
7
+ % Where alpha is a parameter estimated from the data.
8
+ %
9
+ %
10
+ % Inputs:
11
+ %
12
+ % P - parameter structure
13
+ % M - model structure
14
+ % U - experimental timing
15
+ % action - (optional) the action to performm. If not provided, the
16
+ % predicted BOLD and neuronal timeseries are returned.
17
+ %
18
+ % -------------------------------------------------------------------------
19
+ % FORMAT [y,Z] = spm_prf_fcn_template(P,M,U)
20
+ % Return the BOLD and neuronal predicted timeseries
21
+ %
22
+ % P parameters
23
+ % M,U model, inputs
24
+ %
25
+ % y fMRI time series
26
+ % Z neuronal response
27
+ % -------------------------------------------------------------------------
28
+ % FORMAT P = spm_prf_fcn_template(P,M,U,'get_parameters')
29
+ % Return the given parameters corrected for display
30
+ %
31
+ % P parameters
32
+ % M,U model, inputs
33
+ % -------------------------------------------------------------------------
34
+ % FORMAT tf = spm_prf_fcn_template(P,M,U,'is_above_threshold',Cp,v)
35
+ % Return whether the model with parameters P and covariance Cp passes an
36
+ % arbitrary threshold for display
37
+ %
38
+ % P parameters
39
+ % M,U model, inputs
40
+ % Cp parameter covariance matrix
41
+ % v voxel index
42
+ % -------------------------------------------------------------------------
43
+ % FORMAT x = spm_prf_fcn_template(P,M,U,'get_response',xy)
44
+ % Return the instantaneous response of the PRF at coordinates xy
45
+ %
46
+ % P parameters
47
+ % M,U model, inputs
48
+ % xy [2xn] vector of coordinates to evaluate the PRF
49
+ % -------------------------------------------------------------------------
50
+ % FORMAT [pE,pC] = spm_prf_fcn_template(P,M,U,'get_priors')
51
+ % Return the priors for the model. Importantly, this defines which
52
+ % parameters are in the model.
53
+ %
54
+ % pE structure or vector of prior expectations
55
+ % pC prior covariance maitrx
56
+ %
57
+ % ---------------------------------------------------------------------
58
+ % Copyright (C) 2016 Peter Zeidman
59
+ % This program is free software: you can redistribute it and/or modify
60
+ % it under the terms of the GNU General Public License as published by
61
+ % the Free Software Foundation, either version 3 of the License, or
62
+ % (at your option) any later version.
63
+ %
64
+ % This program is distributed in the hope that it will be useful,
65
+ % but WITHOUT ANY WARRANTY; without even the implied warranty of
66
+ % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67
+ % GNU General Public License for more details.
68
+ %
69
+ % You should have received a copy of the GNU General Public License
70
+ % along with this program. If not, see <http://www.gnu.org/licenses/>.
71
+ % ---------------------------------------------------------------------
72
+
73
+ if nargin < 4
74
+ % Integrate the model over time and return neuronal timeseries z and
75
+ % BOLD timeseries y. As an example, here we have neuronal model
76
+ % z(t) = alpha, where alpha is an estimated parameter.
77
+
78
+ % Number of volumes = inputs
79
+ n = length(U );
80
+
81
+ % Neural timeseries. A vector with one entry per microtime bin. The
82
+ % U.nbins field is injected automatially by spm_prf_analyse
83
+ z = zeros(1 ,U(1 ).nbins);
84
+
85
+ for t = 1 : n
86
+ % Microtime index for this volume
87
+ ind = U(t ).ind;
88
+
89
+ % pRF response
90
+ z(ind ) = P .alpha ;
91
+ end
92
+
93
+ % Integrate the BOLD model
94
+ Z.u= z ' ;
95
+ Z.dt= M .dt ;
96
+ y= spm_int(P ,M ,Z );
97
+
98
+ varargout{1 } = y ;
99
+ varargout{2 } = Z ;
100
+ else
101
+ % This section of the code provides information on the model, primarily
102
+ % for plotting purposes in spm_prf_review()
103
+
104
+ action = varargin{1 };
105
+
106
+ switch action
107
+ case ' get_parameters'
108
+ % Get the parameters with any corrections needed for
109
+ % display
110
+ varargout{1 } = P ;
111
+ case ' is_above_threshold'
112
+ % Return binary vector identifying whether each voxel is
113
+ % above some threshold for display
114
+ varargout{1 } = 1 ;
115
+ case ' get_response'
116
+ % Return the prediction of the model at coordinates xy
117
+ xy = varargin{2 };
118
+ varargout{1 } = ones(1 ,length(xy ));
119
+ case ' get_priors'
120
+ % Return a structure containing the priors
121
+ pE.alpha = 1 ;
122
+ pC.alpha = 1 ;
123
+ varargout{1 } = pE ;
124
+ varargout{2 } = pC ;
125
+ case ' glm_initialize'
126
+ % (Optional) Return parameters initialized using some
127
+ % rapid initial search on timeseries y
128
+ y = varargin{2 };
129
+
130
+ varargout = P ;
131
+ otherwise
132
+ error(' Unknown action' );
133
+ end
134
+ end
0 commit comments