How to keep continuously extracting single data points from a wave as it is being acquired real-time

Hi. 
I want to continuously extract every single data point from a wave as the wave is being acquired real-time in Igor Pro 8. I intend to use a code that will keep doing this for me. 

Broad objective:
I am sampling a wave at 50 microseconds for 30 seconds. So it should have 600,000 data points. I want the code to detect when a point crosses a threshold and then trigger an external stimulus. For this I want to extract every point as it is getting acquired. We are also using a custom package that interacts with Igor to perform electrophysiological functions.

I am new to Igor and coding; therefore, I am searching for a code or where to read about this information in the manual. As of now, I am unable to do this because Igor completes the full wave acquisition and then allows any operations. 

Any leads in this regard would be greatly appreciated.

 

Welcome to the forum!

It depends a bit on how the data acquisition is being carried out. You mentioned electrophysiology - do you know if you're using the NIDAQ tools XOP to acquire the data? Your Igor code will be calling things like `DAQmx_Scan` if it is. If so, you likely will need to tell the scanning operation to by carried out in the background, which I think should leave you free to examine the contents of the wave as the data comes in, as opposed to having it wait until acquisition is complete.

There are other things you could probably do, like setting up triggers that depend on the analog input level, but that will probably require a bit more coding and some changes to how your hardware is connected. 

I would just add to Ben's second paragraph, that using a level trigger requires a NI-DAQ device that supports it. Many NI devices lack that support.

Keep in mind that most acquisition devices store the sampled data to a hardware buffer and when Igor makes a call to acquire data, it's reading from that hardware buffer. Even if your Igor code is written to frequently pull data from the hardware buffer into Igor, there will always be a lag between the time that the threshold is passed and Igor has any chance of being able to figure that out. Depending on how much lag is tolerable, you may need to do this using hardware, not software.

For example, if you're trying to do dynamic clamp, I don't think there's any way you can drive that with Igor in the loop--there would just be too much lag. You would need a hardware device that supports dynamic clamp, and your Igor based software would configure the hardware device to use dynamic clamp, but the actual algorithm would run on the hardware.

Thank you all for your extremely valuable suggestions. I checked the background coding of the package integrated in Igor to control acquisition. As mentioned by Ben, there seems to be a bug in the “DAQmx_scan” code (mentioned as a comment in the code itself). Igor freezes completely when acquisition is taking place. We use ITC-18 DAQ and it is possibly playing a role in this problem as stated by all of you. 

We will take your suggestions and see if there are other DAQ devices that could help or any other changes in the hardware. 

As mentioned by Ben, there seems to be a bug in the “DAQmx_scan” code (mentioned as a comment in the code itself). Igor freezes completely when acquisition is taking place.

Not a bug, actually. There are two ways to do a scan- start it and suspend Igor execution until it finishes, or start it and return to Igor. Use a background task or a hook function to learn when it finishes. You can access the data wave while acquisition is taking place.

Another way to look at the most recently acquired data is to do acquisition into an Igor FIFO. DisplayHelpTopic "FIFOs and Charts".

In reply to by johnweeks

johnweeks wrote:

Not a bug, actually. There are two ways to do a scan- start it and suspend Igor execution until it finishes, or start it and return to Igor. Use a background task or a hook function to learn when it finishes. You can access the data wave while acquisition is taking place.

Another way to look at the most recently acquired data is to do acquisition into an Igor FIFO. DisplayHelpTopic "FIFOs and Charts".

 

 

Thank you for this. I will definitely look into this.