Skip to content

Commit 56363d0

Browse files
committed
updated comments | improved naming
1 parent cf24d42 commit 56363d0

File tree

4 files changed

+71
-67
lines changed

4 files changed

+71
-67
lines changed

code/matlab/HGR.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
% - eta : learning rate (inverse of regularization parameter)
3939
%
4040
% optional inputs are
41-
% - l_kernel : length of convolution kernel (two-gamma hresults)
41+
% - l_kernel : length of convolution kernel (two-gamma hrf)
4242
%
4343
% this class has the following functions
4444
%
@@ -177,8 +177,8 @@ function ridge(self,data,stimulus)
177177

178178
function results = get_parameters(self,varargin)
179179
% estimates population receptive field (2D Gaussian) parameters
180-
% based on raw receptive fields given by features and their
181-
% regression weights.
180+
% based on receptive fields given by linear combination of
181+
% features and their weighted by their regression coefficients.
182182
%
183183
% returns a structure with the following fields
184184
% - corr_fit
@@ -188,7 +188,7 @@ function ridge(self,data,stimulus)
188188
% - eccentricity
189189
% - polar_angle
190190
%
191-
% each field is a column vector with number of voxels elements
191+
% each field is a column vector with elements = number of voxels
192192
%
193193
% optional inputs are
194194
% - n_batch : batch size (default = 10000)
@@ -256,8 +256,7 @@ function ridge(self,data,stimulus)
256256

257257
results.sigma(batch) = [m_image, sqrt(results.mu_x(batch).^2 +...
258258
results.mu_y(batch).^2)] * beta;
259-
260-
259+
261260
end
262261

263262
if isempty(v)
@@ -294,7 +293,7 @@ function set_parameters(self,parameters)
294293
% change parameters of the class
295294
%
296295
% required input
297-
% - parameters: a structure containing all parameters required
296+
% - parameters: a structure containing all parameters
298297
% required by the class
299298

300299
self.r_stimulus = parameters.r_stimulus;
@@ -312,24 +311,27 @@ function reset(self)
312311
% reset all internal states of the class
313312
%
314313
% use this function prior to conducting real time estimation
315-
% for a new set of data
314+
% for a new set of data (new run)
316315
self.theta = zeros(self.n_features,self.n_voxels);
317316
self.phi_processor.reset();
318317
self.data_processor.reset();
319318
end
320319

321320
function [mask,corr_fit] = get_best_voxels(self,data,stimulus,varargin)
322-
% uses blocked cross-validation to obtain the best fitting
323-
% voxels and returns a mask as well the correlation fit per
324-
% voxel
321+
% uses blocked cross-validation to obtain the best voxels
322+
% and returns a binary mask as well the correlation fit per voxel
325323
%
326324
% required inputs are
327325
% - data : a matrix of empirically observed BOLD timecourses
328326
% whose rows correspond to time (volumes).
329327
% - stimulus: a time by number of pixels stimulus matrix.
330328
%
331329
% optional inputs are
332-
% - type : cutoff type (default = 'percentile')
330+
% - type : cutoff type
331+
% > 'percentile' (default)
332+
% > 'threshold'
333+
% > 'number'
334+
%
333335
% - cutoff : cutoff value (default = 95)
334336
% - n_splits: number of data splits (default = 4)
335337

code/matlab/IRM.m

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
% optional inputs are
3838
% - hrf : either a column vector containing a single hemodynamic
3939
% response used for every voxel;
40-
% or a matrix with a unique hemodynamic response along
40+
% or a tensor with a unique hemodynamic response along
4141
% its columns for each voxel.
4242
% By default the canonical two-gamma hemodynamic response
4343
% function is generated internally based on the scan parameters.
@@ -96,21 +96,21 @@
9696
self.two_gamma = @(t) (6*t.^5.*exp(-t))./gamma(6)...
9797
-1/6*(16*t.^15.*exp(-t))/gamma(16);
9898

99-
self.f_sampling = p.Results.parameters.f_sampling;
99+
self.f_sampling = p.corr_fitesults.parameters.f_sampling;
100100
self.p_sampling = 1/self.f_sampling;
101-
self.n_samples = p.Results.parameters.n_samples;
102-
self.n_rows = p.Results.parameters.n_rows;
103-
self.n_cols = p.Results.parameters.n_cols;
104-
self.n_slices = p.Results.parameters.n_slices;
101+
self.n_samples = p.corr_fitesults.parameters.n_samples;
102+
self.n_rows = p.corr_fitesults.parameters.n_rows;
103+
self.n_cols = p.corr_fitesults.parameters.n_cols;
104+
self.n_slices = p.corr_fitesults.parameters.n_slices;
105105
self.n_total = self.n_rows*self.n_cols*self.n_slices;
106106

107-
if ~isempty(p.Results.hrf)
108-
self.l_hrf = size(p.Results.hrf,1);
109-
if ndims(p.Results.hrf)==4
110-
self.hrf = reshape(p.Results.hrf,...
107+
if ~isempty(p.corr_fitesults.hrf)
108+
self.l_hrf = size(p.corr_fitesults.hrf,1);
109+
if ndims(p.corr_fitesults.hrf)==4
110+
self.hrf = reshape(p.corr_fitesults.hrf,...
111111
self.l_hrf,self.n_total);
112112
else
113-
self.hrf = p.Results.hrf;
113+
self.hrf = p.corr_fitesults.hrf;
114114
end
115115

116116
else
@@ -125,7 +125,7 @@
125125
% If a single hrf is used for every voxel, this function
126126
% returns a column vector.
127127
% If a unique hrf is used for each voxel, this function returns
128-
% a matrix with rows corresponding to time and the remaining
128+
% a tensor with rows corresponding to time and the remaining
129129
% dimensions reflecting the spatial dimensions of the data.
130130
if size(self.hrf,2)>1
131131
hrf = reshape(self.hrf,self.l_hrf,...
@@ -151,8 +151,8 @@
151151

152152
function set_hrf(self,hrf)
153153
% replace the hemodynamic response with a new hrf column vector
154-
% or a matrix whose rows correspond to time.
155-
% The remaining dimensionsneed to match those of the data.
154+
% or a tensor whose rows correspond to time.
155+
% The remaining dimensions need to match those of the data.
156156
self.l_hrf = size(hrf,1);
157157
if ndims(hrf)>2
158158
self.hrf = reshape(hrf,self.l_hrf,self.n_total);
@@ -212,14 +212,13 @@ function create_timecourse(self,FUN,xdata)
212212
% identifies the best fitting timecourse for each voxel and
213213
% returns the corresponding parameter values of the
214214
% input-referred model. The class returns a structure with two
215-
% fields.
216-
% - R: correlations (fit) - dimension corresponds to the
217-
% dimensions of the data.
218-
% - P: estimate parameters - dimension corresponds to the
215+
% fields
216+
% - corr_fit
217+
% - P: estimated parameters - dimension corresponds to the
219218
% dimensions of the data + 1.
220219
%
221220
% required inputs are
222-
% - data : a matrix of empirically observed BOLD timecourses
221+
% - data : a tensor of empirically observed BOLD timecourses
223222
% whose columns correspond to time (volumes).
224223
%
225224
% optional inputs are
@@ -234,9 +233,9 @@ function create_timecourse(self,FUN,xdata)
234233
addOptional(p,'mask',[]);
235234
p.parse(data,varargin{:});
236235

237-
data = single(p.Results.data);
238-
threshold = p.Results.threshold;
239-
mask = p.Results.mask;
236+
data = single(p.corr_fitesults.data);
237+
threshold = p.corr_fitesults.threshold;
238+
mask = p.corr_fitesults.mask;
240239

241240
data = reshape(data(1:self.n_samples,:,:,:),...
242241
self.n_samples,self.n_total);
@@ -253,7 +252,7 @@ function create_timecourse(self,FUN,xdata)
253252
data = zscore(data(:,mask));
254253
mag_d = sqrt(sum(data.^2));
255254

256-
results.R = zeros(self.n_total,1);
255+
results.corr_fit = zeros(self.n_total,1);
257256
results.P = zeros(self.n_total,self.n_predictors);
258257

259258
if size(self.hrf,2)==1
@@ -269,7 +268,7 @@ function create_timecourse(self,FUN,xdata)
269268
(mag_tc*mag_d(m));
270269
id = isinf(CS) | isnan(CS);
271270
CS(id) = 0;
272-
[results.R(v),j] = max(CS);
271+
[results.corr_fit(v),j] = max(CS);
273272
for p=1:self.n_predictors
274273
results.P(v,p) = self.xdata{p}(self.idx(j,p));
275274
end
@@ -290,15 +289,16 @@ function create_timecourse(self,FUN,xdata)
290289
(mag_tc*mag_d(m));
291290
id = isinf(CS) | isnan(CS);
292291
CS(id) = 0;
293-
[results.R(v),j] = max(CS);
292+
[results.corr_fit(v),j] = max(CS);
294293
for p=1:self.n_predictors
295294
results.P(v,p) = self.xdata(self.idx(j,p),p);
296295
end
297296

298297
progress(m / n_voxels * 20)
299298
end
300299
end
301-
results.R = reshape(results.R,self.n_rows,self.n_cols,self.n_slices);
300+
results.corr_fit = reshape(results.corr_fit,...
301+
self.n_rows,self.n_cols,self.n_slices);
302302
results.P = squeeze(...
303303
reshape(...
304304
results.P,self.n_rows,self.n_cols,self.n_slices,self.n_predictors));

code/matlab/PEA.m

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
% %%% DESCRIPTION %%%
2424
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2525
%
26-
% Phase-encoding analysis tool.
26+
% phase-encoding analysis tool.
2727
%
2828
% pea = PEA(parameters) creates an instance of the PEA class.
2929
%
@@ -131,18 +131,18 @@ function set_direction(self,direction)
131131
end
132132

133133
function results = fitting(self,data,varargin)
134-
% identifies phase and amplitude at stimulation frequency for
134+
% identifies phase and ampltitude at stimulation frequency for
135135
% each voxel and returns a structure with the following fields
136-
% - Phase
137-
% - Amplitude
138-
% - F_statistic
139-
% - P_value
136+
% - phase
137+
% - ampltitude
138+
% - f_statistic
139+
% - p_value
140140
%
141141
% the dimension of each field corresponds to the dimensions of
142142
% the data.
143143
%
144144
% required inputs are
145-
% - data : a matrix of empirically observed BOLD timecourses
145+
% - data : a tensor of empirically observed BOLD timecourses
146146
% whose rows correspond to time (volumes).
147147
%
148148
% optional inputs are
@@ -183,10 +183,10 @@ function set_direction(self,direction)
183183
Y_ = X * beta;
184184
residuals = data - Y_;
185185

186-
results.Phase = zeros(self.n_total,1);
187-
results.Amplitude = zeros(self.n_total,1);
186+
results.phase = zeros(self.n_total,1);
187+
results.ampltitude = zeros(self.n_total,1);
188188
results.F_stat = zeros(self.n_total,1);
189-
results.P_value = ones(self.n_total,1);
189+
results.p_value = ones(self.n_total,1);
190190

191191
df1 = 1;
192192
df2 = self.n_samples-2;
@@ -207,21 +207,21 @@ function set_direction(self,direction)
207207
MSM = (y-mu)'*(y-mu)/df1;
208208
MSE = (y-Dc)'*(y-Dc)/df2;
209209

210-
results.Phase(v) = angle(b(1)+b(2)*1i);
211-
results.Amplitude(v) = abs(b(1)+b(2)*1i);
210+
results.phase(v) = angle(b(1)+b(2)*1i);
211+
results.ampltitude(v) = abs(b(1)+b(2)*1i);
212212
results.F_stat(v) = MSM/MSE;
213-
results.P_value(v) = max(1-fcdf(MSM/MSE,df1,df2),1e-20);
213+
results.p_value(v) = max(1-fcdf(MSM/MSE,df1,df2),1e-20);
214214

215215
progress(m / n_voxels * 20)
216216
end
217217

218-
results.Phase = reshape(results.Phase,...
218+
results.phase = reshape(results.phase,...
219219
self.n_rows,self.n_cols,self.n_slices);
220-
results.Amplitude = reshape(results.Amplitude,...
220+
results.ampltitude = reshape(results.ampltitude,...
221221
self.n_rows,self.n_cols,self.n_slices);
222222
results.F_stat = reshape(results.F_stat,...
223223
self.n_rows,self.n_cols,self.n_slices);
224-
results.P_value = reshape(results.P_value,...
224+
results.p_value = reshape(results.p_value,...
225225
self.n_rows,self.n_cols,self.n_slices);
226226

227227
end

code/matlab/pRF.m

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
% optional inputs are
3939
% - hrf : either a column vector containing a single hemodynamic
4040
% response used for every voxel;
41-
% or a matrix with a unique hemodynamic response along
41+
% or a tensor with a unique hemodynamic response along
4242
% its columns for each voxel.
4343
% By default the canonical two-gamma hemodynamic response
44-
% function is generated internally based on the scan parameters.
44+
% function is generated internally based on provided parameters.
4545
%
4646
% this class has the following functions
4747
%
@@ -133,7 +133,7 @@
133133
% If a single hrf is used for every voxel, this function
134134
% returns a column vector.
135135
% If a unique hrf is used for each voxel, this function returns
136-
% a matrix with rows corresponding to time and the remaining
136+
% a tensor with rows corresponding to time and the remaining
137137
% dimensions reflecting the spatial dimensions of the data.
138138
if size(self.hrf,2)>1
139139
hrf = reshape(self.hrf,self.l_hrf,...
@@ -144,8 +144,8 @@
144144
end
145145

146146
function stimulus = get_stimulus(self)
147-
% returns the stimulus used by the class as a 3D matrix of
148-
% dimensions height-by-width-by-time.
147+
% returns the stimulus used by the class as a tensor
148+
% of rank 3 (height-by-width-by-time).
149149
stimulus = reshape(self.stimulus,self.r_stimulus,...
150150
self.r_stimulus,self.n_samples);
151151
end
@@ -161,8 +161,8 @@
161161

162162
function set_hrf(self,hrf)
163163
% replace the hemodynamic response with a new hrf column vector
164-
% or a matrix whose rows correspond to time.
165-
% The remaining dimensionsneed to match those of the data.
164+
% or a tensor whose rows correspond to time.
165+
% The remaining dimensions need to match those of the data.
166166
self.l_hrf = size(hrf,1);
167167
if ndims(hrf)>2
168168
self.hrf = reshape(hrf,self.l_hrf,self.n_total);
@@ -172,11 +172,11 @@ function set_hrf(self,hrf)
172172
end
173173

174174
function set_stimulus(self,stimulus)
175-
% provide a stimulus matrix.
175+
% provide a stimulus.
176176
% This is useful if the .png files have already been imported
177177
% and stored in matrix form.
178-
% Note that the provided stimulus matrix can be either 3D
179-
% (height-by-width-by-time) or 2D (height*width-by-time).
178+
% Note that the provided stimulus tensor can be either rank 3
179+
% (height-by-width-by-time) or rank 2 (height*width-by-time).
180180
if ndims(stimulus)==3
181181
self.stimulus = reshape(stimulus,...
182182
self.r_stimulus^2,...
@@ -192,7 +192,7 @@ function import_stimulus(self)
192192
% imports a series of .png files constituting the stimulation
193193
% protocol of the pRF experiment.
194194
% This series is stored internally in matrix format
195-
% (height-by-width-by-time).
195+
% (height*width-by-time).
196196
% The stimulus is required to generate timecourses.
197197

198198
[~,path] = uigetfile('*.png',...
@@ -238,7 +238,9 @@ function create_timecourses(self,varargin)
238238
% - min_slope : lower bound of RF size slope (default = 0.1)
239239
% - max_slope : upper bound of RF size slope (default = 1.2)
240240
% - css_exponent: compressive spatial summation (default = 1.0)
241-
% - sampling : eccentricity sampling type (default = 'log')
241+
% - sampling : eccentricity sampling type
242+
% > 'log' (default)
243+
% > 'linear'
242244

243245
progress('creating timecourses');
244246

@@ -314,7 +316,7 @@ function create_timecourses(self,varargin)
314316
% of the data.
315317
%
316318
% required inputs are
317-
% - data : a matrix of empirically observed BOLD timecourses
319+
% - data : a tensor of empirically observed BOLD timecourses
318320
% whose rows correspond to time (volumes).
319321
%
320322
% optional inputs are

0 commit comments

Comments
 (0)