Skip to main content
. 2017 Aug 3;13(8):e1005685. doi: 10.1371/journal.pcbi.1005685

Algorithm 1. NMF algorithm using localization constraints and spatio-temporal decimation.

Required: data YR+D×T, N neuron centers, number of iterations I˜ and I
1: successively take mean of e.g. 30 frames        ⊳ operate on decimated data
2: initialize centers using greedy (or group lasso) method from [8]
3: downscale spatially using local mean: YY˜R+D˜×T˜
4: generate patches P˜ around centers
5: initialize spatial background as 20% percentile, neural shapes as Gaussians within patch: A˜R+D˜×(N+1)
6: initialize temporal background as 1T˜, neural activities as data at centers: C˜R+(N+1)×T˜
7: fori = 1, …, I˜do
8:  C˜ ← HALSactivity(Y˜,A˜,C˜)
9:  A˜ ← HALSshape(Y˜,A˜,C˜,P˜)
10: initialize activities CR+(N+1)×T as mean of C˜ for each neuron     ⊳ back to full data
11: initialize shapes AR+D×(N+1) by zero-order-hold upsampling of A˜
12: generate patches P
13: fori = 1, …, Ido
14:  C ← HALSactivity(Y, A, C, 5)          ⊳ note the increased inner iterations
15:  A ← HALSshape(Y, A, C, P, 5)
16: denoise C using OASIS [18]
17: returnA, C
1: function HALSactivity(Y, A, C, I = 1) 1: function HALSshape(Y, A, C, P, I = 1)
2:  U = AY 2:  U = CY
3:  V = AA 3:  V = CC
4:  fori = 1, …, Ido 4:  fori = 1, …, Ido
5:   forn = 1, …, Ndo 5:   forn = 1, …, N + 1 do
6:    Cn,:max(0,Cn,:+Un,:-jVn,jCj,:Vn,n) 6:    An,:Pn,:max0,(An,:+Un,:ΣjVn,jAj,:Vn,n)
7:   CN+1,:CN+1,:+UN+1,:-jVN+1,jCj,:VN+1,N+1 7:
8:  returnC 8:  returnA