DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform x-offset

Solved!
Go to solution

Hi everyone,

 

Could someone please explain the idea of the Waveform x-offset (in the waveform properties). I understand it is quite easy to shift a channel on the X-Axis when you are using the VIEW window but when it comes to calculations or data export (i.e. csv.) this offset is not being taken into account and creates confusion among my colleagues and myself.

 

In the attachment, you'll find an easy example for this issue. I have two waveform channels A and B. Channel B has a Waveform X-offset of 3. I would have expected that DIAdem recognizes the Waveform offset and therefore takes the offset into account when you perform calculations. Nevertheless, DIAdem seems to calculate row-by-row and completely ignores the offset.

 

In order to keep the "correct" timing, I tried to ignore the Waveform offset and add a "NoValue" in the first three rows of B. However this creates problems when applying FFT or filtering functions on the signal.

 

In addition, when I try to export the two channels (i.e. as .csv) the actual output is also not including the waveform offset.

 

Is there a way of including the waveform offset in calculations without programming tons of scripts? In my opinion, DIAdem should be able to calculate waveform channels by taking the actual time information into account instead of calculating row-by-row.

 

Many thanks for your help and best regards

David

0 Kudos
Message 1 of 10
(5,599 Views)

Hey David,

 

What kind of calculation are you trying to achieve with your waveforms ? We may find another way to achieve it.

Maybe that document (mostly rule 2.3) may help you to understand what are the "limitations".

 

CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 2 of 10
(5,575 Views)

Hi Maxime,

 

Thanks for your quick answer.

 

Usually, I work with the calculator in order to add, subtract or multiply channels with constants or other channels.

 

One practical example would be the calculation of the sum of forces acting on a mechanical strucure like a bladeholder arm of a helicopter.

 

If I had 4 strain gauges mounted on this arm, I would need to calculate the sum of these 4 individual strain gauge measurements in order to get the resulting force. If one of these four channels had an offset of i.e. 0.5 seconds, DIAdem would calculate a wrong output due to the row-by-row calculation.

 

Regards

David

0 Kudos
Message 3 of 10
(5,572 Views)

Copy that. Once again it seems taht if you have different x-offset math functions will consider your waveforms as numeric channels... Have you tried this function ? I am not sure you have different files but maybe you will find a way to achieve what you want using it.

 

CLAMaxime -- Kudos are a great way to say thank you
Message 4 of 10
(5,570 Views)

Yeah seems like the offset property is mainly good for plotting as all calculations are row-by-row...  I would just insert the appropriate amount of NOVALs programmatically unless there is a better solution...  You would need to consider the waveform step with and units to make a reusable function.  And I guess you'd have to remove and insert back the offset before/after FFT and other functions

0 Kudos
Message 5 of 10
(5,566 Views)

Thanks for your answer,

 

I had the same idea but it just seems to be a big inconvenience.

 

I really hope NI is going to implement a time-based calculation function as the row-based calculations can be very painful when you have different starting times (or at least allow NoValues in the ANALYSIS functions)

 

 

 

 

0 Kudos
Message 6 of 10
(5,551 Views)

@Maxime

 

Thanks again, I am quite familiar with the resampling function. I really dont like the idea of having all my channels resampled/mapped as it could change the original data.

 

I guess the only solution would be to select a band (with the band cursor), copy the flags and run the calculations on the sniplets as they would have the same X-offset...

0 Kudos
Message 7 of 10
(5,550 Views)

That could be a solution, even if it would mean to process all channels before hand.

Maybe you can have a script doing it ?

CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 8 of 10
(5,544 Views)
Solution
Accepted by topic author David_Frey

I have couple of functions.  The first adds NOVALs offset to a waveform channel if it has an offset propery and the second removes any offset to a wavform channel.  Worked nice with the EXAMPLE tdms

Function wavefromOffsetNOVAL(wfChannel)
  If TypeName(wfChannel) = "IDiademChannel" Then
    If wfChannel.Properties("waveform").Value = "Yes" Then
      If wfChannel.Properties("wf_start_offset").Value > 0 Then
        Dim stepWidth, offsetTarget, numberOfNOVALs
        stepWidth = wfChannel.Properties("wf_increment").Value
        offsetTarget = wfChannel.Properties("wf_start_offset").Value
        numberOfNOVALs = Round(offsetTarget / stepWidth)
        Call wfChannel.SetValues(NOVALUE, 1, numberOfNOVALs, eValueBlockValueInsert)
        LogFileWrite(CurrentScriptName & ": inserted " & numberOfNOVALs & " NOVALs to create " & offsetTarget & wfChannel.Properties("wf_xunit_string").Value & " offset")
      Else
        Call LogFileWrite(CurrentScriptName & ": channel does not have offset")
      End If
    Else
      Call LogFileWrite(CurrentScriptName & ": Argument must be a waveform channel")
    End If
  Else
    Call LogFileWrite(CurrentScriptName & ": Argument must be a DIAdem channel")
  End If
End Function

Function wavefromOffsetNOVALremove(wfChannel)
  If TypeName(wfChannel) = "IDiademChannel" Then
    If wfChannel.Properties("waveform").Value = "Yes" Then
      Dim firstNOVALrow: firstNOVALrow = Find("Ch(""Noise data/Noise_4"")<>NOVALUE", 1)
      If firstNOVALrow > 1 Then
        Call DataBlDel(wfChannel, 1, (firstNOVALrow - 1), TRUE)
        LogFileWrite(CurrentScriptName & ": Removed " & (firstNOVALrow - 1) & " values of NOVAL offset")
      Else
        Call LogFileWrite(CurrentScriptName & ": There is no (NOVAL) offset to remove")
      End If
    Else
      Call LogFileWrite(CurrentScriptName & ": Argument must be a waveform channel")
    End If
  Else
    Call LogFileWrite(CurrentScriptName & ": Argument must be a DIAdem channel")
  End If
End Function
Message 9 of 10
(5,536 Views)

Thanks a lot for the code, it's still hard to imagine that this offset property is for the optical layout only but now I have a confirmation that there is no other option.

 

0 Kudos
Message 10 of 10
(5,528 Views)