Programmatically extracting data from the data collector
I am building an application in which I am capturing data from an image document grabbing count/size data and stats. I now would like to use the data collector in an effort to collect data from replicate images accessing summary stats as I measure images. I need to know how to programmatically access stat data from the data collector. Also I would like to access all or individual blocks of data from the data collector. Could you forward example code?
0
Best Answer
-
Rod,Yes, you are right GetData command will be available only in 9.1. Meanwhile you have to get that DataSet using direct property, like this:
Public Function GetDCStats() As SimpleScript GetDCStats = New SimpleScript Dim dataSet With Automate.ScriptingCommands.CodeCommand(GetDCStats) If .Run() Then ' User Code Here' 'get Data dataSet=MediaCy.Addins.DataCollector.McDataCollectorAddin.ThisAddin.Document.Data For Each table As System.Data.DataTable In dataSet.tables Debug.Print String.Format("Table - {0}",table.TableName) For Each col As System.Data.DataColumn In table.Columns 'print Mean' Debug.Print String.Format("Mean of {0} = {1}", col.Caption,GetColumnStats(col).Mean) Next Next End If End With End Function
Yuri0
Answers
-
Hello Rod,I suggest that you take a look at the command DataCollectorGetDataCommand, it returns a System.Data.DataSet so you have access to the entire pool of data using a standard .NET object. We will get back to you with more details about statistics but here is a short example.
Public Function Macro1() As SimpleScript Macro1 = New SimpleScript Dim dataSet With Measure.Data.CollectorCommands.GetData(Macro1) .Run(dataSet) End With With Automate.ScriptingCommands.CodeCommand(Macro1) If .Run() Then ' User Code Here Dim table As System.Data.DataTable For Each table In dataSet.tables Debug.Print table.TableName Next End If End With End Function
Pierre
0 -
Hi Rod,If you want to export Data Collector stats somewhere, you can use recordable commands, like this:
With Measure.Data.Collector.TableCommands.CopyToClipboard(Nothing) .UseStatistics = True .Run() End With
If you need to use Data Collector's statistics in the macro, then you can get it from the column data using McBasicStatistics classExample:Public Function GetDCStats() As SimpleScript GetDCStats = New SimpleScript Dim dataSet With Measure.Data.CollectorCommands.GetData(GetDCStats) .Run(dataSet) End With With Automate.ScriptingCommands.CodeCommand(GetDCStats) If .Run() Then ' User Code Here' For Each table As System.Data.DataTable In dataSet.tables Debug.Print String.Format("Table - {0}",table.TableName) For Each col As System.Data.DataColumn In table.Columns 'print Mean' Debug.Print String.Format("Mean of {0} = {1}", col.Caption,GetColumnStats(col).Mean) Next Next End If End With End Function 'Returns complete stats of the column.' Public Function GetColumnStats(col As System.Data.DataColumn) As MediaCy.IQL.ObjectManager.BASIC_STATISTICS Dim rows As New System.Collections.Generic.List(Of Double) With ThisApplication.Engine.McObjects.GlobalTools For Each row As System.Data.DataRow In col.Table.Rows Dim v As Object = row(col) If IsDBNull(v) OrElse Not IsNumeric(v) Then rows.Add(.McMissingDouble) Else rows.Add(v) End If Next Return .McBasicStatistics(rows.ToArray()) 'return stats' End With End Function
GetColumnStats function returns complete statistics for the given column, so you can use any of the statistical fields (check macro help on MediaCy.IQL.ObjectManager.BASIC_STATISTICS for more info).Yuri0 -
Yuri:
Thank you very much for the example. This is most helpful. However, I am running 9.0.4 and at Load, the Scripting Workbench reports that it cannot find GetData as a member of MediaCy.Automation.Measure.Data.CollectorCommands. I checked the Help file and GetData is not listed there. I am overlooking something obvious I am sure. Can you point me in the correct direction?
Thanks much!
//////Rod
0 -
Yuri:
Thanks much. Do you know when 9.1 will be released?
////Rod
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions