11-28-2012 06:43 PM
I have a signal that approximates a noisy sine wave which I want to broadly break down into segments of negative and positive slope. As peak detection on the original trace is messy and the section of positive slope is complex, I plan to extract these features by working with the differential (the maximum velocity of the principle waveform is largely invariant and can be easily thresholded from the lower amplitude waveforms). I can easily detect the MIN peaks in the differential and now want to walk forward in the dataset to the first transition across the zero line and extract this timepoint to a new dataset. Does anyone have a script that I can modify for this purpose? Essentially, I want to trigger with an existing timepoint, iterate to the first timepoint where ti times ti+1 is negative and then write ti+1 to a new waveform. I also want to walk backwards to the the first transition across the zero line and extract this timepoint to a new dataset but this is secondary.
Thanks!
Matt
Solved! Go to Solution.
11-29-2012 05:35 PM
What aspect of an example algorithm are you specifically looking for? From the sound of it, you seem to know how to create the search algorithm which locates at which time value your differential data set values change from positive to negative or vice versa.
I think it would be a matter of traversing your data using a loop, searching for sign-change transitions, and adding the time value at those transitions to an array.
Are you looking for an algorithm to do this, or is there some other level of automation you were looking for?
Warm Regards,
11-30-2012 12:24 PM
Daniel,
I very much appreciate your response. Allow me to clarify where my problem lies.
I know how to design the algorithm in theory (and have successfully implemented it using excel) but have difficulty implementing it in vbs script. I therefore was looking for some sample code fragments that highlight each of the steps you've mentioned. Barring that, is there a good resource for learning the basics of this scripting language? I think this is actually my principle question.
To further clarify the strategy, this implementation generates a zero crossings array (time and value), merges this array with my existing peaks array, then writes to new arrays only the zero crossings that immediately precede (array1) and follow (array2) the peak.
Of course, being able to do this in a more direct fashion would be preferable (ie. iterate to a zero crossing, if it is followed by a peak exceeeding the threshold, write the zero crossing, peak and next zero crossing to three independent arrays. Otherwise, proceed to next zero crossing and repeat.
FYI - I am using my adaptation of thresholdpeaks.vbs to detect the peaks but don't fully understand the code. Again, if there is a resource for learning the basics of vbs, I would very much appreciate the recommendation.
Matt
12-04-2012 11:27 AM
12-13-2012 05:25 PM
Hey matt,
You could try looking at this peak finding script for tips. This method uses an absolute threshold value excursion to trigger the local peak finding.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
02-04-2013 11:29 PM
Sorry for not responding earlier about my progess.
I was able to extract the timepoints using your advice but now want to go back to the original data and extract the y-values. For some reason, my for loop below completes but only writes no-values? Extracting the x and y values in parallel won't work because I generated by x-value subset using the differential of the original dataset.
The general question is as follows:
Given a common timepoint, find the y-value associated with that timepoint in another channel.
FOR i=1 TO InitContrLength
ChDx(i, InitContrY) = ChDx(ChDx(i,InitContr)/Interval, Filtered)
Next
InitContr is an array of discontinuous time values which represent a subset of the original time series. My for loop is designed to iterate through the InitContr, converting them to an integer representing the appropriate row in my original dataset (Filtered) by dividing the time value by the step interval, and then writing the value from Filtered (which is an array of y-values) that corresponds to that row to InitContrY.
Definitions in case the above is confusing
InitContr = Channel containing a subset of time values
Filtered = Channel containing all y-values from the original waveform
Interval = step width of the original waveform
InitContrY = New Channel that I want to write y-values to that correspond to InitContr x-Values
Any ideas or links to a debugging primer would be greatly appreciated. If I could iterate through my for loop and visualize the variables in real time, I think I could figure this out myself.
Matt
02-05-2013 12:11 AM
I downloaded windows script debugger and figured out my problem. Because I extracted my initial timepoints from the differential, I was not returning integers of the original timepoints. I have it working now.
Matt