Script

XLS export of ROIs mean intensity over time

Publication ID: ICY-R1V1T5

Short Description

Export the mean intensity of the all ROIs of active sequence over time in an excel file.

Versions

  • Version 3 • Released on: 2022-04-25 12:00:00
    Download
    Description:

    Rewrote to handle all ROIs from the sequence, multi page sheet to allow more than 256 rois, and only exporting mean intensity.

    importClass(Packages.plugins.tprovoost.scripteditor.uitools.filedialogs.FileDialog)
    importClass(Packages.icy.file.FileUtil)
    importClass(Packages.icy.util.XLSUtil)
    importClass(Packages.icy.roi.ROIUtil)
    
    outFile = FileDialog.save();
    sequence = getSequence()
    
    if (sequence != null)
    {	
    	// create new excel file
    	xls = XLSUtil.createWorkbook(outFile)
    
    	// get ROIs
    	rois = sequence.getROIs()
    
    	// sheet index
    	for(p = 0; p < (rois.size() + 255) / 256; p++)
    	{
    		rstart = p * 256;
    		rend = (p * 256) + 256
    		if (rend > rois.size()) rend = rois.size()
    		
    		// create a new page
    		xlsPage = XLSUtil.createNewPage(xls, "Spots " + rstart + " - " + (rend - 1))
    		
    		for(r = rstart; r < rend; r++)
    		{
    			roi = rois.get(r)
    			rpage = r - (p * 256)
    			
    			// write header (roi name)
    			XLSUtil.setCellString(xlsPage, rpage, 0, roi.getName())
    	
    			// iterate over frames
    			for(t = 0; t < sequence.getSizeT(); t++)
    			{
    				// compute mean intensity for this frame
    				mean = ROIUtil.getMeanIntensity(sequence, roi, -1, t, -1)
    				XLSUtil.setCellNumber(xlsPage, rpage, t+1, mean)
    			}
    	
    			println("processing roi #" + r + " - " + roi.getName())
    		}
    	}
    	
    	println("done !")
    	
    	// save excel file
    	XLSUtil.saveAndClose(xls)
    }
    
  • Version 2 • Released on: 2014-08-07 15:54:30
    Download
    Description:

    Added min / max intensity information.

    importClass(Packages.icy.file.FileUtil)
    importClass(Packages.icy.util.XLSUtil)
    importClass(Packages.icy.roi.ROIUtil)
    
    sequence = getSequence()
    
    if (sequence != null)
    {
    	roi = sequence.getSelectedROI()
    
    	if (roi != null)
    	{
    		// create new excel file
    		xls = XLSUtil.createWorkbook(FileUtil.setExtension(sequence.getFilename(), ".xls"))
    		// create a new page
    		xlsPage = XLSUtil.createNewPage(xls, roi.getName())
    
    		// write header
    		XLSUtil.setCellString(xlsPage, 0, 0, "T position")
    		XLSUtil.setCellString(xlsPage, 2, 0, "Min intensity")
    		XLSUtil.setCellString(xlsPage, 3, 0, "Mean intensity")
    		XLSUtil.setCellString(xlsPage, 4, 0, "Max intensity")
    		
    		for(t = 0; t < sequence.getSizeT(); t++)
    		{
    			// compute intensities for this frame
    			min = ROIUtil.getMinIntensity(sequence, roi, -1, t, -1)
    			mean = ROIUtil.getMeanIntensity(sequence, roi, -1, t, -1)
    			max = ROIUtil.getMaxIntensity(sequence, roi, -1, t, -1)
    			
    			// write value
    			XLSUtil.setCellNumber(xlsPage, 0, t + 2, t)
    			XLSUtil.setCellNumber(xlsPage, 2, t + 2, min)
    			XLSUtil.setCellNumber(xlsPage, 3, t + 2, mean)
    			XLSUtil.setCellNumber(xlsPage, 4, t + 2, max)
    		}
    
    		// save excel file
    		XLSUtil.saveAndClose(xls)
    	}
    }
    
  • Version 1 • Released on: 2014-08-07 15:50:45
    Download
    Description:

    initial version

    importClass(Packages.icy.file.FileUtil)
    importClass(Packages.icy.util.XLSUtil)
    importClass(Packages.icy.roi.ROIUtil)
    
    sequence = getSequence()
    
    if (sequence != null)
    {
    	roi = sequence.getSelectedROI()
    
    	if (roi != null)
    	{
    		// create new excel file
    		xls = XLSUtil.createWorkbook(FileUtil.setExtension(sequence.getFilename(), ".xls"))
    		// create a new page
    		xlsPage = XLSUtil.createNewPage(xls, roi.getName())
    
    		// write header
    		XLSUtil.setCellString(xlsPage, 0, 0, "T position")
    		XLSUtil.setCellString(xlsPage, 1, 0, "Mean intensity")
    		
    		for(t = 0; t < sequence.getSizeT(); t++)
    		{
    			// compute mean intensity for this frame
    			d = ROIUtil.getMeanIntensity(sequence, roi, -1, t, -1)
    			
    			// write value
    			XLSUtil.setCellNumber(xlsPage, 0, t + 2, t)
    			XLSUtil.setCellNumber(xlsPage, 1, t + 2, d)
    		}
    
    		// save excel file
    		XLSUtil.saveAndClose(xls)
    	}
    }
    

Leave a Review