New to Forum and Bonsai. Single Cell online spike tracking

732 views
Skip to first unread message

Nacho Sanguinetti

unread,
Mar 2, 2016, 9:06:14 AM3/2/16
to Bonsai Users

Hey all,

My name is Nacho, I'm starting to play with bonsai for a couple of projects. I've been hitting a couple of walls because of my lack of intuitive understanding of how things work in the background. 
Watched the Tutorials, they were great, and i'm half way.

Project 1

In the lab we do single cell juxtacelllular recording in freely moving animals. I'm trying to setup for online tracking. This was easily solved since we use LED's on the animals head. We can now visualize the animals trajectory online to get an idea of the coverage that we have for any given cell. 
I would want to extend this further, and be able to visualize online the spikes of our single cell in the location in space where they are produced. So, end result would be to have the video of the rat moving and an overlay of the trajectory (visualizer (or python transform) works well for this) , and on top of that the spikes as they occur in space. 
I  haven't done this yet. I want to figure out what would be the easiest route.

1.a Hardware.

Has anybody written or is writing a Spike2 package for bonsai? Is there any plug and play DAQ that one can use for single cell electrophysiology? Is it possible to use Arduino as DAQ for single cell electrophysiological signal?

1. b Workflow

As far as I can tell. I would have to get the tracking location based on the timing of the spike and then use a python transform to plot it on top of the image? 


Thanks



Nacho

goncaloclopes

unread,
Mar 2, 2016, 9:57:05 AM3/2/16
to Bonsai Users
Hi Nacho and welcome to the forums!

Don't worry about the walls, we're constantly trying to find ways to take them down, it only gets better :-)

Ok, here we go:

1.a Hardware.

Has anybody written or is writing a Spike2 package for bonsai? Is there any plug and play DAQ that one can use for single cell electrophysiology? Is it possible to use Arduino as DAQ for single cell electrophysiological signal?

Yes, there are currently three plug-and-play DAQ systems you can use with Bonsai:

c) NI-DAQ acquisition cards

If you are using a) or b) you can just install the Bonsai - Ephys package and use the Rhd2000EvalBoard source to stream the data into Bonsai. There are a couple of tutorials in the forum for this (e.g. see here and here).

If you are using c) let me know and I will give you a custom package that can get you started really fast.

Either way, once you have the data you can use FrequencyFilter and DetectSpikes modules in order to get discrete spike waveforms for both single or multi-channel data.

1. b Workflow

As far as I can tell. I would have to get the tracking location based on the timing of the spike and then use a python transform to plot it on top of the image? 

This is also already been asked in the past with a couple of solutions, but I don't know if anyone has really got it working. You can get started here, but I would love to hear back if you really are able to get it working or if you get stuck somewhere.

Hope this helps and let me know how it turns out!
Cheer

Nacho Sanguinetti

unread,
Mar 2, 2016, 10:34:57 AM3/2/16
to Bonsai Users
Thanks Gonzalo,
I need something that adapts to what we use now. This is a pipette electrode being held by a minuature manipulator, conected to a NPI electronics miniaturized headstage for single cell, this in turn is connected to a NPI amplifier, then to spike 2, then to computer.  You can see here the methods http://dx.doi.org/10.1038/nprot.2014.161

I could split the analog signal after it is amplified and maybe use a NI DAQ then.  

Regarding Workflow. The good thing is that its only one channel, and the spikes a very big, so this should be feasible to do it in Bonsai alone. Okay, frequencyFilter, Detectspikes, then combine with the tracking data. I'll try playing with this as soon as I have the data in there. If I get anything I'll let you know.

Thanks again.

Nacho

Adam Kampff

unread,
Mar 2, 2016, 10:58:16 AM3/2/16
to Nacho Sanguinetti, Bonsai Users
Hi Nacho,
   If you are able to split the amplified signal, only have 1-channel with big juxta-spikes, and only need to visualize these obvious spikes with a time-resolution similar to the video tracking, then I would suggest using the ADC (microphone) input of the sound card.

   For more precision/functionality, see if you can get Spike2 to provide an API for their acquisition card. ;)

Cheers,
Adam



--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/bonsai-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/0e581a54-de7e-4806-a505-9f55421c6329%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nacho Sanguinetti

unread,
Mar 2, 2016, 11:08:05 AM3/2/16
to Bonsai Users, ji.sang...@gmail.com
Oh, hahaha, that sounds like a good first approximation! Why didn't I think of this... Thanks Adam

Andrew Macaskill

unread,
Mar 3, 2016, 5:54:26 PM3/3/16
to Bonsai Users
hello, I was wondering if I may be able to get my hands on the NIDAQ custom package mentioned here?

I am new to bonzai, and looking to play around with some combinations of video and time series data, and have a bunch of different NI interfaces that it would be great to be able to use!

Thanks for the cool program

a

goncaloclopes

unread,
Mar 3, 2016, 6:11:10 PM3/3/16
to Bonsai Users
Hi Andrew and welcome to the forums!

I am attaching the custom NI-DAQ package to this answer. This is an experimental package, and it's been a while since I've tweaked it so let me know if you find any issues. You need two things in order to get it up and running:

1) Install the NI-DAQmx .NET Application Development support. This should be provided as an optional install on your NI-DAQmx driver CD (see instructions here).

2) Install the attached custom Bonsai package (.nupkg). You can find a tutorial for this at the Bonsai wiki pages.

Let me know if you get stuck somewhere. It's been a while since I've tried to run this package.
Hope this helps,
Bonsai.NationalInstruments.2.0.0-ctp3.nupkg

Andrew Macaskill

unread,
Mar 4, 2016, 8:54:21 AM3/4/16
to Bonsai Users
Great - Thanks! 

I will let you know how I get on

a

Andrew Macaskill

unread,
Mar 4, 2016, 2:57:34 PM3/4/16
to Bonsai Users
Hi, 

I now have a properly idiotic question - i can visualise simple analogue data input through the Ni card now really nicely with the NI package - but for downstream processing I cannot for the life of me work out how the data is handled in bonzai - when I try to output the source.item (e.g. val0) it gives an ambiguous match error. I reckon I am doing something idiotic here, but cant figure it out - i cant seem to find where the data is!. Can you tell me how I can read out the different channels as an array or matrix in bonzai and save them to e.g. a csv?


thanks!

a


On Thursday, 3 March 2016 23:11:10 UTC, goncaloclopes wrote:

goncaloclopes

unread,
Mar 5, 2016, 3:47:53 AM3/5/16
to Bonsai Users
Hi Andrew,

If I understand it correctly, you were able to visualize the data already in Bonsai, right? If my memory is right, the output of the NI source is already a stream of data matrices, where rows are channels and columns are samples. You can check this by right-clicking on the node, and checking if the output is an OpenCV.Net.Mat. If this is the case, you can now use all the signal processing, reading and writing operators specified in the Dsp package. For example you can use FrequencyFilter to filter out a specific frequency range from the signal, or DetectSpikes to isolate spike waveforms, etc. Each node should give you a small text description of what they can do.

If you want to isolate individual channels of the matrix, you can use the SelectChannels node, or Submatrix, in case you want to select a rectangular sub-region (similar to Crop for image processing). For recording you can use MatrixWriter, which will dump the contents of the input data matrices to disk using either a column-major or row-major layout. For streaming data, I recommend column-major for a more sane layout at the buffer boundaries.

Finally, if you want to individually access the data elements for doing custom processing, you can write your own PythonTransform or PythonSink that takes the input and indexes it. The easiest way to index these multi-dimensional matrix values is to use the GetReal method. However, I don't recommend doing bulk processing of the data in this way (i.e. processing that requires you to loop through the elements of the array), as this is MUCH slower than using the optimized bulk processing routine of either the Dsp package or OpenCV itself.

Hope this helps,
G
Reply all
Reply to author
Forward
0 new messages