Fast-oopsi was developed by joshua vogelstein in 2009, which is now widely used to extract neuron spike activities from calcium fluorescence signals. Here, we propose detailed implementation of the fast-oopsi algorithm in python programming language. Some corrections are also made to the original fast-oopsi paper. Index Terms python, fast-oopsi, spikes, calcium fluorescence, connectomics I. FAST-OOPSI, A BRIEF VIEW Oopsi, from vogelstein [1], [2], is a family of optimal optical spike inference algorithms. Here, we focus on the development of the fast-oopsi, which was originally published in [2]. We will port the MATLAB implementation to python. Sec II, III, IV, V and VI are digests from the original paper by vogelstein [1]. The python implementation, py-oopsi, can be obtained at https://github.com/liubenyuan/py-oopsi. II. CALCIUM FLUORESCENCE MODEL Let F be a one-dimensional fluorescence trace. At time t, the fluorescence measurement Ft is a linear Gaussian function of the intracellular calcium concentration [Ca]t at that time: Ft = α[Ca ]t + β + et, et ∼ N (0, σ) (1) Benyuan Liu is with The Department of Biomedical Engineering, Fourth Military Medical University, Xi’an, 710032, China. E-mail: liubenyuan@gmail.com, lbyoopp@163.com Manuscript received May 26, 2014. May 26, 2014 DRAFT TECHNICAL REPORT, DEPT. BME, FMMU, 2014 2 α determines the scale of the signal, β absorbs the offset. α and β may be learned independently per neuron. The noise et is assumed to be i.i.d distributed. The calcium concentration jumps A μM after each spike and decays back down to baseline Cb μM, with time constant τ , [Ca]t+1 = (1−∆/τ)[Ca]t + (∆/τ)Cb +Ant, (2) where ∆ is the frame interval. The scale A and α, baseline Cb and β are not identifiable, therefore, we may let A = 1 and Cb = 0 without loss of generality. nt indicates the number of times the neuron spiked in time t, we may also write it as a delta function δt. Finally, letting γ = (1−∆/τ), we have Ct = γCt−1 + nt (3) and (the filtering model) C[z] = 1 1− γz−1 [z] (4) Note that Ct does not refer to the absolute intracellular concentration, but rather, a relative measure [2]. The simulated calcium trace can be generated if we synthetically generate nt from a probability distribution. To complete the generative model, we assume spikes are sampled according to a Poisson distribution, nt ∼ Poisson(λ∆) (5) where λ∆ is the expected firing rate per bin, ∆ is included to ensure that the expected firing rate is independent of the frame rate [2]. III. BAYES MODEL We aim to find the most likely spike trains n̂ given the fluorescence F, n̂ = argmax nt∈N0,∀t p(n|F) (6) Using Bayes’ rule, p(n|F) = 1 p(F) · p(F|n)p(n) (7) given that p(F) merely scales the results, we rewrite (6) as, n̂ = argmax nt∈N0,∀t p(F|n)p(n) (8)