DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Script for multi channel processing

Hi everybody

 

I have got 40 channels. Names look like "A1 B1", "A1 B2", ... "A1 B8", "A2 B1", ... "A2 B8", ... "A5 B8"

"Dimension" is 5x8 (AxB).

 

I would like to run script witch will calculate 'mean' for channels "Ax B1" to "Ax B8" and save result to new channel "mean Ax".

AND

Script witch will calculate mean with channels "A1 Bx" to "A5 Bx" and save result to new channel "mean Bx".

 

Complication: Same channels could be missing for example there will be 38 channels without "A2 B5" and "A5 B2"

0 Kudos
Message 1 of 4
(3,600 Views)

Hi JCC,

 

I think it would be best to either post or email (brad.turpin@ni.com) an example data set.  I'm willing to create a quick VBScript to do these calculations, but it would be hugely helpful to be able to test that VBScript on the right data set during development.  Do you want the Ax and Bx channels to have one value each which is the matrix average or 8 values for each Ax channel and 5 values for each Bx channel?  Asked a different way, should the average calculation always be just over 1 channel?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 2 of 4
(3,579 Views)

Hi Brad

Thank you for your replay.

I am attaching example data set.

Channel names are combination of A and B when A = 1 to 5 and B = 1 to 8.

 

I want generate channels list Ax which will include this channels: (AxB1, AxB2, AxB3, AxB4, AxB5, AxB6, AxB7, AxB8). Later I will use this channels list to calc 'mean' or 'standard deviation'.

For this I could use VBScript command:

  • "Call ChnAverage("'[1]/A1 B1' - '[1]/A1 B8'","/Mean1")" or
  • "Call ChnAverage("'[1]/A1 B1', '[1]/A1 B2', '[1]/A1 B3', '[1]/A1 B4', '[1]/A1 B5', '[1]/A1 B6', '[1]/A1 B7', '[1]/A1 B8'","/Mean1")"

And I want generate channels list Bx which will include this channels: (A1Bx, A2Bx, A3Bx, A4Bx, A5Bx)

For this I could use VBScript command:

  • "Call ChnAverage("'[1]/A1 B1', '[1]/A2 B1', '[1]/A3 B1', '[1]/A4 B1', '[1]/A5 B1'","/Mean1")"

Script must check if channel name is valid. If Channel name is invalid then must be removed from channels list because calc function will return Error. (Same channels could be missing)

 

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

Hi JCC,

 

This is what I think you're asking for:

OPTION EXPLICIT
Dim ChStems, ChStem, ChnStr
Call GroupCreate("Averages")
Call GroupDefaultSet(GroupCount)
ChStems = Array("A1 Bx", "A2 Bx", "A3 Bx", "A4 Bx", "A5 Bx", "Ax B1", "Ax B2", "Ax B3", "Ax B4", "Ax B5", "Ax B6", "Ax B7", "Ax B8")
FOR Each ChStem In ChStems
  ChnStr = GetChnStr(ChStem)
  Call ChnAverage(ChnStr, ChStem)
NEXT ' ChStem


Function GetChnStr(ChStem)
  Dim i, ChName, ChNum, ChnStr
  ChnStr = ""
  ChStem = UCase(Trim(ChStem))
  FOR i = 1 TO 8
    ChName = Replace(ChStem, "X", i)
    ChNum = CNo(ChName)
    IF ChNum > 0 THEN ChnStr = ChnStrAdd(ChnStr, ChNum)
  NEXT ' i
GetChnStr = ChnStr
End Function ' GetChnStr()

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 4 of 4
(3,521 Views)