Life Science

cancel
Showing results for 
Search instead for 
Did you mean: 

amplitude sensitive correlation in DIAdem

I think this is a simple question but probably a difficult procedure.

Does anyone have systax for running a correlation procedure on the y-axes fo two separate channels of data.  I am interested in the correlation of EMG amplitudes for selected muscle pairs.  The channel cross-correlation in DIAdem is simply time dependent. I can do this in Excel but my files are too big for excel and I have been using DIAdem for everything lately.

Thanks!
0 Kudos
Message 1 of 2
(6,335 Views)
Hi Dancer,
 
you can use the following VBS code if you want to calculate the correlation coefficient (-1..1) of two channels.
The channels are expceted to have the same length.
 
I hope this helps,
 
Christian
 
 
Function Covariance(sgChnX, sgChnY) ' Calculates covariance
  ' Calculates mean values
  Dim dMeanX : dMeanX = CCh(sgChnX, 0)
  Dim dMeanY : dMeanY = CCh(sgChnY, 0)
  Call ChnCalculate("Ch(""Temp"") = (Ch(""" & sgChnX & """) - " & Str(dMeanX) & ") * (Ch(""" & sgChnY & """) - " & Str(dMeanY) & ")")
  Call ChnSum("Temp", "Temp")
  Covariance = ChD(CL("Temp"), "Temp") / CL("Temp")
  Call ChnDel("Temp")
End Function
 
Function StdDev(sgChn)
  Dim i
  For i = 1 To 23
    StatSel(1) = "No"
  Next
  StatSel(14)      ="Yes"
  StatClipCopy     =0
  StatClipValue    =0
  StatFormat       =""
  StatResChn       =0
  Call StatBlockCalc("Channel","1-",sgChn) '... StatDirec,RowNoStr,ChnNoStr
  StdDev = StatDeviation ' or ChnPropValGet(sgChn, "ResultStatDeviation")
End Function
 
Function Correlation(sgChnX, sgChnY)
  Correlation = Covariance(sgChnX, sgChnY) / (StdDev(sgChnX) * StdDev(sgChnY))
End Function
 
'Call MsgBox(Correlation("Channel1", "Channel2"))
0 Kudos
Message 2 of 2
(6,324 Views)