DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate channel average over a specific window

Solved!
Go to solution

Looking to find the average of a specific window of a channel. I need this to be something that can be plugged into a loop, as I'll be caclulating it on every channel (150+). Using the stat block function gets a little hairy if you try to loop it.

 

This is my current code, I'd like to use the average of points 98001-100001, store in variable R4, then plug into a free offset removal.

 

Dim iLoopOG, iLoopO, R4
  For iLoopOG = 1 to GroupCount
  For iLoopO = 2 to GroupChnCount(iLoopOG)
R4 = **Looking for a line here to calculate average over window** Call ChnOffset("["&iLoopOG&"]/["&iLoopO&"]","["&iLoopOG&"]/["&iLoopO&"]",-R4,"free offset") Next Next
0 Kudos
Message 1 of 4
(3,644 Views)

Well after some tinkering, I got the script below to do what I want (sort of, only works for group one). Is there any way to clean up the stat block calculation? I hate that it eats up almost 40 lines just to select which calculations I want. I've tried only leaving the "Yes" selections and deleting the "No" but that only works with the current session, if you reset DIAdem it will apply the defaults for the nos.

 

Any suggestions?

 

StatSel(1)       = "No"
StatSel(2)       = "No"
StatSel(3)       = "No"
StatSel(4)       = "No"
StatSel(5)       = "No"
StatSel(6)       = "Yes"
StatSel(7)       = "No"
StatSel(8)       = "No"
StatSel(9)       = "No"
StatSel(10)      = "No"
StatSel(11)      = "No"
StatSel(12)      = "No"
StatSel(13)      = "No"
StatSel(14)      = "No"
StatSel(15)      = "No"
StatSel(16)      = "No"
StatSel(17)      = "No"
StatSel(18)      = "No"
StatSel(19)      = "No"
StatSel(20)      = "No"
StatSel(21)      = "No"
StatSel(22)      = "No"
StatSel(23)      = "No"
StatClipCopy     = 0
StatClipValue    = 0
StatFormat       = ""
StatResChn       = 1
StatResChnNames  = 0
StatResChnNameFormat= "NameName"
Call StatBlockCalc("Channel","98001-100001","'[1]/[2]' - '[1]/["&GroupChnCount(1)&"]'")

Dim iLoopOG, iLoopO, R4, i
  For iLoopOG = 1 to GroupCount
  For iLoopO = 2 to GroupChnCount(iLoopOG)-1
    R4 = CHV(iLoopO - 1, "[1]/["&GroupChnCount(iLoopOG)&"]")
		Call ChnOffset("["&iLoopOG&"]/["&iLoopO&"]","["&iLoopOG&"]/["&iLoopO&"]",-R4,"free offset")
  Next
  Next
0 Kudos
Message 2 of 4
(3,630 Views)
Solution
Accepted by topic author TamerZero

Hello Tamer,

 

This will make the statistics selection part a little shorter:

 

Dim i 
For i = 1 to 23
  StatSel(i)       = "No"
Next
  StatSel(6)       = "Yes"
StatResChn       = 0
StatClipCopy     = 0
Call StatBlockCalc("Channel","98001-100001","'[1]/[2]' - '[1]/["&GroupChnCount(1)&"]'")

The other variables should not be required because they are dependent on StatResChn and StatClipCopy being true, which they shouldn't be in your use case.

 

Hope that helps a little,

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 3 of 4
(3,611 Views)

Thanks Otmar. I figured out the loop trick just after posting my latest code. This solution will work for me, thanks for the help.

 

Tamer

0 Kudos
Message 4 of 4
(3,591 Views)