Need help or advice ? Come to the Icy club ! - Every Wenesday morning from 9h30 to 12h30 - Francois Jacob Building - Main hall - Pasteur
Register

ROI pixels CSV export

by stef / Stephane Dallongeville

This small script export all contained pixel (position and value) into a CSV file.

Warning: this script may require a lot of memory to run !

version 1 (last version):

download to use and modify in Icy. How do I use scripts ? A Problem ? ask the community.
Changelog for this version: initial version
importClass(Packages.icy.gui.frame.progress.ProgressFrame)
importClass(Packages.icy.file.FileUtil)
importClass(Packages.plugins.tprovoost.scripteditor.uitools.filedialogs.FileDialog)
importClass(Packages.icy.util.XLSUtil)
importClass(Packages.icy.util.XMLUtil)
importClass(Packages.icy.util.ShapeUtil)
importClass(Packages.icy.roi.ROIUtil)
importClass(Packages.icy.sequence.SequenceDataIterator)

// get active sequence
s = getSequence()
// merge all ROI from image in a single one (OR operation)
r = ROIUtil.merge(s.getROIs(), ShapeUtil.BooleanOperator.OR)

if (r != null)
{
	// request path to save XLS result
	file = FileDialog.open()

	if (file != null)
	{
		// display progress frame
		p = new ProgressFrame("exporting...")

		// set XLS extension
		path = FileUtil.setExtension(file.getAbsolutePath(), ".csv")

		// create empty sheet
		sheet = ""

		// create an iterator through the given sequence and ROI
		it = new SequenceDataIterator(s, r)

		// set column titles
		sheet += "X\tY\tC\tZ\tT\tValue\n"
		
		while(!it.done())
		{
			// set position information
			sheet += it.getPositionX() + "\t" +it.getPositionY() + "\t" +it.getPositionC() + "\t" +it.getPositionZ() + "\t" +it.getPositionT() + "\t"
			// set value
			sheet += it.get() + "\n"

			// pass to next value
			it.next()
		}

		// save file
		FileUtil.save(path, sheet.getBytes(), true)

		// done
		p.close()
	}
}

This script has no documentation. A Problem ? ask the community.



Icy script publication Id : L3A2E4