LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make a cross-correlogram from two inputs

Hi I am trying to  make a cross-correlogram. 
 
 My program is difficult to explain so I will try my best.  Right now I am generating impulses using a random possion generator.  Meaning whether I output a 1 or 0 is dependent on my poisson formula.  I am generating two signals, and my goal is to compare when a peak occurs from both these signals. I am able to detect my peaks (1) using a peak detector, which tells me the time the peak occured for both signals.  I would like to now line up the two signals, (the location time) and see within a certain interval if a peak occured in both my signals.  Then I would like to graph this number on my y axis of a histogram. I am having problems with this.
 
My question is pretty simple I think, but I am confused with the parameters on the histogram, x- is the input data?? and I dont know what h(x) is?, also has anyone tried to make a cross-correlogram before with two signals??? I also would like to know how i can compare the locations of the two signals, since all the values are stored in an indicator? I would like to compare the peak times, if there is a peak within a certain time interval for both signals, that would be a point on my histogram (yaxis),
 
I think my question is a little confusing, if you have problems understanding what i wrote please let me know
0 Kudos
Message 1 of 16
(4,079 Views)
Let me first try to answer your second question concerning the syntax of the 'histogram.vi'. the following is an excerpt from the Labview Help pages (you get them when you click on 'Click here for more help' in Labview's 'Context Help' window):
 
X must contain at least one sample. If X is empty, the histogram is undefined, and the VI sets Histogram: h(x) and X Values to empty arrays and returns an error.
intervals must be greater than zero. If intervals is less than or equal to zero, the histogram is undefined, and the VI sets Histogram: h(X) and X Values to empty arrays and returns an error. The default is 1.
Histogram: h(x) is the discrete histogram of the input sequence X.
X Values is the center values of the intervals (bins) of the histogram.
error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster.

So if your data are in input array [X], the histogram.vi first determines the min and max of X.Then it divides the range min...max into a number (=intervals) of equally sized bins and looks how many elements of X fall in each bin. The bin midpoints are returned in the output array [X values] (whose length equals 'intervals') and the counts in each bin are returned in array [h(x)] which IS the histogram. You best plot [h(x)] as a function of [X values] in an XY-Graph indicator.

 

I do not completely understand the first part of your question. To me it seems you are generating (=simulating? or =measuring?) two sequences of digital data 0 or 1. They are contained in two arrays and the index of the arrays can be interpreted as time. If this is correct, you can just connect the two arrays by a logical AND function and get a third array which tells you when both input array simultaneously had a '1' (what you call a 'peak') .

If you feed that array into the histogram function, it will tell you the frequncy of 0's and 1's in the third array, but maybe that is not what you really want?

Please give a bit more details if I did not understand correctly what you want to achieve. You could also post examples of the input arrays. (If you post a VI: I have LV version 7.0 only.)

 

 

-Franz

 

 

0 Kudos
Message 2 of 16
(4,048 Views)
There is a Cross correlation function. Look at the functions palette Functions >> Analyze >> Signal Processing >> Time Domain >> CrossCorrelation.vi.

Lynn
0 Kudos
Message 3 of 16
(4,036 Views)

Hi Franz, thanks for answering my question about the histogram parameters.

For my program, I am writing a test program which will be used with real signals in real-time.  I have attached the begininning of my program.  You can see there are four graphs- 2 XY plots, and 2 charts I believe, You will see that once the program runs , peaks are generated and the location (time) of the peak is recorded in an indicator for my 2 signals.

I would like to start comparing signal 1 and 2 once a peak is generated in signal 1, and say if my program runs for 100 samples,and I want 10 intervals so I have 10 time bins, 0-10, 11-20 etc, and in each time bin, i would like to check to see if a peak occured in signal 1 AND signal 2, if so i record a 1.  Now the tricky part is that I want to specify the time bins depending on signal 1, so that  each time a peak occurs in Siganl 1  I have a new time bin?? is that possible?  If not then I wil just try to do the first part of the histogram of recording the peaks of Signal 1 and 2.

You mentioned something about adding the two arrays.  I use an index array for signal 1 and 2 seperately, which you will see in my block diagram, im a little confused about what you said with connecting them as an AND function.  I will try to see if I can do that.

I have attached my VI, I use LabVIEW version 7.1

Thanks again

0 Kudos
Message 4 of 16
(4,033 Views)

Hi, I just figured out how to construct a cross-correlogram, and it seems that I mis-understood how to do it.

Basically I want to choose a refrence signal, and one target signal....For my refrence signal I would like to pick the first peak or 1 as my reference `peak/spike`, and store that as time 0 on my histogram, then I want to record all the peaks of signal 2 into a histogram,.  So if there are any peaks recorded for Signal 2 before the reference peak of the reference signal 1 they are stored in the negative axis of time so to the left of time 0.  Once I have finished that I would like to take the next peak in the reference signal and use that as my new reference peak at time 0, therefore shifting my histogram once again, and again I search for peaks of the target signal and record them on to my histogram. and I would repeat this for however many refrence peaks I have.

I am very confused about how to implement this, as I have only been using labVIEW for 2 mths.  I am assuming I will need a for loop that is controlled by the number of peaks of my reference signal.  I dont know how to update the histogram though.

If anyone has any ideas I would greatly apprecitate them

thanks

0 Kudos
Message 5 of 16
(4,028 Views)


sophie83 wrote:

Basically I want to choose a refrence signal, and one target signal....For my refrence signal I would like to pick the first peak or 1 as my reference `peak/spike`, and store that as time 0 on my histogram, then I want to record all the peaks of signal 2 into a histogram,.  So if there are any peaks recorded for Signal 2 before the reference peak of the reference signal 1 they are stored in the negative axis of time so to the left of time 0.  Once I have finished that I would like to take the next peak in the reference signal and use that as my new reference peak at time 0, therefore shifting my histogram once again, and again I search for peaks of the target signal and record them on to my histogram. and I would repeat this for however many refrence peaks I have.


That sounds to me like you want to take the peaks of signal 1 as boundaries for the bins of a histogram for signal 2 peaks. Or in other words: you want to count how many peaks of signal 2 occur between any two peaks of signal 1? Is that correct?

I could not open the VI you posted in your other mail since I only have LV 7.0. You can save your VI for LV 7.0 by using in the menu 'File->Save with Options->Save for Previous...' and then re-post it, so I can have a look.

 

-Franz


 

0 Kudos
Message 6 of 16
(4,023 Views)
Ok I saved it with version 7, but the problem is that it says you cant view some of my vis, like my source generator, so I dont think you`ll be abke to run it.
 
I think you misunderstood me, my message was not clear so sorry for that.
What I want to do is say I have a signal A, and B
Signal A only determines the x-axis, the Bin count or y axis is determined by signal B,
so I find my first Peak let`s say called ``Peak 1`` for Signal A, and plot my histogram finding ALL peaks of signal B occuring AFTER the first reference peak of Signal A (Peak1).  The peaks of Signal B are plotted normally on a histogram on the y axis( stores the number of peaks per time bin), then I will pick the next Peak of Signal A lets called it ``Peak 2`` and now that will be my new time 0 reference on the same histogram, so the plot is shifted to the left, and I need to find ALL peaks of Signal B occuring AFTER ``Peak 2``.
 
So basically im iterating, I think I would need two loops, an outer loop for the number of peaks found in Signal A, and another loop to do the calulation of the histogram. 
I hope its clearer now
 
Im not sure if I saved it properly, can you let me know if it opens properly
 
Thank you for your help
0 Kudos
Message 7 of 16
(4,020 Views)


@sophie83 wrote:
Ok I saved it with version 7, but the problem is that it says you cant view some of my vis, like my source generator, so I dont think you`ll be abke to run it.

I can open the VI, but 'Advanced Peak Detector Pt by Pt.VI' is mising. Could you try to convert that also to LV 7.0 and post it?


 


@sophie83 wrote:
I think you misunderstood me, my message was not clear so sorry for that.
What I want to do is say I have a signal A, and B
Signal A only determines the x-axis, the Bin count or y axis is determined by signal B,
so I find my first Peak let`s say called ``Peak 1`` for Signal A, and plot my histogram finding ALL peaks of signal B occuring AFTER the first reference peak of Signal A (Peak1).  The peaks of Signal B are plotted normally on a histogram on the y axis( stores the number of peaks per time bin), then I will pick the next Peak of Signal A lets called it ``Peak 2`` and now that will be my new time 0 reference on the same histogram, so the plot is shifted to the left, and I need to find ALL peaks of Signal B occuring AFTER ``Peak 2``.
 
I hope its clearer now


Sorry, not it is not yet clear to me. Maybe if I see the A and B data you try to evulate. If the posting should fail, you could try to export the data into a textfile and post it or you could take a screenshot of the data and post that.

 

-Franz

0 Kudos
Message 8 of 16
(4,011 Views)
Hi I couldnt export the data into a text file, but I took a screen shot of the front panel.
In my front panel, I plotted Signals A and B in an xy graph, under neath each plot is the time a peak occured (location), and also the number of peaks found is indicated for each graph.
 
I want to start at Location 1 (Peak 1) for Signal A, (this is time 0 on the Histogram) I will then compare Peaks of B to Peak 1. Once Peak1B > Peak1A, i start to record the occurences of the peaks of Signal B and record on a histogram.  Once I have finished recording all Peaks of B on the histogram, I will move to Location 2(Peak2) for Signal A, and record all the peaks for Signal B on the same histogram, in which PeakB`s are greater then Peak2.
I will continue until I have done the analysis with all Peaks in Signal A, which is dependent on the number of peaks I have found.
 
For me it would be easy to do in C++, but I am confused with LabVIEW`s FOR loops and Arrays.
 
Codin it I  would have two FOR Loops, the outer is for Signal A
 
where  A is the array storing all the locations of peaks in Signal A
B is the array storing all the locations of peaks in Signal B
 
for (A= 0, A<Num_Peaks_FoundA; A++)
(
     for ( B=0; B<Num_Peaks_FoundB; B++)
         
           (CODE )if (B>A)
                     X= B;  // Basically I want to plot values of B (the occurences of peaks of B) on the histogram its the data from B that im interested in
 
so basically once all the locations or peaks of B are done, the outer loop iterates to 2, and the inner loop is repeated again for all values of B greater then A
 
I hope that helps a little

Message Edited by sophie83 on 07-22-2005 01:55 PM

0 Kudos
Message 9 of 16
(4,017 Views)
Is this what you want:
0 Kudos
Message 10 of 16
(4,000 Views)