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

Pixels XLS Export

by stef / Stephane Dallongeville

This script allow you to export all pixels values which are contained in the ROI(s) into a excel file.

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
	path = FileDialog.open()

	if (path != null)
	{
		// display progress frame
		p = new ProgressFrame("exporting...")
		
		// set XLS extension
		path = FileUtil.setExtension(path, ".xls")

		//create a new excel document
		wb = XLSUtil.createWorkbook(path)
		sh = XLSUtil.createNewPage(wb, "Pixels intensitiezs")

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

		// set column titles
		XLSUtil.setCellString(sh, 0, 0, "X")
		XLSUtil.setCellString(sh, 1, 0, "Y")
		XLSUtil.setCellString(sh, 2, 0, "C")
		XLSUtil.setCellString(sh, 3, 0, "Z")
		XLSUtil.setCellString(sh, 4, 0, "T")
		XLSUtil.setCellString(sh, 5, 0, "Value")
		
		line = 1
		while(!it.done())
		{
			// set position information
			XLSUtil.setCellNumber(sh, 0, line, it.getPositionX())
			XLSUtil.setCellNumber(sh, 1, line, it.getPositionY())
			XLSUtil.setCellNumber(sh, 2, line, it.getPositionC())
			XLSUtil.setCellNumber(sh, 3, line, it.getPositionZ())
			XLSUtil.setCellNumber(sh, 4, line, it.getPositionT())
			// set value
			XLSUtil.setCellNumber(sh, 5, line, it.get())

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

		// save and close excel document
		XLSUtil.saveAndClose(wb)

		// done
		p.close()
	}
}

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



Icy script publication Id : U9N8E9