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

Excel export of mean intensity and standard deviation for an images folder

by stef / Stephane Dallongeville

This script compute and exports the mean intensity and the standard deviation for a complete folder of image into a single excel file. If the image contains a region of interest the script uses it to localize the mean intensity and standard deviation calculation.

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

// select input folder
inputFolder = FileDialog.openFolder()
// cancelled
if (inputFolder == null) throw "Cancelled..."

// create output file name for XLS file
xlsFileName = inputFolder.getAbsolutePath() + "/result.xls"
// create excel document
wb = XLSUtil.createWorkbook(xlsFileName)
// create a new page in the excel document
ws = XLSUtil.createNewPage(wb, "result")

// set excel headers
XLSUtil.setCellString(ws, 0, 0, "filename")
XLSUtil.setCellString(ws, 2, 0, "average")
XLSUtil.setCellString(ws, 3, 0, "st dev")

// get all files from input folder
files = FileUtil.getFiles(inputFolder, null, false, false, false)

for(i = 0; i < files.length; i++)
	// get current file
	f = files[i]
	// load image
	seq = Loader.loadSequence(f.getAbsolutePath(), 0, false)

	if (seq != null)
		// get image rois 
		rois = seq.getROIs()
		// we only take the first roi
		if (rois.size() > 0) roi = rois.get(0)
		// use the whole sequence as rectangular ROI
		else roi = new ROI2DRectangle(seq.getBounds2D())
		// compute the mean intensity for the whole roi
		// be careful, if the image has severals channels
		mean = ROIUtil.getMeanIntensity(seq, roi)
		// compute the standard deviation for the whole roi
		// be careful, if the image has severals channels
		stdev = ROIUtil.getStandardDeviation(seq, roi)
		// write results in excel file
		XLSUtil.setCellString(ws, 0, i + 1, f.getAbsolutePath())
		XLSUtil.setCellNumber(ws, 2, i + 1, mean)
		XLSUtil.setCellNumber(ws, 3, i + 1, stdev)

// close and save the excel file

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

Icy script publication Id : O2Y9Y4