Skip to content

Instantly share code, notes, and snippets.

@imagejan
Last active April 24, 2024 08:06
Show Gist options
  • Save imagejan/b251d1ccea52912cc54cf09ef7a9b22f to your computer and use it in GitHub Desktop.
Save imagejan/b251d1ccea52912cc54cf09ef7a9b22f to your computer and use it in GitHub Desktop.
Open an XML file saved by Cell Counter as an ImageJ PointRoi (ignoring stack position)
/*
* 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.xml.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)
@TemponeMH
Copy link

In newer versions of Groovy , you should replace "import groovy.util.XmlParser" for "import groovy.xml.XmlParser". Hope it helps!

@imagejan
Copy link
Author

Thanks for the info, @TemponeMH !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment