Forked from imagejan/Open_Cell_Counter_XML_as_ROI.groovy
Created
April 18, 2024 20:41
-
-
Save TemponeMH/e738f1429ee32041b0047f25e7bdf0c2 to your computer and use it in GitHub Desktop.
Open an XML file saved by Cell Counter as an ImageJ PointRoi (ignoring stack position)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Open an XML file saved by Cell Counter as an ImageJ PointRoi (ignoring stack position) | |
* | |
* (see https://forum.image.sc/t/convert-cell-counter-markers-to-multi-point/23844?u=imagejan) | |
*/ | |
#@ ImagePlus imp | |
#@ File input | |
import groovy.util.XmlParser | |
import ij.gui.PointRoi | |
roi = new PointRoi() | |
parser = new XmlParser() | |
doc = parser.parse(input) | |
doc.Marker_Data.Marker_Type.each { | |
roi.setCounter( it.Type[0].text() as int ) | |
it.Marker.each { | |
roi.addPoint( it.MarkerX[0].text() as int, it.MarkerY[0].text() as int ) | |
} | |
} | |
roi.setShowLabels(true) | |
imp.setRoi(roi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment