measurement in an ROI
I want to count thresholded cells inside a free drawn ROI and get 'count per unit area.' I can threshold the cells and draw the ROI but I don't know which measurement parameters to use - I can't find the ROI area.
0
Answers
-
Hi Paul,
The ROI Area is not reported directly. If you use a macro you can get ROI area using the following line:Public Sub PrintROIArea Debug.Print ThisApplication.ActiveImage.Aoi.mRgnArea.Sum End Sub
There is also a way getting this area from Percent Area measurement.
Regards,
Yuri
0 -
Paul --
I took a bit of time this (FRI) AM and created a PREMIER PROJECT that performs the TASK that you described in your question.
I have packaged this into an IPX FILE and attached that file as
Demo-2016-11-04-094836.ipx
The PROJECT consists of two files:
Demo-2016-11-04-094836.ipp
Module1.vb
The CODE for MODULE1 is shown below with the DEPENDENCIES that are needed.
The DEMOMACRO FUNCTION within MODULE1 contains code to:
'Declare LOCAL VARIABLES
'Set up ERROR HANDLING
'Connect with IMAGE
'Clear MEASUREMENT LIST
'Activate AREA MEASUREMENT
'Set APPLY FILTERS to OFF
'Learn OBJECT COUNT
'Learn CALIBRATION INFORMATION
'Learn AOI AREA (using Yuri's example + a mechanism for NO ROI)
'Calculate OBJECT DENSITY
'Create RESULTS STRING
'Display RESULTS STRING in OUTPUT WINDOW
'Send RESULTS STRING to CLIPBOARD
This FUNCTION will handle the ERROR CONDITIONS (No Objects, No ROIs, No Calibrations) that seemed to be appropriate.
This FUNCTION will also put the RESULTS STRING in the PREMIER OUTPUT WINDOW and on the WINDOWS CLIPBOARD (so they can be pasted into WORD, EXCEL, etc.).
I have also attached a SCREEN CAPTURE as
2016-11-04-113147.jpg
That shows the general configuration and operation of this PROJECT and the appearance of the RESULTS STRING when PASTED into EXCEL.
*-*-*-*-*-
!!! PLEASE NOTE !!!
I have just realized that I goofed on the UNITS for DENSITY!
I did not include the "^2" to make the DISTANCE UNITS into AREA UNITS.
I'm sure you can resolve this if you use this CODE.
*-*-*-*-*-
I hope this information is helpful.
-- Matt
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-Imports MediaCy.Addins.Measurements Imports MediaCy.Addins.Measurements.Gadgets Imports MediaCy.Addins.Measurements.McMMData Public Module DemoModule Public Function DemoMacro() 'Declare LOCAL VARIABLES Dim doc1 Dim MyData As McMMData Dim MyObjectCount As Double Dim MyCalibrationUnits As String Dim MyPixelSizeX As Double Dim MyPixelSizeY As Double Dim MyRoiArea As Double Dim MyObjectDensity As Double Dim MyResults As String 'Set up error handling On Error Resume Next 'Connect with IMAGE With Application.DocumentCommands.Active(Nothing) .Run(doc1) End With 'Clear MEASUREMENT LIST With Measure.MeasurementsCommands.Options(Nothing) .SelMeasurements = New MeasCollection() .Segmentation.FilterRanges = New System.Collections.Generic.List(Of MeasFilterEntry) .Run(doc1) End With 'Activate AREA MEASUREMENT With Measure.MeasurementsCommands.Options(Nothing) .SelMeasurements = New MeasCollection() .SelMeasurements.Add( New MeasEntry(eMeasures.RgnArea)) .Segmentation.FilterRanges = New System.Collections.Generic.List(Of MeasFilterEntry) .Segmentation.FilterRanges.Add( New MeasFilterEntry(eMeasures.RgnArea,0R,10000000R)) .Run(doc1) End With 'Set APPLY FILTERS to OFF With Measure.MeasurementsCommands.Options(Nothing) .Segmentation.ApplyFilters = False .Run(doc1) End With 'Learn OBJECT COUNT With measure.MeasurementsCommands.GetData(Nothing) .Run(ThisApplication.ActiveDocument, MyData) End With MyObjectCount = MyData.Statistics(eMeasures.RgnArea).count 'Learn CALIBRATION INFORMATION If (ThisApplication.ActiveImage.SpatialCalibration IsNot Nothing) _ Then MyCalibrationUnits = _ ThisApplication.ActiveImage.SpatialCalibration.UnitAbbrev MyPixelSizeX = _ ThisApplication.ActiveImage.SpatialCalibration.PixelSizeX MyPixelSizeY = _ ThisApplication.ActiveImage.SpatialCalibration.PixelSizeY Else MyCalibrationUnits = _ "pix" MyPixelSizeX = _ 1 MyPixelSizeY = _ 1 End If 'Learn AOI AREA If (ThisApplication.ActiveImage.Aoi.Count > 0) _ Then MyRoiArea = _ ThisApplication.ActiveImage.Aoi.mRgnArea.Sum Else MyRoiArea = _ ( ThisApplication.ActiveImage.Width * MyPixelSizeX ) * _ ( ThisApplication.ActiveImage.Height * MyPixelSizeY ) End If 'Calculate OBJECT DENSITY MyObjectDensity = MyObjectCount / MyRoiArea 'Create RESULTS STRING MyResults = _ "COUNT = " & vbTab & MyObjectCount & vbTab & "(units)" & vbLf & _ "ROI AREA = " & vbTab & MyRoiArea & vbTab & "(" & MyCalibrationUnits & "^2)" & vbLf & _ "DENSITY = " & vbTab & MyObjectDensity & vbTab & "(per " & MyCalibrationUnits & ")" & vbLf & _ "" 'Display RESULTS STRING in OUTPUT WINDOW ThisApplication.Output.show ThisApplication.Output.Clear ThisApplication.Output.PrintMessage(MyResults) 'Send RESULTS STRING to CLIPBOARD system.Windows.Clipboard.SetText (MyResults) End Function End Module
0 -
many thanks for this - I'll give it a try0
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