{
  "id": 8036,
  "title": "Py-oopsi: the python implementation of the fast-oopsi algorithm",
  "url": "/competitions/connectomics/discussion/8036",
  "author_name": "",
  "post_date": "2014-05-06T03:54:32.860Z",
  "votes": 1,
  "comment_count": 7,
  "views": 2556,
  "content": "<p>Hi, all,</p>\n<p>I implemented the fast oopsi algorithm (developed by J. Vogelstein in 2009), which was used to infer neuron spikes from noisy calcium fluorescence, in python! You may obtain the code on the github page:</p>\n<p><a href=\"https://github.com/liubenyuan/py-oopsi\">https://github.com/liubenyuan/py-oopsi</a></p>\n<p>I think it might be too late for this competition&nbsp;:(</p>\n<p>Any suggestions, comments on the algorithm, coding styles are all welcome.</p>\n<p><img src=\"http://liubenyuan.github.io/pics/pyoopsi-demo.png\" alt=\"demo\" width=\"400\" height=\"560\"></p>\n<p>Liu Benyuan</p>",
  "messages": [
    {
      "id": "43906",
      "postDate": "05/06/2014 03:54:32",
      "content": "<p>Hi, all,</p>\n<p>I implemented the fast oopsi algorithm (developed by J. Vogelstein in 2009), which was used to infer neuron spikes from noisy calcium fluorescence, in python! You may obtain the code on the github page:</p>\n<p><a href=\"https://github.com/liubenyuan/py-oopsi\">https://github.com/liubenyuan/py-oopsi</a></p>\n<p>I think it might be too late for this competition&nbsp;:(</p>\n<p>Any suggestions, comments on the algorithm, coding styles are all welcome.</p>\n<p><img src=\"http://liubenyuan.github.io/pics/pyoopsi-demo.png\" alt=\"demo\" width=\"400\" height=\"560\"></p>\n<p>Liu Benyuan</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "43914",
      "postDate": "05/06/2014 04:39:02",
      "content": "<p>Below is a demo to extract spikes from calcium fluorescence signals. Data set is small_04, where&nbsp;the ground truth says that&nbsp;([9,19,23,31,36,46,60,69]) connected to [34]. A segment data (from 152390:153190) is shown. Py-oopsi can also be used to extract the simulataneously bursts from the mean fluorescence trace of all neurons.&nbsp;</p>\n<p><img src=\"http://liubenyuan.github.io/pics/connectomics-demo.png\" alt=\"Connectomics Demo on \" width=\"600\" height=\"840\"></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "43988",
      "postDate": "05/06/2014 12:31:56",
      "content": "<p>Great !!</p>\n<p>The challenge just ended, so it might be a bit late to use it in there, but I will certainly take a look at the code.</p>\n<p>I&nbsp;think some participants also used spike inference methods in the challenge, it will be good to check and compare the different methods on the same datasets.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44214",
      "postDate": "05/07/2014 21:28:29",
      "content": "<p>Well, we also ended up writing a Python version of fast non-negative deconvolution, which is now freely available <a href=\"https://github.com/alimuldal/PyFNND\">here</a>. We found that we could get nice performance gains by wrapping LAPACK's `dgtsv` tridiagonal solver to compute the direction for each Newton step, rather than using standard LU factorization such as with scipy's `spsolve`.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44225",
      "postDate": "05/08/2014 01:52:55",
      "content": "<p>Great !</p>\n<p>Mime was a simply, bare bone implementation of the fast-oopsi algorithm, where only subroutine <strong>&quot;initialize parameters&quot;, &quot;MAP estimate&quot;, &quot;estimate parameters&quot;</strong> are used. I do not use dgtsv which might bring performance improvements. I found &quot;test_trisolve&quot; func in your code, have you test the ratio of speed up using&nbsp;<strong>trisolve</strong> and&nbsp;<strong>sparse.linalg.spsolve</strong> ?</p>\n<p>And one more question, how do you use the spikes inferred from the calcium trace ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44282",
      "postDate": "05/09/2014 00:03:27",
      "content": "<p>I've added a simple benchmarking script to the <strong>_tridiag_solvers</strong> module. Here's the speed up for a range of different array sizes:</p>\n<p style=\"text-align: center\"><img src=\"http://i.imgur.com/SgvfNXA.png\" alt=\"Benchmarking: dgtsv vs spsolve\" width=\"565\" height=\"424\"></p>\n<p>In practice the difference is even greater, since dgtsv allows us to avoid the extra overhead involved in constructing/updating the sparse matrices that are required by spsolve (dgtsv just takes three 1D arrays for the matrix diagonals), and we can also solve in-place to avoid creating additional copies.</p>\n<p>As for your second question, we just thresholded the continuous estimate of spike probability that FNND returns. We did this based on the average expected firing rate for a neuron in this network model (we ended up running some spiking network simulations ourselves, using the code that the organisers provided <a href=\"https://github.com/dherkova/te-causality/blob/connectomics_challenge/simulation/adaptive-multibursts.py\">here</a>, so we had comparable datasets where we had access to the actual spike trains). We then basically just threw these discrete estimated spike trains at GTE, more or less as described in the Stetter paper.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44283",
      "postDate": "05/09/2014 00:15:31",
      "content": "<p>Cool !! I will surely learn more python coding from your implementation :)</p>\n<p>I do not think GTE might be a better&nbsp;choice, as the firings are sparse and the same-bin effect is not evident between simulataneously bursts.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44284",
      "postDate": "05/09/2014 00:32:50",
      "content": "<p>True, I don't think that there's a great deal of mileage in GTE, but it was the most robust method we were able to implement in time. We were playing around with a few other information theoretic measures which consider multiple nodes rather than just pairs, but it's very tricky to get these to work robustly, since the dimensionality over which you have to compute conditional probabilities tends to explode. As far as the bursts are concerned, I think that there's really not much information that can be obtained during these time bins (at least not without a much higher sample rate).</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 43914,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "05/06/2014 04:39:02",
      "content": "<p>Below is a demo to extract spikes from calcium fluorescence signals. Data set is small_04, where&nbsp;the ground truth says that&nbsp;([9,19,23,31,36,46,60,69]) connected to [34]. A segment data (from 152390:153190) is shown. Py-oopsi can also be used to extract the simulataneously bursts from the mean fluorescence trace of all neurons.&nbsp;</p>\n<p><img src=\"http://liubenyuan.github.io/pics/connectomics-demo.png\" alt=\"Connectomics Demo on \" width=\"600\" height=\"840\"></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 43988,
      "author_name": "orlandi",
      "author_url": "",
      "post_date": "05/06/2014 12:31:56",
      "content": "<p>Great !!</p>\n<p>The challenge just ended, so it might be a bit late to use it in there, but I will certainly take a look at the code.</p>\n<p>I&nbsp;think some participants also used spike inference methods in the challenge, it will be good to check and compare the different methods on the same datasets.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44214,
      "author_name": "alistairmuldal",
      "author_url": "",
      "post_date": "05/07/2014 21:28:29",
      "content": "<p>Well, we also ended up writing a Python version of fast non-negative deconvolution, which is now freely available <a href=\"https://github.com/alimuldal/PyFNND\">here</a>. We found that we could get nice performance gains by wrapping LAPACK's `dgtsv` tridiagonal solver to compute the direction for each Newton step, rather than using standard LU factorization such as with scipy's `spsolve`.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44225,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "05/08/2014 01:52:55",
      "content": "<p>Great !</p>\n<p>Mime was a simply, bare bone implementation of the fast-oopsi algorithm, where only subroutine <strong>&quot;initialize parameters&quot;, &quot;MAP estimate&quot;, &quot;estimate parameters&quot;</strong> are used. I do not use dgtsv which might bring performance improvements. I found &quot;test_trisolve&quot; func in your code, have you test the ratio of speed up using&nbsp;<strong>trisolve</strong> and&nbsp;<strong>sparse.linalg.spsolve</strong> ?</p>\n<p>And one more question, how do you use the spikes inferred from the calcium trace ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44282,
      "author_name": "alistairmuldal",
      "author_url": "",
      "post_date": "05/09/2014 00:03:27",
      "content": "<p>I've added a simple benchmarking script to the <strong>_tridiag_solvers</strong> module. Here's the speed up for a range of different array sizes:</p>\n<p style=\"text-align: center\"><img src=\"http://i.imgur.com/SgvfNXA.png\" alt=\"Benchmarking: dgtsv vs spsolve\" width=\"565\" height=\"424\"></p>\n<p>In practice the difference is even greater, since dgtsv allows us to avoid the extra overhead involved in constructing/updating the sparse matrices that are required by spsolve (dgtsv just takes three 1D arrays for the matrix diagonals), and we can also solve in-place to avoid creating additional copies.</p>\n<p>As for your second question, we just thresholded the continuous estimate of spike probability that FNND returns. We did this based on the average expected firing rate for a neuron in this network model (we ended up running some spiking network simulations ourselves, using the code that the organisers provided <a href=\"https://github.com/dherkova/te-causality/blob/connectomics_challenge/simulation/adaptive-multibursts.py\">here</a>, so we had comparable datasets where we had access to the actual spike trains). We then basically just threw these discrete estimated spike trains at GTE, more or less as described in the Stetter paper.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44283,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "05/09/2014 00:15:31",
      "content": "<p>Cool !! I will surely learn more python coding from your implementation :)</p>\n<p>I do not think GTE might be a better&nbsp;choice, as the firings are sparse and the same-bin effect is not evident between simulataneously bursts.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44284,
      "author_name": "alistairmuldal",
      "author_url": "",
      "post_date": "05/09/2014 00:32:50",
      "content": "<p>True, I don't think that there's a great deal of mileage in GTE, but it was the most robust method we were able to implement in time. We were playing around with a few other information theoretic measures which consider multiple nodes rather than just pairs, but it's very tricky to get these to work robustly, since the dimensionality over which you have to compute conditional probabilities tends to explode. As far as the bursts are concerned, I think that there's really not much information that can be obtained during these time bins (at least not without a much higher sample rate).</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "43906": "",
    "43914": "",
    "43988": "",
    "44214": "",
    "44225": "",
    "44282": "",
    "44283": "",
    "44284": ""
  },
  "source": "meta"
}