Code: Select all
#######################################################
## M E A S U R E M E N T A N D A N A L Y S I S
##
## Macro name: Analyze an image using an external mask
## Required files: 017 - FL time lapse.zvi, 017 - FL time lapse.czias
##
## LOAD IMAGE, CREATE AND SAVE IMAGE ANALYSIS SETTING,
## SEGMENT AND PROCESS NUCS, MEASURE FL INTENSITY OF ALL NUCS IN DSRed CHANNEL
##
#######################################################
##
##
## Remove all open documents
Zen.Application.Documents.RemoveAll()
##
## Load image automatically
## Display the image
image = Zen.Application.LoadImage ('C:\\OAD\\Input\\ZVI Images\\017 - FL time lapse.zvi')
Zen.Application.Documents.Add(image)
##
## Adjust display setting automatically
d=ZenDisplaySetting()
ids = image.DisplaySetting.GetAllChannelIds()
for id in ids:
image.DisplaySetting.SetParameter(id,'IsAutoApplyEnabled',True)
##
## Create a new measurement program for external mask
ias = ZenImageAnalysisSetting(ZenAnalysisSettingType.ExternalMask)
##
## Define a class pair
## Note! Class name must match with one mask channel name
## Note! Channel name must match with one dens channel name
ias.AddRegionClassPair("DsRed_all",1,"DsRed",2,"DsRed")
##
## Assign class colors
all = ias.GetRegionsClass("DsRed_all")
all.Color = ZenColors.Coral
single = ias.GetRegionClass("DsRed")
single.Color = ZenColors.Coral
##
## Define features (regions, region, draw)UC 38 - FL Time lapse III
all.AddFeature(ZenImageFeatures.ImageRelativeTime,True)
all.AddFeature(ZenRegionsFeaturesIntensity.RegionsIntensityMean,'DsRed')
all.AddFeature(ZenRegionsFeaturesIntensity.RegionsIntensityStd,'DsRed')
single.AddFeature(ZenRegionFeaturesGeometric.ID,True)
single.AddFeature(ZenImageFeatures.ImageIndexTime)
single.AddFeature(ZenRegionFeaturesGeometric.AreaConvex)
single.AddDrawFeature(ZenRegionFeaturesDraw.DrawBoundingRectangle)
##
## Save measurement program
ias.Save("017 - FL Time lapse")
##
## Do preprocessing and thresholding to create external mask
thres = Zen.Processing.Segmentation.ThresholdAutomatic(image,False)
#Zen.Application.Documents.Add(thres)
open = Zen.Processing.Morphology.Open(thres,1,True,ZenStructureElement.Octagon,False)
#Zen.Application.Documents.Add(open)
mask = Zen.Processing.Binary.Scrap(open,1,500,False)
Zen.Application.Documents.Add(mask)
##
## Load measurement program
ias.Load ("017 - FL Time lapse")
## Measure automatically (Run Silent)
Zen.Analyzing.Analyze(image,mask,ias)
##
## Show field table
ftable = Zen.Analyzing.CreateRegionsTable(image)
Zen.Application.Documents.Add(ftable)
##
#######################################################