Skip to main content
. Author manuscript; available in PMC: 2018 Oct 15.
Published in final edited form as: Neuroimage. 2017 Jun 20;180(Pt A):188–202. doi: 10.1016/j.neuroimage.2017.06.035

Algorithm A.1.

Feature weighted receptive field method. In the following, tensors are boldfaced and the dimensions of a tensor are always displayed in square bracket after its name. A change in the order of the dimension implies a transpose of the tensor and an arrow in the dimensions indicates broadcasting to a certain size.

  1: procedure Generate modelspace tensor(ℱ, 𝒢): # Evaluate the spatial integrals of Eq 2 for all feature maps (ℱ) and pooling field (𝒢) candidates and resolutions.
  2:    for (Fl, gl) ∈ (ℱ, 𝒢) do
  3:      Ml ← TensorDot(Fl[n, Kl, xl, yl], gl[G, xl, yl], axis = [[2, 3], [1, 2]])
  4:    M ← Concatenate((Ml[n, Kl, G], ∀lL), axis = 1)
  5:    M ← Z-Score(M, axis = 0)
  6:    return M[n, K, G]
  7:
  8: procedure Generate voxel predictions(M, w):
  9:     ← Batched-TensorDot(M[G, n, K], w[G, V, K], axis = [[2], [2]])
10:    return R̂[n, V, G]
11:
12: procedure Loss(M, R, w):
13:     ← Generate voxel predictions(M, w)
14:    return L2-norm([n, V, G] − R[n, V, 1 → G])[V, G]
15:
16: procedure Optimize FWRF model parameters(M, R, winit): # M is the precalculated model-space tensor and R is the target voxel activity.
17:    mbestzeros[V] # best models initialization
18:    wbestzeros[V, K] # best weights initialization
19:    sbestinf[V] # best scores initialization
20:    for Vb ∈ Batch(V) do # take a batch of voxels
21:      for Gb ∈ Batch(G) do # take a batch of candidates f.p.f.
22:        wbwinit[1 → Gb, Vb, K]
23:        for e ∈ 1‥epochs do
24:          sbzeros[Vb, Gb] # scores for this batch
25:          for nb ∈ Batch(ntrain) do # take a batch from the training samples
26:             wbwbλdLossdw(M[nb,K,Gb],R[nb,Vb],wb[Gb,Vb,K])
27:          for nb ∈ Batch(nholdout) do # take a batch from the holdout samples
28:            sbsb + Loss(M[nb, K, Gb], R[nb, Vb], wb[Gb, Vb, K])
29:          for υ ∈ Element(Vb) do # for all voxels
30:            g ← argmin(sb[υ, Gb]) # get the best model for this batch
31:            if sb[υ, g] < sbest[υ] then
32:              mbest[υ] ← g
33:              wbest[υ, K] ← wb[g, υ, K]
34:              sbest[υ] ← sb[υ, g]
35:    return mbest, wbest, sbest