maskedCentromeres = itk.LabelMapMaskImageFilter.LM3IUC3.New(nucleusLM, unflattenCentromeres) centromeresLM = itk.LabelImageToStatisticsLabelMapFilter.IUC3IUC3LM3.New(maskedCentromeres, unflattenCentromeresInt) posCentromeresLM = itk.StatisticsPositionLabelMapFilter.LM3.New(centromeresLM, Attribute="CenterOfGravity") aggrCentromeresLM = itk.AggregateLabelMapFilter.LM3.New(posCentromeresLM, InPlace=False) shapeAggrCentromeresLM = itk.ShapeLabelMapFilter.LM3.New(aggrCentromeresLM) simCentromeresLM = itk.LabelMap._3.New() shapeSimCentromeresLM = itk.ShapeLabelMapFilter.LM3.New(simCentromeresLM) simCentromeresLM2 = itk.LabelMap._3.New() shapeSimCentromeresLM2 = itk.ShapeLabelMapFilter.LM3.New(simCentromeresLM2) extra = ExtraData(defaults={"nucleus-ext": "-nuclei.nrrd", "spots-ext": "-CENP.nrrd", "spots-are-labeled": "true", "rawspots-ext": "", "rawspots-channel": "0", "number-of-simulations": "500"}) nf = extra.printer(file(sys.argv[1].replace("::","-")+".txt", "w")) nf.printHeader("image", "label", "size", "centromeres", "flatness", "cdist", "rdist", "ncdist", "nrdist", "pvalue") for (nucleusName, centromeresName, centromeresIntName) in extra.iterate(["nucleus-ext", "spots-ext", "rawspots-ext"]): try: nbSims = extra.getint("number-of-simulations") nucleusReader(FileName=nucleusName) centromeresReader(FileName=centromeresName) centromeresIntReader(FileName=centromeresIntName) for flatNucleus in li2lm()[0]: idx, size, spacing, spacing2 = computeRegion(flatNucleus, nucleusReader)
singleNucleusLM = itk.LabelSelectionLabelMapFilter.LM3.New(nucleusLM, InPlace=False) binaryNucleus = itk.LabelMapToBinaryImageFilter.LM3IUC3.New(singleNucleusLM, ForegroundValue=0, BackgroundValue=255) maurerSingleNucleus = itk.SignedMaurerDistanceMapImageFilter.IUC3IF3.New(binaryNucleus, UseImageSpacing=True, SquaredDistance=False) evfSingleNucleus = itk.ErodedVolumeFractionMapImageFilter.IF3IF3.New(maurerSingleNucleus) maskedCentromeres = itk.LabelMapMaskImageFilter.LM3IUC3.New(nucleusLM, centromeresReader) centromeresLM = itk.LabelImageToStatisticsLabelMapFilter.IUC3IUC3LM3.New(maskedCentromeres, centromeresIntReader) def interpolate(image, pos): li = itk.LinearInterpolateImageFunction.IF3D.New(image) return li.Evaluate( pos ) extra = ExtraData(sys.argv[1], sys.argv[2:], {"nucleus-ext": "-nuclei.nrrd", "spots-ext": "-CENP.nrrd", "spots-are-labeled": "true", "rawspots-ext": "", "rawspots-channel": "0"}) cf = extra.printer(file(sys.argv[1].replace("::","-")+".txt", "w")) cf.printHeader("image", "label", "clabel", "mdist", "evf") for (nucleusName, centromeresName, centromeresIntName) in extra.iterate(["nucleus-ext", "spots-ext", "rawspots-ext"]): try: nucleusReader(FileName=nucleusName) centromeresReader(FileName=centromeresName) centromeresIntReader(FileName=centromeresIntName, Channel=extra.getint("rawspots-channel")) for nucleus in nucleusLM()[0]: singleNucleusLM.SetLabel(nucleus.GetLabel()) maskedCentromeres.SetLabel(nucleus.GetLabel())