DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Cross correlation signal order

I have a piece of script which uses the cross correlation function (in the time domain) to find the relative time between two similar signals acquired on two separate acquisition systems. I have noticed that you get different results depending on which of the signals is used as Signal channel 1 and Signal channel 2. Why should this be?
 
The vast majority of the time this doesn't present a problem as the code always works. However, just occasionally it will trip up and I find it's because I have to reverse the order of the signals in the CHNCORRELNCROSS function. Why should some files be different to others when they are all acquired in essentially the same way?
 
Thanks,
 
Si.
 
0 Kudos
Message 1 of 11
(6,221 Views)
Hi Si,

I will do my very best to help you with this issue, however I would like to know some more information if that's okay. Firstly, would it be possible to paste the relevent Cross correlation script into a reply to this post? Secondly, what happens exactly when the anaylsis trips-up; is it a case of an incorrect or non-sensicle value being returned, or does the code throw an error of some description? Finaly, how are the signals being acquired, and into which file format are they acquired?

Best Regards,

Ian C
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 2 of 11
(6,190 Views)

Hi Ian,

Many thanks for the offer of help. The relevant line of script that I have been using is: Call CHNCORRELNCROSS("Time temp","SR30 Latac","RT3000 Latac","X_CCF","N_CCF","TimeDomain",50), although when it fails I have to reverse the signal channels thus: Call CHNCORRELNCROSS("Time temp","RT3000 Latac","SR30 Latac","X_CCF","N_CCF","TimeDomain",50). There is no error when the analysis trips up as the function returns usable data but the data returned is non-sensical to the rest of my code. As the two signals are essentially the same my code relies on finding the maximum value in the N_CCF channel, which should represent the time shift required to line to the two signals up. Typically the peak value is in the order of 0.7 to 0.8 and, due to the form of the signal, is clearly the peak of interest. On the occasions when the code fails the N_CCF channel contains values that are a miniscule fraction of unity, thus implying no correlation between the signals. For info, the X_CCF channel is identical in both cases and the "Time temp" channel is linearly increasing as required (this I discovered as necessary as the time increments in the output file from the OTS RT3000 are not always equispaced!!!)

The file formats are a CSV Excel file from the OTS RT3000 and a tab-delimited text file from the ABD steering robot. However, both file formats are imported and saved as a single DIAdem TDM file before the code is run.

Please let me know if you wish me to email you the relevant data.

Regards,

Si.

0 Kudos
Message 3 of 11
(6,186 Views)
Hi Si
 
Would you be able to attach the TDM file so that I can run the cross correlation functions and try to debug the issue? If the file is too large could you attach a cut down version of the file with fewer data points?
 
Could you attach a file that is giving you the error and one that isn't?
 
Thanks
Beejal S
NI UK & Ireland
0 Kudos
Message 4 of 11
(6,099 Views)
Hi Beejal,
 
I have a TDM file, the relevant TDX file and a VBS file to send you but none of these seem to be 'valid' extensions that are allowed by this forum. How do I get them to you?
 
Cheers,
 
Si.
 
0 Kudos
Message 5 of 11
(6,096 Views)

Hi

Can you zip all of the files together, then attach it?

Thanks

Beejal S
NI UK & Ireland
0 Kudos
Message 6 of 11
(6,092 Views)

Hi Beejal,

Can do. Should be attached. The VBS will run the cross correlation issue on a working and non-working set of data. It will also run the function with the input signals in the alternative order to that which my code normally uses. Paradoxically, if you run the function on the working data but with the signals in the alternative order then you also get unexpected results. I would expect the function to produce the expected results regardless of the order of the input signals.

Cheers,

Si.

 

0 Kudos
Message 7 of 11
(6,089 Views)

Hi

Thanks for that. I will have a look at it and get back to you as soon as possible.

Regards

Beejal S
NI UK & Ireland
0 Kudos
Message 8 of 11
(6,069 Views)

Hi

I have been looking at your issue and I can now see exactly what you mean. I have not yet been able to find a reason why the resulting data appears to be swapped, so I will escalate this issue for you.

In the mean time you can use a work around to ensure that your result generation is still automated. You can add some error checking into your VB script. Once you have run the initial cross correlation function, you can do a peak check to make sure you have a peak above 0.6. If you do not have a peak you can then delete the calculated data and run the cross correlation function again, swapping the SR30 and RT3000 parameters in the function. You can then run the peak check function again to make sure you do have the peak. If there is still no peak you can output and error.

By implementing this into your script you can ensure that the data will be in the correct order.

I will let you know as soon as possible if I get an any answers from escalating this error.

Regards

Beejal S
NI UK & Ireland
0 Kudos
Message 9 of 11
(6,066 Views)

Hi Si,

       I haven't have a look into your code yet. However, I am working on a very similar topic. I have data acquired in two different formats. I convert them in DIAdem format & create a new .tdm file. To synchorise the data, I downsample them & then use the same cross-correlation function which you use.

       By going through your post, I found that I have little difference in implemenation. I use "Frequency Domain" in CHNCORRELNCROSS() function instead of "Time Domain". Also I find the peak value by following statement:

Dim peak: peak = ChnFind("ValEqual(Ch("NormalizedCrossCorrelated"), CMax("NormalizedCrossCorrelated"))")

      Still now, I am yet to face any problem. I also feel that the order of the channels in CHNCORRELNCROSS() function should cause any problem.

      On the other hand, if you swap the two channels, there would be different results for the maximum normalized correlation value. I tried it with my data. However, the difference is marginal for my analysis (to the order of 0.001 for peak correalation value).

      Hope this might help to some extent. In my experince too, DIAdem behaves little awkwardly at times. Smiley Indifferent

With warm regards,

Saurav

 

0 Kudos
Message 10 of 11
(5,935 Views)