DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert MATLAB program to Diadem script

I'm fairly new to Diadem and am trying to convert this MATLAB program to a Diadem script.  Can Diadem handle array manipulations like this?  If so, how would I go about making the conversion of this program to be able to run in Diadem?

 

thanks for any insight!

0 Kudos
Message 1 of 14
(7,973 Views)

Hi jgabe,

 

Your m script has 231 lines of code with multiple instances of nested loops.  Could you please point out the specific line numbers you mean with the reference, "Can DIAdem handle array manipulations like this"?

 

DIAdem stores each scalar in a property of a channel, group or file

DIAdem stores each 1D array in a channel

DIAdem stores 2D arrays in a series of channels that typically are in the same group

 

DIAdem has both 1D and 2D array manipulation functions, and it's easy to operate between a scalar and an array in a customer-defined formula.

DIAdem can also perform single value analysis in a nested loop, but that's slower because VBScript is an interpreted language.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 14
(7,952 Views)

Brad:

 

I am primarily concerned with the nested loop starting on line 124. 

 

Also, due to my lack of knowledge with Diadem at this point, is there a source or a service that you are aware of that would convert the MATLAB program to a usable Diadem script for me?

 

thanks!

 

0 Kudos
Message 3 of 14
(7,939 Views)

Hi jgabe,

 

That's a busy nested loop.  It looks like you have four different 1D arrays of values that you are systematicall string comparing with each other and rearranging into an output matrix.  You could port this code pretty easily to DIAdem.  How big are these arrays?  Do you have them loaded into DIAdem as 4 channels?  What's purpose of this sorting process?

 

Brad Turpin

DIAdem Product Support Engineer

National Instrurments

0 Kudos
Message 4 of 14
(7,931 Views)

Brad:

 

I've attached a powerpoint that basically explains the purpose/goal of the MATLAB program.  The purpose of the busy nested loop is to place the  linear equations in a matrix that are needed to solve for the unknowns maximum lags between the cross correlated pairs of data.  In my case, I would have 3 channels already loaded into Diadem.  Ideally, I would choose the three channels to be compared.  The program is designed to cross correlate each set of pairs of the threen channels (C12, C23, C31), determine the lags between the three pairs and then take a derivative of cross correlations to produce the set of linear equations (the Lagrange Multiplier) that go into determining the maximum maximum lag.  The determined max lag solution would then be applied to each of three channels to properly align them.  I have provided a powerpoint that helps explain the program and an example of the data I am looking to compare and align.  For instance, I would want to align the X_accel_head[1], X_accel_head[2, X_accel_head[3] for each of the three runs, etc. 

 

You could port this code pretty easily to DIAdem. How do you port code into Diadem?

How big are these arrays? The arrays I plan to use should be a three by three as seen in the powerpoint since I will be only comparing 3 channels of data at any given time.

Do you have them loaded into DIAdem as 3 channels? The channels would be loaded as seen in the sample provided data set.

What's purpose of this sorting process?  Please see above.  The sorting process is used to determine the cross correlations of the sets of pairs and the lags for the pairs so that a set of simultaneous equations can be developed (derivative of the cross correlation) to determine the max lag fo the three channels.

0 Kudos
Message 5 of 14
(7,921 Views)
0 Kudos
Message 6 of 14
(7,919 Views)
0 Kudos
Message 7 of 14
(7,917 Views)

Hi jgabe,

 

In this case you "port code into DIAdem" by re-writing it from scratch.  The code to loop over the individual channel values is very similar in the *.m script compared to what it would be in a DIAdem VBScript, so that code is particularly "portable", but I'm not sure how fast the DIAdem VBScript would run compared to the equivalent *.m script.  In the example data set you just posted, there were 6000 data values in each HEAD_ACCEL_X channel, is that a typical size, or is it sometimes longer?

 

The powerpoint slides indicate your primary goal is to edge-align or shape-align the different head acceleration signals to compensate for different body parameters.  I actually already have code to do that based on edge or shape detection, but it uses a different method than your Lagrangian approach.  It looks to me, though, like the 3 *.DAT data sets you sent are already time-aligned or perhaps never needed it, and the the *.TDM file also appears to need no time-aligning.  It would be interesting to try my existing code against some of your data sets that need adjustment and see how it performs.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 14
(7,911 Views)

The 6000 data points should be the typical size if not shorter for the data I need to align.

 

I am going to start to port the code to Diadem to see what happens.  In the interim, is it possible to get a copy of your code that is based on edge or shape detection to compare.  I'm not convinced the Lagrangian method is the best approach but it is what NHTSA has been using.

 

thanks!

0 Kudos
Message 9 of 14
(7,887 Views)

Hi jgabe,

 

Sure, I'm attaching my code.  It assumes that the data is loaded and plotted and that you want to shift all the waveforms on the plot.  It also assumes that you have marked the desired rising edge X-axis point to align with the crosshair cursor.  When you've run the "Time Align Curves.VBS" once in the SCRIPT panel, then you'll see a new icon appear in the VIEW panel at the top right of the icon bar which you can press to re-run the script.

 

Please ask as you have further questions,

Brad Turpin

DIAdem Product Support Engineer

brad.turpin@ni.com

0 Kudos
Message 10 of 14
(7,885 Views)